##// END OF EJS Templates
graphlog: rewrite --rev like all other options
Patrick Mezard -
r16158:e04cc21b default
parent child Browse files
Show More
@@ -253,13 +253,14 b' def revset(pats, opts):'
253 'no_merges': ('not merge()', None),
253 'no_merges': ('not merge()', None),
254 'only_merges': ('merge()', None),
254 'only_merges': ('merge()', None),
255 'removed': ('removes("*")', None),
255 'removed': ('removes("*")', None),
256 'date': ('date($)', None),
256 'date': ('date(%(val)r)', None),
257 'branch': ('branch($)', ' or '),
257 'branch': ('branch(%(val)r)', ' or '),
258 'exclude': ('not file($)', ' and '),
258 'exclude': ('not file(%(val)r)', ' and '),
259 'include': ('file($)', ' and '),
259 'include': ('file(%(val)r)', ' and '),
260 'keyword': ('keyword($)', ' or '),
260 'keyword': ('keyword(%(val)r)', ' or '),
261 'prune': ('not ($ or ancestors($))', ' and '),
261 'prune': ('not (%(val)r or ancestors(%(val)r))', ' and '),
262 'user': ('user($)', ' or '),
262 'user': ('user(%(val)r)', ' or '),
263 'rev': ('%(val)s', ' or '),
263 }
264 }
264
265
265 # branch and only_branch are really aliases and must be handled at
266 # branch and only_branch are really aliases and must be handled at
@@ -268,36 +269,27 b' def revset(pats, opts):'
268 opts = dict(opts)
269 opts = dict(opts)
269 opts['branch'] = opts['branch'] + opts.pop('only_branch')
270 opts['branch'] = opts['branch'] + opts.pop('only_branch')
270
271
271 optrevset = []
272 revset = []
272 revset = []
273 for op, val in opts.iteritems():
273 for op, val in opts.iteritems():
274 if not val:
274 if not val:
275 continue
275 continue
276 if op == 'rev':
277 # Already a revset
278 revset.extend(val)
279 if op not in opt2revset:
276 if op not in opt2revset:
280 continue
277 continue
281 revop, andor = opt2revset[op]
278 revop, andor = opt2revset[op]
282 if '$' not in revop:
279 if '%(val)' not in revop:
283 optrevset.append(revop)
280 revset.append(revop)
284 else:
281 else:
285 revop = revop.replace('$', '%(val)r')
286 if not isinstance(val, list):
282 if not isinstance(val, list):
287 expr = revop % {'val': val}
283 expr = revop % {'val': val}
288 else:
284 else:
289 expr = '(' + andor.join((revop % {'val': v}) for v in val) + ')'
285 expr = '(' + andor.join((revop % {'val': v}) for v in val) + ')'
290 optrevset.append(expr)
286 revset.append(expr)
291
287
292 for path in pats:
288 for path in pats:
293 optrevset.append('file(%r)' % path)
289 revset.append('file(%r)' % path)
294
290
295 if revset or optrevset:
291 if revset:
296 if revset:
292 revset = '(' + ' and '.join(revset) + ')'
297 revset = ['(' + ' or '.join(revset) + ')']
298 if optrevset:
299 revset.append('(' + ' and '.join(optrevset) + ')')
300 revset = ' and '.join(revset)
301 else:
293 else:
302 revset = 'all()'
294 revset = 'all()'
303 return revset
295 return revset
@@ -1486,19 +1486,3 b' Test log -G options'
1486 $ hg log -G --follow a
1486 $ hg log -G --follow a
1487 abort: -G/--graph option is incompatible with --follow with file argument
1487 abort: -G/--graph option is incompatible with --follow with file argument
1488 [255]
1488 [255]
1489
1490 Test multiple revision specifications are correctly handled
1491
1492 $ hg log -G -r 27 -r 25 -r 21 -r 34 -r 32 -r 31 --template '{rev}\n'
1493 o 34
1494 |
1495 o 32
1496 |\
1497 | o 31
1498 | |\
1499 o | | 27
1500 |/ /
1501 | o 25
1502 |/
1503 o 21
1504 |\
General Comments 0
You need to be logged in to leave comments. Login now