[PATCH] hgweb: changeset view: show parent branch name if different from current

Stepan Koltsov yozh at mx1.ru
Sun Jan 18 18:18:49 CST 2009


Hi, all.

We are hacking lighttpd, and we have a branch for each feature, so
repository has lots of branches and lots of merges. In this case it is
important to know names of branches of parent revisions for each merge
revision. I've raised this problem some time ago for console hg
utility, and the discussion had no result.

Now I'm posting preliminary patch for hgweb here. In changeset view,
in paper theme, parent branch name is printed if it is different from
branch of current revision.

http://screencast.com/t/qpcdmdrbIN7
http://screencast.com/t/aaStF7he

Please, review.

Also, I've made some hacks for templater ("commabefore" key), and I'd
like to know how to do formatting properly.

===
diff -r 44b3f7bbe2f3 mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Thu Jan 15 01:38:52 2009 +0100
+++ b/mercurial/hgweb/webcommands.py	Mon Jan 19 03:17:13 2009 +0300
@@ -243,8 +243,8 @@ def changeset(web, req, tmpl):
                 diff=diffs,
                 rev=ctx.rev(),
                 node=ctx.hex(),
-                parent=webutil.siblings(parents),
-                child=webutil.siblings(ctx.children()),
+                parent=webutil.siblings(parents, origbranch=ctx.branch()),
+                child=webutil.siblings(ctx.children(),
origbranch=ctx.branch()),
                 changesettag=showtags,
                 changesetbranch=showbranch,
                 author=ctx.user(),
diff -r 44b3f7bbe2f3 mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py	Thu Jan 15 01:38:52 2009 +0100
+++ b/mercurial/hgweb/webutil.py	Mon Jan 19 03:17:13 2009 +0300
@@ -58,10 +58,11 @@ def revnavgen(pos, pagelen, limit, nodef

     return nav

-def siblings(siblings=[], hiderev=None, **args):
+def siblings(siblings=[], hiderev=None, origbranch=None, **args):
     siblings = [s for s in siblings if s.node() != nullid]
     if len(siblings) == 1 and siblings[0].rev() == hiderev:
         return
+    commabefore = ""
     for s in siblings:
         d = {'node': hex(s.node()), 'rev': s.rev()}
         d['user'] = s.user()
@@ -69,6 +70,13 @@ def siblings(siblings=[], hiderev=None,
         d['description'] = s.description()
         if hasattr(s, 'path'):
             d['file'] = s.path()
+        if origbranch is not None and s.branch() == origbranch:
+            d['branchifdifferent'] = []
+        else:
+            d['branchifdifferent'] = [{'branch': s.branch()}]
+        d['branch'] = s.branch()
+        d['commabefore'] = commabefore
+        commabefore = ","
         d.update(args)
         yield d

diff -r 44b3f7bbe2f3 templates/paper/map
--- a/templates/paper/map	Thu Jan 15 01:38:52 2009 +0100
+++ b/templates/paper/map	Mon Jan 19 03:17:13 2009 +0300
@@ -43,7 +43,8 @@ diffline = '<a href="#{lineid}" id="{lin

 changelogparent = '<tr><th class="parent">parent {rev}:</th><td
class="parent"><a
href="{url}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></td></tr>'

-changesetparent = '<a
href="{url}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>
'
+changesetparent = '{commabefore} <a
href="{url}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>{branchifdifferent%branchinbraces}'
+branchinbraces = ' ({branch})'

 filerevparent = '<a
href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{rename%filerename}{node|short}</a>
'
 filerevchild = '<a
href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a>
'
===

S.


More information about the Mercurial-devel mailing list