[PATCH 2 of 6 STABLE v2] graphlog: explicitely join multivalue parameters
Patrick Mezard
patrick at mezard.eu
Wed Feb 22 11:31:33 UTC 2012
# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1329910215 -3600
# Branch stable
# Node ID a44b243f7f52b9ba2ae9edb08cebb0f022b345a3
# Parent 68d017872188e8de77c67826d20fd69a2b09ade9
graphlog: explicitely join multivalue parameters
This will let use override the "join" value (and/or) depending on the option
considered. The option revset arity is now deduced from the revset and the
option value type, to simplify opt2revset definition.
diff --git a/hgext/graphlog.py b/hgext/graphlog.py
--- a/hgext/graphlog.py
+++ b/hgext/graphlog.py
@@ -249,18 +249,18 @@
"""Return revset str built of revisions, log options and file patterns.
"""
opt2revset = {
- 'follow': (0, 'follow()'),
- 'no_merges': (0, 'not merge()'),
- 'only_merges': (0, 'merge()'),
- 'removed': (0, 'removes("*")'),
- 'date': (1, 'date($)'),
- 'branch': (2, 'branch($)'),
- 'exclude': (2, 'not file($)'),
- 'include': (2, 'file($)'),
- 'keyword': (2, 'keyword($)'),
- 'only_branch': (2, 'branch($)'),
- 'prune': (2, 'not ($ or ancestors($))'),
- 'user': (2, 'user($)'),
+ 'follow': ('follow()', None),
+ 'no_merges': ('not merge()', None),
+ 'only_merges': ('merge()', None),
+ 'removed': ('removes("*")', None),
+ 'date': ('date($)', None),
+ 'branch': ('branch($)', ' and '),
+ 'exclude': ('not file($)', ' and '),
+ 'include': ('file($)', ' and '),
+ 'keyword': ('keyword($)', ' and '),
+ 'only_branch': ('branch($)', ' and '),
+ 'prune': ('not ($ or ancestors($))', ' and '),
+ 'user': ('user($)', ' and '),
}
optrevset = []
revset = []
@@ -272,15 +272,16 @@
revset.extend(val)
if op not in opt2revset:
continue
- arity, revop = opt2revset[op]
- revop = revop.replace('$', '%(val)r')
- if arity == 0:
+ revop, andor = opt2revset[op]
+ if '$' not in revop:
optrevset.append(revop)
- elif arity == 1:
- optrevset.append(revop % {'val': val})
else:
- for f in val:
- optrevset.append(revop % {'val': f})
+ revop = revop.replace('$', '%(val)r')
+ if not isinstance(val, list):
+ expr = revop % {'val': val}
+ else:
+ expr = '(' + andor.join((revop % {'val': v}) for v in val) + ')'
+ optrevset.append(expr)
for path in pats:
optrevset.append('file(%r)' % path)
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -1419,7 +1419,7 @@
abort: unknown revision 'something nice'!
[255]
$ hg log -G --print-revset -k 'something' -k 'nice'
- ('group', ('and', ('func', ('symbol', 'keyword'), ('string', 'something')), ('func', ('symbol', 'keyword'), ('string', 'nice'))))
+ ('group', ('group', ('and', ('func', ('symbol', 'keyword'), ('string', 'something')), ('func', ('symbol', 'keyword'), ('string', 'nice')))))
$ hg log -G --only-branch 'something nice'
abort: unknown revision 'something nice'!
[255]
More information about the Mercurial-devel
mailing list