Thursday Aug 07, 2008
Thursday Aug 07, 2008
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 Kotaldate: 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:
from mercurial import templatefilters
def newlines(text):
return text.replace(' ', '\n')
def outgoing_hook(ui, repo, **kwargs):
templatefilters.filters["newlines"] = newlines
[extensions] outproc=~/bin/Mercurial/outproc.py [hooks] pre-outgoing=python:outproc.outgoing_hook
changeset = outgoing.template
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}
------------------------------------------------------------------------
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 Kotaldate: 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.
tags:
hg
mercurial
outgoing
template
Linkage:
Technorati cosmos
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.
Posted by Danek Duvall on August 09, 2008 at 07:22 PM CEST #
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.
Posted by Vladimir Kotal on August 18, 2008 at 12:03 PM CEST #