Mercurial > hg
diff hgext/graphlog.py @ 16147:5607d829bf17
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.
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Wed, 22 Feb 2012 12:30:15 +0100 |
parents | eb87fbc6d702 |
children | 184cc3c3e0a6 |
line wrap: on
line diff
--- a/hgext/graphlog.py Wed Feb 22 12:30:14 2012 +0100 +++ b/hgext/graphlog.py Wed Feb 22 12:30:15 2012 +0100 @@ -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)