##// END OF EJS Templates
Pull getchange out of walkchangerevs
Matt Mackall -
r3527:45620faa default
parent child Browse files
Show More
@@ -50,7 +50,7 b' def logmessage(opts):'
50 50 (logfile, inst.strerror))
51 51 return message
52 52
53 def walkchangerevs(ui, repo, pats, opts):
53 def walkchangerevs(ui, repo, pats, change, opts):
54 54 '''Iterate over files and the revs they changed in.
55 55
56 56 Callers most commonly need to iterate backwards over the history
@@ -61,10 +61,8 b' def walkchangerevs(ui, repo, pats, opts)'
61 61 window, we first walk forwards to gather data, then in the desired
62 62 order (usually backwards) to display it.
63 63
64 This function returns an (iterator, getchange, matchfn) tuple. The
65 getchange function returns the changelog entry for a numeric
66 revision. The iterator yields 3-tuples. They will be of one of
67 the following forms:
64 This function returns an (iterator, matchfn) tuple. The iterator
65 yields 3-tuples. They will be of one of the following forms:
68 66
69 67 "window", incrementing, lastrev: stepping through a window,
70 68 positive if walking forwards through revs, last rev in the
@@ -91,12 +89,11 b' def walkchangerevs(ui, repo, pats, opts)'
91 89 if windowsize < sizelimit:
92 90 windowsize *= 2
93 91
94
95 92 files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts)
96 93 follow = opts.get('follow') or opts.get('follow_first')
97 94
98 95 if repo.changelog.count() == 0:
99 return [], False, matchfn
96 return [], matchfn
100 97
101 98 if follow:
102 99 defrange = '%s:0' % repo.changectx().rev()
@@ -107,13 +104,6 b' def walkchangerevs(ui, repo, pats, opts)'
107 104 slowpath = anypats
108 105 fncache = {}
109 106
110 chcache = {}
111 def getchange(rev):
112 ch = chcache.get(rev)
113 if ch is None:
114 chcache[rev] = ch = repo.changelog.read(repo.lookup(str(rev)))
115 return ch
116
117 107 if not slowpath and not files:
118 108 # No files, no patterns. Display all revs.
119 109 wanted = dict(zip(revs, revs))
@@ -169,7 +159,7 b' def walkchangerevs(ui, repo, pats, opts)'
169 159 def changerevgen():
170 160 for i, window in increasing_windows(repo.changelog.count()-1, -1):
171 161 for j in xrange(i - window, i + 1):
172 yield j, getchange(j)[3]
162 yield j, change(j)[3]
173 163
174 164 for rev, changefiles in changerevgen():
175 165 matches = filter(matchfn, changefiles)
@@ -240,11 +230,11 b' def walkchangerevs(ui, repo, pats, opts)'
240 230 srevs = list(nrevs)
241 231 srevs.sort()
242 232 for rev in srevs:
243 fns = fncache.get(rev) or filter(matchfn, getchange(rev)[3])
233 fns = fncache.get(rev) or filter(matchfn, change(rev)[3])
244 234 yield 'add', rev, fns
245 235 for rev in nrevs:
246 236 yield 'iter', rev, None
247 return iterate(), getchange, matchfn
237 return iterate(), matchfn
248 238
249 239 def write_bundle(cg, filename=None, compress=True):
250 240 """Write a bundle file and return its filename.
@@ -1491,7 +1481,8 b' def grep(ui, repo, pattern, *pats, **opt'
1491 1481
1492 1482 fstate = {}
1493 1483 skip = {}
1494 changeiter, getchange, matchfn = walkchangerevs(ui, repo, pats, opts)
1484 getchange = util.cachefunc(lambda r:repo.changectx(r).changeset())
1485 changeiter, matchfn = walkchangerevs(ui, repo, pats, getchange, opts)
1495 1486 count = 0
1496 1487 incrementing = False
1497 1488 follow = opts.get('follow')
@@ -1824,7 +1815,8 b' def log(ui, repo, *pats, **opts):'
1824 1815 def __getattr__(self, key):
1825 1816 return getattr(self.ui, key)
1826 1817
1827 changeiter, getchange, matchfn = walkchangerevs(ui, repo, pats, opts)
1818 getchange = util.cachefunc(lambda r:repo.changectx(r).changeset())
1819 changeiter, matchfn = walkchangerevs(ui, repo, pats, getchange, opts)
1828 1820
1829 1821 if opts['branches']:
1830 1822 ui.warn(_("the --branches option is deprecated, "
General Comments 0
You need to be logged in to leave comments. Login now