comparison mercurial/commands.py @ 2777:21e571c21a6b

Make log --follow without a file list follow a single head. This includes all the parents or children (depending on the direction of the revision range).
author Brendan Cully <brendan@kublai.com>
date Thu, 03 Aug 2006 11:06:09 -0700
parents 71029a3247cb
children 2e0cd25fe4ac
comparison
equal deleted inserted replaced
2765:0327bd1c831c 2777:21e571c21a6b
204 if matches: 204 if matches:
205 fncache[rev] = matches 205 fncache[rev] = matches
206 wanted[rev] = 1 206 wanted[rev] = 1
207 207
208 def iterate(): 208 def iterate():
209 class followfilter:
210 def __init__(self):
211 self.startrev = -1
212 self.roots = []
213
214 def match(self, rev):
215 def realparents(rev):
216 return filter(lambda x: x != -1, repo.changelog.parentrevs(rev))
217
218 if self.startrev == -1:
219 self.startrev = rev
220 return True
221
222 if rev > self.startrev:
223 # forward: all descendants
224 if not self.roots:
225 self.roots.append(self.startrev)
226 for parent in realparents(rev):
227 if parent in self.roots:
228 self.roots.append(rev)
229 return True
230 else:
231 # backwards: all parents
232 if not self.roots:
233 self.roots.extend(realparents(self.startrev))
234 if rev in self.roots:
235 self.roots.remove(rev)
236 self.roots.extend(realparents(rev))
237 return True
238
239 return False
240
241 if follow and not files:
242 ff = followfilter()
243 def want(rev):
244 if rev not in wanted:
245 return False
246 return ff.match(rev)
247 else:
248 def want(rev):
249 return rev in wanted
250
209 for i, window in increasing_windows(0, len(revs)): 251 for i, window in increasing_windows(0, len(revs)):
210 yield 'window', revs[0] < revs[-1], revs[-1] 252 yield 'window', revs[0] < revs[-1], revs[-1]
211 nrevs = [rev for rev in revs[i:i+window] 253 nrevs = [rev for rev in revs[i:i+window] if want(rev)]
212 if rev in wanted]
213 srevs = list(nrevs) 254 srevs = list(nrevs)
214 srevs.sort() 255 srevs.sort()
215 for rev in srevs: 256 for rev in srevs:
216 fns = fncache.get(rev) or filter(matchfn, getchange(rev)[3]) 257 fns = fncache.get(rev) or filter(matchfn, getchange(rev)[3])
217 yield 'add', rev, fns 258 yield 'add', rev, fns
1970 2011
1971 Print the revision history of the specified files or the entire 2012 Print the revision history of the specified files or the entire
1972 project. 2013 project.
1973 2014
1974 File history is shown without following rename or copy history of 2015 File history is shown without following rename or copy history of
1975 files. Use -f/--follow to follow history across renames and 2016 files. Use -f/--follow with a file name to follow history across
1976 copies. 2017 renames and copies. --follow without a file name will only show
2018 ancestors or descendants of the starting revision.
1977 2019
1978 By default this command outputs: changeset id and hash, tags, 2020 By default this command outputs: changeset id and hash, tags,
1979 non-trivial parents, user, date and time, and a summary for each 2021 non-trivial parents, user, date and time, and a summary for each
1980 commit. When the -v/--verbose switch is used, the list of changed 2022 commit. When the -v/--verbose switch is used, the list of changed
1981 files and full commit message is shown. 2023 files and full commit message is shown.
3085 _('hg locate [OPTION]... [PATTERN]...')), 3127 _('hg locate [OPTION]... [PATTERN]...')),
3086 "^log|history": 3128 "^log|history":
3087 (log, 3129 (log,
3088 [('b', 'branches', None, _('show branches')), 3130 [('b', 'branches', None, _('show branches')),
3089 ('f', 'follow', None, 3131 ('f', 'follow', None,
3090 _('follow file history across copies and renames')), 3132 _('follow changeset history, or file history across copies and renames')),
3091 ('k', 'keyword', [], _('search for a keyword')), 3133 ('k', 'keyword', [], _('search for a keyword')),
3092 ('l', 'limit', '', _('limit number of changes displayed')), 3134 ('l', 'limit', '', _('limit number of changes displayed')),
3093 ('r', 'rev', [], _('show the specified revision or range')), 3135 ('r', 'rev', [], _('show the specified revision or range')),
3094 ('M', 'no-merges', None, _('do not show merges')), 3136 ('M', 'no-merges', None, _('do not show merges')),
3095 ('', 'style', '', _('display using template map file')), 3137 ('', 'style', '', _('display using template map file')),