Czech techie's adventures
Archives
« November 2009
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
     
       
Today
Click me to subscribe
Search

Links
 

Today's Page Hits: 9

Thursday Aug 07, 2008
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:

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:

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:
Linkage: Technorati cosmos Technorati cosmos

Posted at 06:34PM Aug 07, 2008  |  Permanent link to this entry  |  Comments[2]