Mercurial > hg-stable
changeset 16433:e38b29937118
graphlog: reduce duplication in --follow code
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Sat, 14 Apr 2012 11:16:57 +0200 |
parents | 365bb0fa73a4 |
children | 8b62a77d0895 |
files | hgext/graphlog.py |
diffstat | 1 files changed, 8 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/graphlog.py Sat Apr 14 10:44:13 2012 +0200 +++ b/hgext/graphlog.py Sat Apr 14 11:16:57 2012 +0200 @@ -297,10 +297,10 @@ opts = dict(opts) # follow or not follow? follow = opts.get('follow') or opts.get('follow_first') - followfirst = opts.get('follow_first') + followfirst = opts.get('follow_first') and 1 or 0 # --follow with FILE behaviour depends on revs... startrev = revs[0] - followdescendants = len(revs) > 1 and revs[0] < revs[1] + followdescendants = (len(revs) > 1 and revs[0] < revs[1]) and 1 or 0 # branch and only_branch are really aliases and must be handled at # the same time @@ -349,22 +349,13 @@ opts['_matchfiles'] = matchargs else: if follow: - if followfirst: - if pats: - opts['_patsfollowfirst'] = list(pats) - else: - if followdescendants: - opts['_fdescendants'] = str(startrev) - else: - opts['_fancestors'] = str(startrev) + fpats = ('_patsfollow', '_patsfollowfirst') + fnopats = (('_ancestors', '_fancestors'), + ('_descendants', '_fdescendants')) + if pats: + opts[fpats[followfirst]] = list(pats) else: - if pats: - opts['_patsfollow'] = list(pats) - else: - if followdescendants: - opts['_descendants'] = str(startrev) - else: - opts['_ancestors'] = str(startrev) + opts[fnopats[followdescendants][followfirst]] = str(startrev) else: opts['_patslog'] = list(pats)