Mercurial > hg
changeset 16158:e04cc21b01b2
graphlog: rewrite --rev like all other options
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Thu, 23 Feb 2012 11:21:30 +0100 |
parents | 4a828d3bc04a |
children | ec33539b61f6 |
files | hgext/graphlog.py tests/test-glog.t |
diffstat | 2 files changed, 14 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/graphlog.py Thu Feb 23 11:21:04 2012 +0100 +++ b/hgext/graphlog.py Thu Feb 23 11:21:30 2012 +0100 @@ -253,13 +253,14 @@ 'no_merges': ('not merge()', None), 'only_merges': ('merge()', None), 'removed': ('removes("*")', None), - 'date': ('date($)', None), - 'branch': ('branch($)', ' or '), - 'exclude': ('not file($)', ' and '), - 'include': ('file($)', ' and '), - 'keyword': ('keyword($)', ' or '), - 'prune': ('not ($ or ancestors($))', ' and '), - 'user': ('user($)', ' or '), + 'date': ('date(%(val)r)', None), + 'branch': ('branch(%(val)r)', ' or '), + 'exclude': ('not file(%(val)r)', ' and '), + 'include': ('file(%(val)r)', ' and '), + 'keyword': ('keyword(%(val)r)', ' or '), + 'prune': ('not (%(val)r or ancestors(%(val)r))', ' and '), + 'user': ('user(%(val)r)', ' or '), + 'rev': ('%(val)s', ' or '), } # branch and only_branch are really aliases and must be handled at @@ -268,36 +269,27 @@ opts = dict(opts) opts['branch'] = opts['branch'] + opts.pop('only_branch') - optrevset = [] revset = [] for op, val in opts.iteritems(): if not val: continue - if op == 'rev': - # Already a revset - revset.extend(val) if op not in opt2revset: continue revop, andor = opt2revset[op] - if '$' not in revop: - optrevset.append(revop) + if '%(val)' not in revop: + revset.append(revop) else: - 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) + revset.append(expr) for path in pats: - optrevset.append('file(%r)' % path) + revset.append('file(%r)' % path) - if revset or optrevset: - if revset: - revset = ['(' + ' or '.join(revset) + ')'] - if optrevset: - revset.append('(' + ' and '.join(optrevset) + ')') - revset = ' and '.join(revset) + if revset: + revset = '(' + ' and '.join(revset) + ')' else: revset = 'all()' return revset
--- a/tests/test-glog.t Thu Feb 23 11:21:04 2012 +0100 +++ b/tests/test-glog.t Thu Feb 23 11:21:30 2012 +0100 @@ -1486,19 +1486,3 @@ $ hg log -G --follow a abort: -G/--graph option is incompatible with --follow with file argument [255] - -Test multiple revision specifications are correctly handled - - $ hg log -G -r 27 -r 25 -r 21 -r 34 -r 32 -r 31 --template '{rev}\n' - o 34 - | - o 32 - |\ - | o 31 - | |\ - o | | 27 - |/ / - | o 25 - |/ - o 21 - |\