comparison hgext/graphlog.py @ 16409:2cbd7dd0cc1f

graphlog: fix --follow-first --rev combinations This solves a similar problem than the previous --follow/--rev patch. This time we need changelog.ancestors()/descendants() filtering on first parent. Duplicating the code looked better than introducing keyword arguments. Besides, the ancestors() version was already implemented in follow() revset.
author Patrick Mezard <patrick@mezard.eu>
date Wed, 11 Apr 2012 11:25:34 +0200
parents d74099ac2ac1
children 4c2edcd84175
comparison
equal deleted inserted replaced
16408:d74099ac2ac1 16409:2cbd7dd0cc1f
277 are not passed filematcher is None. Otherwise it is a callable 277 are not passed filematcher is None. Otherwise it is a callable
278 taking a revision number and returning a match objects filtering 278 taking a revision number and returning a match objects filtering
279 the files to be detailed when displaying the revision. 279 the files to be detailed when displaying the revision.
280 """ 280 """
281 opt2revset = { 281 opt2revset = {
282 'follow_first': ('_followfirst()', None),
283 'no_merges': ('not merge()', None), 282 'no_merges': ('not merge()', None),
284 'only_merges': ('merge()', None), 283 'only_merges': ('merge()', None),
285 '_ancestors': ('ancestors(%(val)s)', None), 284 '_ancestors': ('ancestors(%(val)s)', None),
285 '_fancestors': ('_firstancestors(%(val)s)', None),
286 '_descendants': ('descendants(%(val)s)', None), 286 '_descendants': ('descendants(%(val)s)', None),
287 '_fdescendants': ('_firstdescendants(%(val)s)', None),
287 '_matchfiles': ('_matchfiles(%(val)s)', None), 288 '_matchfiles': ('_matchfiles(%(val)s)', None),
288 'date': ('date(%(val)r)', None), 289 'date': ('date(%(val)r)', None),
289 'branch': ('branch(%(val)r)', ' or '), 290 'branch': ('branch(%(val)r)', ' or '),
290 '_patslog': ('filelog(%(val)r)', ' or '), 291 '_patslog': ('filelog(%(val)r)', ' or '),
291 '_patsfollow': ('follow(%(val)r)', ' or '), 292 '_patsfollow': ('follow(%(val)r)', ' or '),
297 298
298 opts = dict(opts) 299 opts = dict(opts)
299 # follow or not follow? 300 # follow or not follow?
300 follow = opts.get('follow') or opts.get('follow_first') 301 follow = opts.get('follow') or opts.get('follow_first')
301 followfirst = opts.get('follow_first') 302 followfirst = opts.get('follow_first')
302 if 'follow_first' in opts:
303 del opts['follow_first']
304 # --follow with FILE behaviour depends on revs... 303 # --follow with FILE behaviour depends on revs...
305 startrev = revs[0] 304 startrev = revs[0]
306 followdescendants = len(revs) > 1 and revs[0] < revs[1] 305 followdescendants = len(revs) > 1 and revs[0] < revs[1]
307 306
308 # branch and only_branch are really aliases and must be handled at 307 # branch and only_branch are really aliases and must be handled at
354 if follow: 353 if follow:
355 if followfirst: 354 if followfirst:
356 if pats: 355 if pats:
357 opts['_patsfollowfirst'] = list(pats) 356 opts['_patsfollowfirst'] = list(pats)
358 else: 357 else:
359 opts['follow_first'] = True 358 if followdescendants:
359 opts['_fdescendants'] = str(startrev)
360 else:
361 opts['_fancestors'] = str(startrev)
360 else: 362 else:
361 if pats: 363 if pats:
362 opts['_patsfollow'] = list(pats) 364 opts['_patsfollow'] = list(pats)
363 else: 365 else:
364 if followdescendants: 366 if followdescendants: