X

Solaris serviceability and nifty tools

Customizing Mercurial outgoing output

Part of the transition of Mercurial in OpenSolaris
are changes in the integration processes. Every RTI has
to contain output of hg outgoing -v so the CRT
advocates can better see the impact of the changes in terms of changed files.
However, the default output is not very readable:

    $ hg outgoing -v
    comparing with /local/ws-mirrors/onnv-clone.hg
    searching for changes
    changeset: 7248:225922d15fe6
    user: Vladimir Kotal
    date: 2008-08-06 23:39 +0200
    modified: usr/src/cmd/ldap/ns_ldap/ldapaddent.c usr/src/cmd/sendmail/db/config.h usr/src/cmd/ssh/include/config.h usr/src
    /cmd/ssh/include/openbsd-compat.h usr/src/cmd/ssh/include/strsep.h usr/src/cmd/ssh/libopenbsd-compat/Makefile.com usr/src
    /cmd/ssh/libopenbsd-compat/common/llib-lopenbsd-compat usr/src/cmd/ssh/libopenbsd-compat/common/strsep.c usr/src/cmd/ssh/libssh
    /common/llib-lssh usr/src/common/util/string.c usr/src/head/string.h usr/src/lib/libc/amd64/Makefile usr/src/lib/libc
    /i386/Makefile.com usr/src/lib/libc/port/gen/strsep.c usr/src/lib/libc/port/llib-lc usr/src/lib/libc/port/mapfile-vers usr/src
    /lib/libc/sparc/Makefile usr/src/lib/libc/sparcv9/Makefile usr/src/lib/passwdutil/Makefile.com usr/src/lib/passwdutil
    /bsd-strsep.c usr/src/lib/passwdutil/passwdutil.h usr/src/lib/smbsrv/libsmb/common/mapfile-vers usr/src/lib/smbsrv/libsmb
    /common/smb_util.c
    added: usr/src/lib/libc/port/gen/strsep.c
    deleted: usr/src/cmd/ssh/include/strsep.h usr/src/cmd/ssh/libopenbsd-compat/common/strsep.c usr/src/lib/passwdutil/bsd-strsep.c
    log:PSARC 2008/305 strsep() in libc
    4383867 need strsep() in libc
    --------------------------------------------------------------------

In the above case, the list of modified files spans single line which makes the web form used for RTI go really
wild in terms of width (I had to wrap the lines manually in the above example otherwise this page would suffer from the same
problem). The following steps can be used to make the output a bit nicer:


  1. create ~/bin/Mercurial/outproc.py with the following contents:
    from mercurial import templatefilters
    def newlines(text):
    return text.replace(' ', '\\n')
    def outgoing_hook(ui, repo, \*\*kwargs):
    templatefilters.filters["newlines"] = newlines
  2. hook into outgoing command in ~/.hgrc by adding the following lines
    into [hooks], [extensions] sections so it looks like this:
    [extensions]
    outproc=~/bin/Mercurial/outproc.py
    [hooks]
    pre-outgoing=python:outproc.outgoing_hook
  3. create ~/bin/Mercurial/style.outgoing with the following contents:
    changeset = outgoing.template
  4. create ~/bin/Mercurial/outgoing.template with the following contents (the file can
    be downloaded here):
    changeset:

    {rev}:{node|short}
    user:

    {author}
    date:

    {date|isodate}
    modified:
    {files|stringify|newlines}
    added:
    {file_adds|stringify|newlines}
    deleted:
    {file_dels|stringify|newlines}
    log:
    {desc}
    ------------------------------------------------------------------------
  5. add the following into your ~/.bashrc (or to .rc file of the shell of your choice):
    alias outgoing='hg outgoing --style ~/bin/Mercurial/style.outgoing'

After that it works like this:

    $ outgoing
    comparing with /local/ws-mirrors/onnv-clone.hg
    searching for changes
    changeset:

    7248:225922d15fe6
    user:

    Vladimir Kotal
    date:

    2008-08-06 23:39 +0200
    modified:
    usr/src/cmd/ldap/ns_ldap/ldapaddent.c
    usr/src/cmd/sendmail/db/config.h
    usr/src/cmd/ssh/include/config.h
    usr/src/cmd/ssh/include/openbsd-compat.h
    usr/src/cmd/ssh/include/strsep.h
    usr/src/cmd/ssh/libopenbsd-compat/Makefile.com
    usr/src/cmd/ssh/libopenbsd-compat/common/llib-lopenbsd-compat
    usr/src/cmd/ssh/libopenbsd-compat/common/strsep.c
    usr/src/cmd/ssh/libssh/common/llib-lssh
    usr/src/common/util/string.c
    usr/src/head/string.h
    usr/src/lib/libc/amd64/Makefile
    usr/src/lib/libc/i386/Makefile.com
    usr/src/lib/libc/port/gen/strsep.c
    usr/src/lib/libc/port/llib-lc
    usr/src/lib/libc/port/mapfile-vers
    usr/src/lib/libc/sparc/Makefile
    usr/src/lib/libc/sparcv9/Makefile
    usr/src/lib/passwdutil/Makefile.com
    usr/src/lib/passwdutil/bsd-strsep.c
    usr/src/lib/passwdutil/passwdutil.h
    usr/src/lib/smbsrv/libsmb/common/mapfile-vers
    usr/src/lib/smbsrv/libsmb/common/smb_util.c
    added:
    usr/src/lib/libc/port/gen/strsep.c
    deleted:
    usr/src/cmd/ssh/include/strsep.h
    usr/src/cmd/ssh/libopenbsd-compat/common/strsep.c
    usr/src/lib/passwdutil/bsd-strsep.c
    log:
    PSARC 2008/305 strsep() in libc
    4383867 need strsep() in libc
    ------------------------------------------------------------------------

I asked Richard Lowe (who has been very helpful with helping getting the transition process done) if next
Mercurial version can have newlines function already included and if there could be
outgoingtemplate which would be similar to logtemplate in hgrc(5).


In the meantime I will be using the above for my RTIs.

Join the discussion

Comments ( 2 )
  • Danek Duvall Saturday, August 9, 2008

    That format of template file doesn't seem to work on my version of mercurial (the 1.0 that ships on opensolaris). Is a newer version needed?

    Instead, I copied map-cmdline.default from the mercurial directory, and put newlines after each of start_files, file, start_file_{mods,adds,dels,copies}, and file_{mod,add,del,copy}, like this:

    start_files = 'files:\\n'

    file = '{file}\\n'

    and it gave the newlines as in your template, without the need for an extension. Though use of --debug is still needed to get the mods/adds/dels separated out.


  • Vladimir Kotal Monday, August 18, 2008

    The scripts were actually tested on Mercurial 1.0 (sfwnv-x20080429023054). The only place of failure is probably the newlines filter function. Try to see where are the filters defined in the version you're using. Newer versions (0.9 and up) have templater class instead of templatefilters and common_filters variable instead of filters. Try to substitute those in outproc.py and it should work.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.