Mercurial > hg
comparison hgext/graphlog.py @ 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 |
comparison
equal
deleted
inserted
replaced
14084:2285e5c97f72 | 14085:4852753dae36 |
---|---|
221 % op.replace("_", "-")) | 221 % op.replace("_", "-")) |
222 | 222 |
223 def revset(pats, opts): | 223 def revset(pats, opts): |
224 """Return revset str built of revisions, log options and file patterns. | 224 """Return revset str built of revisions, log options and file patterns. |
225 """ | 225 """ |
226 opt2revset = dict(only_merges='merge()', | 226 opt2revset = { |
227 only_branch='branch($)', | 227 'follow': (0, 'follow()'), |
228 no_merges='not merge()', | 228 'no_merges': (0, 'not merge()'), |
229 include='file($)', | 229 'only_merges': (0, 'merge()'), |
230 exclude='not file($)', | 230 'removed': (0, 'removes("*")'), |
231 prune='not ($ or ancestors($))', | 231 'date': (1, 'date($)'), |
232 user='user($)', | 232 'branch': (2, 'branch($)'), |
233 branch='branch($)', | 233 'exclude': (2, 'not file($)'), |
234 keyword='keyword($)', | 234 'include': (2, 'file($)'), |
235 follow='follow()', | 235 'keyword': (2, 'keyword($)'), |
236 removed='removes("*")') | 236 'only_branch': (2, 'branch($)'), |
237 opt2revset = dict((k, v.replace('$', '%(val)r')) | 237 'prune': (2, 'not ($ or ancestors($))'), |
238 for k,v in opt2revset.iteritems()) | 238 'user': (2, 'user($)'), |
239 } | |
239 revset = [] | 240 revset = [] |
240 for op, val in opts.iteritems(): | 241 for op, val in opts.iteritems(): |
241 if not val: | 242 if not val: |
242 continue | 243 continue |
243 revop = opt2revset.get(op, op) | 244 if op == 'rev': |
244 if op in ('follow', 'only_merges', 'no_merges', 'removed'): | 245 # Already a revset |
245 revset.append('%s' % revop) | 246 revset.extend(val) |
246 elif op in ('date',): | 247 if op not in opt2revset: |
247 revset.append('%s(%r)' % (revop, val)) | 248 continue |
248 elif op in ('include', 'exclude', 'user', 'branch', 'keyword', | 249 arity, revop = opt2revset[op] |
249 'prune', 'only_branch'): | 250 revop = revop.replace('$', '%(val)r') |
251 if arity == 0: | |
252 revset.append(revop) | |
253 elif arity == 1: | |
254 revset.append(revop % {'val': val}) | |
255 else: | |
250 for f in val: | 256 for f in val: |
251 revset.append(revop % {'val': f}) | 257 revset.append(revop % {'val': f}) |
252 elif op == 'rev': | |
253 revset.extend(val) | |
254 | 258 |
255 for path in pats: | 259 for path in pats: |
256 revset.append('file(%r)' % path) | 260 revset.append('file(%r)' % path) |
257 | 261 |
258 revset = ' and '.join(revset) or 'all()' | 262 revset = ' and '.join(revset) or 'all()' |