hgext/graphlog.py
changeset 16408 d74099ac2ac1
parent 16407 49ef1c382965
child 16409 2cbd7dd0cc1f
equal deleted inserted replaced
16407:49ef1c382965 16408:d74099ac2ac1
   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':           ('follow()', None),
       
   283         'follow_first':     ('_followfirst()', None),
   282         'follow_first':     ('_followfirst()', None),
   284         'no_merges':        ('not merge()', None),
   283         'no_merges':        ('not merge()', None),
   285         'only_merges':      ('merge()', None),
   284         'only_merges':      ('merge()', None),
       
   285         '_ancestors':       ('ancestors(%(val)s)', None),
       
   286         '_descendants':     ('descendants(%(val)s)', None),
   286         '_matchfiles':      ('_matchfiles(%(val)s)', None),
   287         '_matchfiles':      ('_matchfiles(%(val)s)', None),
   287         'date':             ('date(%(val)r)', None),
   288         'date':             ('date(%(val)r)', None),
   288         'branch':           ('branch(%(val)r)', ' or '),
   289         'branch':           ('branch(%(val)r)', ' or '),
   289         '_patslog':         ('filelog(%(val)r)', ' or '),
   290         '_patslog':         ('filelog(%(val)r)', ' or '),
   290         '_patsfollow':      ('follow(%(val)r)', ' or '),
   291         '_patsfollow':      ('follow(%(val)r)', ' or '),
   296 
   297 
   297     opts = dict(opts)
   298     opts = dict(opts)
   298     # follow or not follow?
   299     # follow or not follow?
   299     follow = opts.get('follow') or opts.get('follow_first')
   300     follow = opts.get('follow') or opts.get('follow_first')
   300     followfirst = opts.get('follow_first')
   301     followfirst = opts.get('follow_first')
   301     if 'follow' in opts:
       
   302         del opts['follow']
       
   303     if 'follow_first' in opts:
   302     if 'follow_first' in opts:
   304         del opts['follow_first']
   303         del opts['follow_first']
       
   304     # --follow with FILE behaviour depends on revs...
       
   305     startrev = revs[0]
       
   306     followdescendants = len(revs) > 1 and revs[0] < revs[1]
   305 
   307 
   306     # branch and only_branch are really aliases and must be handled at
   308     # branch and only_branch are really aliases and must be handled at
   307     # the same time
   309     # the same time
   308     opts['branch'] = opts.get('branch', []) + opts.get('only_branch', [])
   310     opts['branch'] = opts.get('branch', []) + opts.get('only_branch', [])
   309     opts['branch'] = [repo.lookupbranch(b) for b in opts['branch']]
   311     opts['branch'] = [repo.lookupbranch(b) for b in opts['branch']]
   357                     opts['follow_first'] = True
   359                     opts['follow_first'] = True
   358             else:
   360             else:
   359                 if pats:
   361                 if pats:
   360                     opts['_patsfollow'] = list(pats)
   362                     opts['_patsfollow'] = list(pats)
   361                 else:
   363                 else:
   362                     opts['follow'] = True
   364                     if followdescendants:
       
   365                         opts['_descendants'] = str(startrev)
       
   366                     else:
       
   367                         opts['_ancestors'] = str(startrev)
   363         else:
   368         else:
   364             opts['_patslog'] = list(pats)
   369             opts['_patslog'] = list(pats)
   365 
   370 
   366     filematcher = None
   371     filematcher = None
   367     if opts.get('patch') or opts.get('stat'):
   372     if opts.get('patch') or opts.get('stat'):
   400     callable taking a revision number and returning a match objects
   405     callable taking a revision number and returning a match objects
   401     filtering the files to be detailed when displaying the revision.
   406     filtering the files to be detailed when displaying the revision.
   402     """
   407     """
   403     if not len(repo):
   408     if not len(repo):
   404         return [], None, None
   409         return [], None, None
       
   410     # Default --rev value depends on --follow but --follow behaviour
       
   411     # depends on revisions resolved from --rev...
       
   412     follow = opts.get('follow') or opts.get('follow_first')
   405     if opts.get('rev'):
   413     if opts.get('rev'):
   406         revs = scmutil.revrange(repo, opts['rev'])
   414         revs = scmutil.revrange(repo, opts['rev'])
   407     else:
   415     else:
   408         revs = range(len(repo))
   416         if follow and len(repo) > 0:
       
   417             revs = scmutil.revrange(repo, ['.:0'])
       
   418         else:
       
   419             revs = range(len(repo) - 1, -1, -1)
   409     if not revs:
   420     if not revs:
   410         return [], None, None
   421         return [], None, None
   411     expr, filematcher = _makelogrevset(repo, pats, opts, revs)
   422     expr, filematcher = _makelogrevset(repo, pats, opts, revs)
   412     if expr:
   423     if expr:
   413         # Evaluate revisions in changelog order for performance
   424         # Evaluate revisions in changelog order for performance