Mercurial > public > mercurial-scm > hg
diff hgext/graphlog.py @ 16408:d74099ac2ac1
graphlog: fix --follow --rev combinations
The previous behaviour of --follow was really a subset of what is really
happening in log command:
- If --rev is not passed, default to '.:0'
- Resolve --rev into a revision list "revs"
- Set the starting revision to revs[0]
- If revs[1] > revs[0] keep descendants(revs[0]) in revs, otherwise keep
ancestors.
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Wed, 11 Apr 2012 11:22:40 +0200 |
parents | 49ef1c382965 |
children | 2cbd7dd0cc1f |
line wrap: on
line diff
--- a/hgext/graphlog.py Wed Apr 11 11:17:26 2012 +0200 +++ b/hgext/graphlog.py Wed Apr 11 11:22:40 2012 +0200 @@ -279,10 +279,11 @@ the files to be detailed when displaying the revision. """ opt2revset = { - 'follow': ('follow()', None), 'follow_first': ('_followfirst()', None), 'no_merges': ('not merge()', None), 'only_merges': ('merge()', None), + '_ancestors': ('ancestors(%(val)s)', None), + '_descendants': ('descendants(%(val)s)', None), '_matchfiles': ('_matchfiles(%(val)s)', None), 'date': ('date(%(val)r)', None), 'branch': ('branch(%(val)r)', ' or '), @@ -298,10 +299,11 @@ # follow or not follow? follow = opts.get('follow') or opts.get('follow_first') followfirst = opts.get('follow_first') - if 'follow' in opts: - del opts['follow'] if 'follow_first' in opts: del opts['follow_first'] + # --follow with FILE behaviour depends on revs... + startrev = revs[0] + followdescendants = len(revs) > 1 and revs[0] < revs[1] # branch and only_branch are really aliases and must be handled at # the same time @@ -359,7 +361,10 @@ if pats: opts['_patsfollow'] = list(pats) else: - opts['follow'] = True + if followdescendants: + opts['_descendants'] = str(startrev) + else: + opts['_ancestors'] = str(startrev) else: opts['_patslog'] = list(pats) @@ -402,10 +407,16 @@ """ if not len(repo): return [], None, None + # Default --rev value depends on --follow but --follow behaviour + # depends on revisions resolved from --rev... + follow = opts.get('follow') or opts.get('follow_first') if opts.get('rev'): revs = scmutil.revrange(repo, opts['rev']) else: - revs = range(len(repo)) + if follow and len(repo) > 0: + revs = scmutil.revrange(repo, ['.:0']) + else: + revs = range(len(repo) - 1, -1, -1) if not revs: return [], None, None expr, filematcher = _makelogrevset(repo, pats, opts, revs)