Mercurial > hg
comparison hgext/graphlog.py @ 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 |
comparison
equal
deleted
inserted
replaced
16432:365bb0fa73a4 | 16433:e38b29937118 |
---|---|
295 } | 295 } |
296 | 296 |
297 opts = dict(opts) | 297 opts = dict(opts) |
298 # follow or not follow? | 298 # follow or not follow? |
299 follow = opts.get('follow') or opts.get('follow_first') | 299 follow = opts.get('follow') or opts.get('follow_first') |
300 followfirst = opts.get('follow_first') | 300 followfirst = opts.get('follow_first') and 1 or 0 |
301 # --follow with FILE behaviour depends on revs... | 301 # --follow with FILE behaviour depends on revs... |
302 startrev = revs[0] | 302 startrev = revs[0] |
303 followdescendants = len(revs) > 1 and revs[0] < revs[1] | 303 followdescendants = (len(revs) > 1 and revs[0] < revs[1]) and 1 or 0 |
304 | 304 |
305 # branch and only_branch are really aliases and must be handled at | 305 # branch and only_branch are really aliases and must be handled at |
306 # the same time | 306 # the same time |
307 opts['branch'] = opts.get('branch', []) + opts.get('only_branch', []) | 307 opts['branch'] = opts.get('branch', []) + opts.get('only_branch', []) |
308 opts['branch'] = [repo.lookupbranch(b) for b in opts['branch']] | 308 opts['branch'] = [repo.lookupbranch(b) for b in opts['branch']] |
347 matchargs.append('x:' + p) | 347 matchargs.append('x:' + p) |
348 matchargs = ','.join(('%r' % p) for p in matchargs) | 348 matchargs = ','.join(('%r' % p) for p in matchargs) |
349 opts['_matchfiles'] = matchargs | 349 opts['_matchfiles'] = matchargs |
350 else: | 350 else: |
351 if follow: | 351 if follow: |
352 if followfirst: | 352 fpats = ('_patsfollow', '_patsfollowfirst') |
353 if pats: | 353 fnopats = (('_ancestors', '_fancestors'), |
354 opts['_patsfollowfirst'] = list(pats) | 354 ('_descendants', '_fdescendants')) |
355 else: | 355 if pats: |
356 if followdescendants: | 356 opts[fpats[followfirst]] = list(pats) |
357 opts['_fdescendants'] = str(startrev) | |
358 else: | |
359 opts['_fancestors'] = str(startrev) | |
360 else: | 357 else: |
361 if pats: | 358 opts[fnopats[followdescendants][followfirst]] = str(startrev) |
362 opts['_patsfollow'] = list(pats) | |
363 else: | |
364 if followdescendants: | |
365 opts['_descendants'] = str(startrev) | |
366 else: | |
367 opts['_ancestors'] = str(startrev) | |
368 else: | 359 else: |
369 opts['_patslog'] = list(pats) | 360 opts['_patslog'] = list(pats) |
370 | 361 |
371 filematcher = None | 362 filematcher = None |
372 if opts.get('patch') or opts.get('stat'): | 363 if opts.get('patch') or opts.get('stat'): |