[PATCH] graphlog: add -b [BRANCH] argument

Steve Borho steve at borho.org
Mon Feb 11 09:59:08 CST 2008


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1202745524 21600
# Node ID d60cb6d2e87e19f611516ca410c1695b0383df8a
# Parent  89c70d496175b2e359161a85a66e59fcc0f53012
graphlog: add -b [BRANCH] argument

diff --git a/hgext/graphlog.py b/hgext/graphlog.py
--- a/hgext/graphlog.py
+++ b/hgext/graphlog.py
@@ -12,7 +12,7 @@
 from mercurial.node import nullid, nullrev
 from mercurial.util import Abort, canonpath
 
-def revision_grapher(repo, start_rev, stop_rev):
+def revision_grapher(repo, start_rev, stop_rev, branches=[]):
     """incremental revision grapher
 
     This generator function walks through the revision history from
@@ -40,6 +40,11 @@
 
         # Compute revs and next_revs.
         if curr_rev not in revs:
+            if branches:
+                ctx = repo.changectx(curr_rev)
+                if ctx.branch() not in branches:
+                    curr_rev -= 1
+                    continue
             # New head.
             revs.append(curr_rev)
         rev_index = revs.index(curr_rev)
@@ -218,7 +223,7 @@
         cpath = canonpath(repo.root, os.getcwd(), path)
         grapher = filelog_grapher(repo, cpath, start_rev, stop_rev)
     else:
-        grapher = revision_grapher(repo, start_rev, stop_rev)
+        grapher = revision_grapher(repo, start_rev, stop_rev, opts["only_branch"])
     repo_parents = repo.dirstate.parents()
     prev_n_columns_diff = 0
     prev_node_index = 0
@@ -320,6 +325,8 @@
          [('l', 'limit', '', _('limit number of changes displayed')),
           ('p', 'patch', False, _('show patch')),
           ('r', 'rev', [], _('show the specified revision or range')),
+          ('b', 'only-branch', [],
+            _('show only changesets and ancestors within named branch')),
           ('', 'style', '', _('display using template map file')),
           ('', 'template', '', _('display with template'))],
          _('hg glog [OPTION]... [FILE]')),


More information about the Mercurial-devel mailing list