Mercurial > hg-stable
changeset 14085:4852753dae36
graphlog: unify log -G revset translation
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sat, 30 Apr 2011 19:42:00 +0200 |
parents | 2285e5c97f72 |
children | 2d7cb340a53f |
files | hgext/graphlog.py |
diffstat | 1 files changed, 26 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/graphlog.py Sat Apr 30 19:42:00 2011 +0200 +++ b/hgext/graphlog.py Sat Apr 30 19:42:00 2011 +0200 @@ -223,34 +223,38 @@ def revset(pats, opts): """Return revset str built of revisions, log options and file patterns. """ - opt2revset = dict(only_merges='merge()', - only_branch='branch($)', - no_merges='not merge()', - include='file($)', - exclude='not file($)', - prune='not ($ or ancestors($))', - user='user($)', - branch='branch($)', - keyword='keyword($)', - follow='follow()', - removed='removes("*")') - opt2revset = dict((k, v.replace('$', '%(val)r')) - for k,v in opt2revset.iteritems()) + 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($)'), + } revset = [] for op, val in opts.iteritems(): if not val: continue - revop = opt2revset.get(op, op) - if op in ('follow', 'only_merges', 'no_merges', 'removed'): - revset.append('%s' % revop) - elif op in ('date',): - revset.append('%s(%r)' % (revop, val)) - elif op in ('include', 'exclude', 'user', 'branch', 'keyword', - 'prune', 'only_branch'): + if op == 'rev': + # Already a revset + revset.extend(val) + if op not in opt2revset: + continue + arity, revop = opt2revset[op] + revop = revop.replace('$', '%(val)r') + if arity == 0: + revset.append(revop) + elif arity == 1: + revset.append(revop % {'val': val}) + else: for f in val: revset.append(revop % {'val': f}) - elif op == 'rev': - revset.extend(val) for path in pats: revset.append('file(%r)' % path)