[PATCH 1 of 5] graphlog: --branch and --only-branch are the same

Patrick Mezard patrick at mezard.eu
Thu Feb 23 11:10:27 CST 2012


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1329992464 -3600
# Node ID 4a828d3bc04a42bdba153dea03233121475418c4
# Parent  816211dfa3a586915111a2429b7606fa324ab25a
graphlog: --branch and --only-branch are the same

Handling the aliasing in fancyopts would be cleaner but I do not want to make
this change for stable.

diff --git a/hgext/graphlog.py b/hgext/graphlog.py
--- a/hgext/graphlog.py
+++ b/hgext/graphlog.py
@@ -258,10 +258,16 @@
         'exclude':     ('not file($)', ' and '),
         'include':     ('file($)', ' and '),
         'keyword':     ('keyword($)', ' or '),
-        'only_branch': ('branch($)', ' and '),
         'prune':       ('not ($ or ancestors($))', ' and '),
         'user':        ('user($)', ' or '),
         }
+
+    # branch and only_branch are really aliases and must be handled at
+    # the same time
+    if 'branch' in opts and 'only_branch' in opts:
+        opts = dict(opts)
+        opts['branch'] = opts['branch'] + opts.pop('only_branch')
+
     optrevset = []
     revset = []
     for op, val in opts.iteritems():
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -1433,13 +1433,10 @@
   ('group', ('group', ('func', ('symbol', 'branch'), ('string', 'not-a-branch'))))
   abort: unknown revision 'not-a-branch'!
   abort: unknown revision 'not-a-branch'!
-  $ testlog -b default -b branch
-  ('group', ('group', ('or', ('func', ('symbol', 'branch'), ('string', 'default')), ('func', ('symbol', 'branch'), ('string', 'branch')))))
+  $ testlog -b default -b branch --only-branch branch
+  ('group', ('group', ('or', ('or', ('func', ('symbol', 'branch'), ('string', 'default')), ('func', ('symbol', 'branch'), ('string', 'branch'))), ('func', ('symbol', 'branch'), ('string', 'branch')))))
   $ testlog -k expand -k merge
   ('group', ('group', ('or', ('func', ('symbol', 'keyword'), ('string', 'expand')), ('func', ('symbol', 'keyword'), ('string', 'merge')))))
-  $ hg log -G --only-branch 'something nice'
-  abort: unknown revision 'something nice'!
-  [255]
   $ hg log -G --include 'some file' --exclude 'another file'
   $ hg log -G --follow  --template 'nodetag {rev}\n' | grep nodetag | wc -l
   \s*36 (re)


More information about the Mercurial-devel mailing list