-
Notifications
You must be signed in to change notification settings - Fork 0
/
customizing-mercurial-outgoing-output.html
7 lines (7 loc) · 6.02 KB
/
customizing-mercurial-outgoing-output.html
1
2
3
4
5
6
7
<html><body>
<head>
<title>Customizing Mercurial outgoing output | Oracle Czech techie's adventures Blog</title>
<meta name="publish_date" content="2008-08-07 09:34:56">
</head>
<p>Part of the <a href="http://opensolaris.org/os/project/scm-migration/">transition of Mercurial</a> in OpenSolaris <br/>are changes in the integration processes. Every <a href="http://opensolaris.org/os/community/on/crt/rti-nits/">RTI</a> has<br/>to contain output of <tt>hg outgoing -v</tt> so the <a href="http://www.opensolaris.org/os/community/on/crt/">CRT</a><br/>advocates can better see the impact of the changes in terms of changed files. <br/>However, the default output is not very readable:</p><ul><pre>$ hg outgoing -v<br/>comparing with /local/ws-mirrors/onnv-clone.hg<br/>searching for changes<br/>changeset: 7248:225922d15fe6<br/>user: Vladimir Kotal <Vladimir.Kotal@Sun.COM><br/>date: 2008-08-06 23:39 +0200<br/>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<br/>/cmd/ssh/include/openbsd-compat.h usr/src/cmd/ssh/include/strsep.h usr/src/cmd/ssh/libopenbsd-compat/Makefile.com usr/src<br/>/cmd/ssh/libopenbsd-compat/common/llib-lopenbsd-compat usr/src/cmd/ssh/libopenbsd-compat/common/strsep.c usr/src/cmd/ssh/libssh<br/>/common/llib-lssh usr/src/common/util/string.c usr/src/head/string.h usr/src/lib/libc/amd64/Makefile usr/src/lib/libc<br/>/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<br/>/lib/libc/sparc/Makefile usr/src/lib/libc/sparcv9/Makefile usr/src/lib/passwdutil/Makefile.com usr/src/lib/passwdutil<br/>/bsd-strsep.c usr/src/lib/passwdutil/passwdutil.h usr/src/lib/smbsrv/libsmb/common/mapfile-vers usr/src/lib/smbsrv/libsmb<br/>/common/smb_util.c<br/>added: usr/src/lib/libc/port/gen/strsep.c<br/>deleted: usr/src/cmd/ssh/include/strsep.h usr/src/cmd/ssh/libopenbsd-compat/common/strsep.c usr/src/lib/passwdutil/bsd-strsep.c<br/>log:PSARC 2008/305 strsep() in libc<br/>4383867 need strsep() in libc<br/>--------------------------------------------------------------------</pre></ul><p>In the above case, the list of modified files spans single line which makes the web form used for RTI go really <br/>wild in terms of width (I had to wrap the lines manually in the above example otherwise this page would suffer from the same<br/>problem). The following steps can be used to make the output a bit nicer:</p><br/><ol><li>create <tt>~/bin/Mercurial/outproc.py</tt> with the following contents:<pre>from mercurial import templatefilters<br/>def newlines(text):<br/> return text.replace(' ', '\\n')<br/>def outgoing_hook(ui, repo, \*\*kwargs):<br/> templatefilters.filters["newlines"] = newlines</pre></li><li>hook into outgoing command in <tt>~/.hgrc</tt> by adding the following lines<br/> into <tt>[hooks]</tt>, <tt>[extensions]</tt> sections so it looks like this:<pre>[extensions]<br/>outproc=~/bin/Mercurial/outproc.py<br/>[hooks]<br/>pre-outgoing=python:outproc.outgoing_hook</pre></li><li>create <tt>~/bin/Mercurial/style.outgoing</tt> with the following contents:<pre>changeset = outgoing.template</pre></li><li>create <tt>~/bin/Mercurial/outgoing.template</tt> with the following contents (the file can<br/> be downloaded <a href="http://blogs.sun.com/vlad/resource/outgoing.template">here</a>):<pre>changeset:<p style="text-indent:5em;"></p>{rev}:{node|short}<br/>user:<p style="text-indent:5em;"></p>{author}<br/>date:<p style="text-indent:5em;"></p>{date|isodate}<br/>modified:<br/>{files|stringify|newlines}<br/>added:<br/>{file_adds|stringify|newlines}<br/>deleted:<br/>{file_dels|stringify|newlines}<br/>log:<br/>{desc}<br/>------------------------------------------------------------------------</pre></li><li>add the following into your <tt>~/.bashrc</tt> (or to .rc file of the shell of your choice):<pre>alias outgoing='hg outgoing --style ~/bin/Mercurial/style.outgoing'</pre></li><br/></ol><p>After that it works like this:</p><ul><pre>$ outgoing<br/>comparing with /local/ws-mirrors/onnv-clone.hg<br/>searching for changes<br/>changeset:<p style="text-indent:5em;"></p>7248:225922d15fe6<br/>user:<p style="text-indent:5em;"></p>Vladimir Kotal <Vladimir.Kotal@Sun.COM><br/>date:<p style="text-indent:5em;"></p>2008-08-06 23:39 +0200<br/>modified:<br/>usr/src/cmd/ldap/ns_ldap/ldapaddent.c<br/>usr/src/cmd/sendmail/db/config.h<br/>usr/src/cmd/ssh/include/config.h<br/>usr/src/cmd/ssh/include/openbsd-compat.h<br/>usr/src/cmd/ssh/include/strsep.h<br/>usr/src/cmd/ssh/libopenbsd-compat/Makefile.com<br/>usr/src/cmd/ssh/libopenbsd-compat/common/llib-lopenbsd-compat<br/>usr/src/cmd/ssh/libopenbsd-compat/common/strsep.c<br/>usr/src/cmd/ssh/libssh/common/llib-lssh<br/>usr/src/common/util/string.c<br/>usr/src/head/string.h<br/>usr/src/lib/libc/amd64/Makefile<br/>usr/src/lib/libc/i386/Makefile.com<br/>usr/src/lib/libc/port/gen/strsep.c<br/>usr/src/lib/libc/port/llib-lc<br/>usr/src/lib/libc/port/mapfile-vers<br/>usr/src/lib/libc/sparc/Makefile<br/>usr/src/lib/libc/sparcv9/Makefile<br/>usr/src/lib/passwdutil/Makefile.com<br/>usr/src/lib/passwdutil/bsd-strsep.c<br/>usr/src/lib/passwdutil/passwdutil.h<br/>usr/src/lib/smbsrv/libsmb/common/mapfile-vers<br/>usr/src/lib/smbsrv/libsmb/common/smb_util.c<br/>added:<br/>usr/src/lib/libc/port/gen/strsep.c<br/>deleted:<br/>usr/src/cmd/ssh/include/strsep.h<br/>usr/src/cmd/ssh/libopenbsd-compat/common/strsep.c<br/>usr/src/lib/passwdutil/bsd-strsep.c<br/>log:<br/>PSARC 2008/305 strsep() in libc<br/>4383867 need strsep() in libc<br/>------------------------------------------------------------------------</pre></ul><p>I asked Richard Lowe (who has been very helpful with helping getting the transition process done) if next<br/>Mercurial version can have <tt>newlines</tt> function already included and if there could be <br/><tt>outgoingtemplate</tt> which would be similar to <tt>logtemplate</tt> in hgrc(5).<br/><br/><br/>In the meantime I will be using the above for my RTIs.</p>
</body></html>