mercurial/commands.py
changeset 2779 12a7bfcafd8f
parent 2778 2e0cd25fe4ac
child 2784 e3564699409c
equal deleted inserted replaced
2778:2e0cd25fe4ac 2779:12a7bfcafd8f
   123                 if windowsize < sizelimit:
   123                 if windowsize < sizelimit:
   124                     windowsize *= 2
   124                     windowsize *= 2
   125 
   125 
   126 
   126 
   127     files, matchfn, anypats = matchpats(repo, pats, opts)
   127     files, matchfn, anypats = matchpats(repo, pats, opts)
   128     follow = opts.get('follow')
   128     follow = opts.get('follow') or opts.get('follow_first')
   129 
   129 
   130     if repo.changelog.count() == 0:
   130     if repo.changelog.count() == 0:
   131         return [], False, matchfn
   131         return [], False, matchfn
   132 
   132 
   133     if follow:
   133     if follow:
   215                 fncache[rev] = matches
   215                 fncache[rev] = matches
   216                 wanted[rev] = 1
   216                 wanted[rev] = 1
   217 
   217 
   218     def iterate():
   218     def iterate():
   219         class followfilter:
   219         class followfilter:
   220             def __init__(self):
   220             def __init__(self, onlyfirst=False):
   221                 self.startrev = -1
   221                 self.startrev = -1
   222                 self.roots = []
   222                 self.roots = []
       
   223                 self.onlyfirst = onlyfirst
   223 
   224 
   224             def match(self, rev):
   225             def match(self, rev):
   225                 def realparents(rev):
   226                 def realparents(rev):
   226                     return filter(lambda x: x != -1, repo.changelog.parentrevs(rev))
   227                     if self.onlyfirst:
       
   228                         return repo.changelog.parentrevs(rev)[0:1]
       
   229                     else:
       
   230                         return filter(lambda x: x != -1, repo.changelog.parentrevs(rev))
   227 
   231 
   228                 if self.startrev == -1:
   232                 if self.startrev == -1:
   229                     self.startrev = rev
   233                     self.startrev = rev
   230                     return True
   234                     return True
   231 
   235 
   247                         return True
   251                         return True
   248 
   252 
   249                 return False
   253                 return False
   250 
   254 
   251         if follow and not files:
   255         if follow and not files:
   252             ff = followfilter()
   256             ff = followfilter(onlyfirst=opts.get('follow_first'))
   253             def want(rev):
   257             def want(rev):
   254                 if rev not in wanted:
   258                 if rev not in wanted:
   255                     return False
   259                     return False
   256                 return ff.match(rev)
   260                 return ff.match(rev)
   257         else:
   261         else:
  2023     project.
  2027     project.
  2024 
  2028 
  2025     File history is shown without following rename or copy history of
  2029     File history is shown without following rename or copy history of
  2026     files.  Use -f/--follow with a file name to follow history across
  2030     files.  Use -f/--follow with a file name to follow history across
  2027     renames and copies. --follow without a file name will only show
  2031     renames and copies. --follow without a file name will only show
  2028     ancestors or descendants of the starting revision.
  2032     ancestors or descendants of the starting revision. --follow-first
       
  2033     only follows the first parent of merge revisions.
  2029 
  2034 
  2030     If no revision range is specified, the default is tip:0 unless
  2035     If no revision range is specified, the default is tip:0 unless
  2031     --follow is set, in which case the working directory parent is
  2036     --follow is set, in which case the working directory parent is
  2032     used as the starting revision.
  2037     used as the starting revision.
  2033 
  2038 
  3142     "^log|history":
  3147     "^log|history":
  3143         (log,
  3148         (log,
  3144          [('b', 'branches', None, _('show branches')),
  3149          [('b', 'branches', None, _('show branches')),
  3145           ('f', 'follow', None,
  3150           ('f', 'follow', None,
  3146            _('follow changeset history, or file history across copies and renames')),
  3151            _('follow changeset history, or file history across copies and renames')),
       
  3152           ('', 'follow-first', None,
       
  3153            _('only follow the first parent of merge changesets')),
  3147           ('k', 'keyword', [], _('search for a keyword')),
  3154           ('k', 'keyword', [], _('search for a keyword')),
  3148           ('l', 'limit', '', _('limit number of changes displayed')),
  3155           ('l', 'limit', '', _('limit number of changes displayed')),
  3149           ('r', 'rev', [], _('show the specified revision or range')),
  3156           ('r', 'rev', [], _('show the specified revision or range')),
  3150           ('M', 'no-merges', None, _('do not show merges')),
  3157           ('M', 'no-merges', None, _('do not show merges')),
  3151           ('', 'style', '', _('display using template map file')),
  3158           ('', 'style', '', _('display using template map file')),