Mercurial > hg-stable
changeset 9656:2ae3758526d8
Merge with crew
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 27 Oct 2009 17:14:19 -0500 |
parents | 6d7d3f849062 (diff) bd3af545c7c6 (current diff) |
children | 96c803e9018f |
files | mercurial/cmdutil.py mercurial/commands.py |
diffstat | 3 files changed, 40 insertions(+), 47 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/churn.py Tue Oct 27 21:59:44 2009 +0900 +++ b/hgext/churn.py Tue Oct 27 17:14:19 2009 -0500 @@ -53,14 +53,12 @@ if opts.get('date'): df = util.matchdate(opts['date']) - get = util.cachefunc(lambda r: repo[r]) - changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) - for st, rev, fns in changeiter: - + m = cmdutil.match(repo, pats, opts) + for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, m, opts): if not st == 'add': continue - ctx = get(rev) + rev = ctx.rev() if df and not df(ctx.date()[0]): # doesn't match date format continue
--- a/mercurial/cmdutil.py Tue Oct 27 21:59:44 2009 +0900 +++ b/mercurial/cmdutil.py Tue Oct 27 17:14:19 2009 -0500 @@ -1024,9 +1024,9 @@ """Find the tipmost changeset that matches the given date spec""" df = util.matchdate(date) get = util.cachefunc(lambda r: repo[r]) - changeiter, matchfn = walkchangerevs(ui, repo, [], get, {'rev':None}) + m = matchall(repo) results = {} - for st, rev, fns in changeiter: + for st, rev, fns in walkchangerevs(ui, repo, m, get, {'rev':None}): if st == 'add': d = get(rev).date() if df(d[0]): @@ -1039,7 +1039,7 @@ raise util.Abort(_("revision matching date not found")) -def walkchangerevs(ui, repo, pats, change, opts): +def walkchangerevs(ui, repo, match, opts): '''Iterate over files and the revs in which they changed. Callers most commonly need to iterate backwards over the history @@ -1050,12 +1050,8 @@ window, we first walk forwards to gather data, then in the desired order (usually backwards) to display it. - This function returns an (iterator, matchfn) tuple. The iterator - yields 3-tuples. They will be of one of the following forms: - - "window", incrementing, lastrev: stepping through a window, - positive if walking forwards through revs, last rev in the - sequence iterated over - use to reset state for the current window + This function returns an iterator. The iterator yields 3-tuples. + They will be of one of the following forms: "add", rev, fns: out-of-order traversal of the given filenames fns, which changed during revision rev - use to gather data for @@ -1078,11 +1074,10 @@ if windowsize < sizelimit: windowsize *= 2 - m = match(repo, pats, opts) follow = opts.get('follow') or opts.get('follow_first') if not len(repo): - return [], m + return [] if follow: defrange = '%s:0' % repo['.'].rev() @@ -1090,10 +1085,11 @@ defrange = '-1:0' revs = revrange(repo, opts['rev'] or [defrange]) wanted = set() - slowpath = m.anypats() or (m.files() and opts.get('removed')) + slowpath = match.anypats() or (match.files() and opts.get('removed')) fncache = {} + change = util.cachefunc(repo.changectx) - if not slowpath and not m.files(): + if not slowpath and not match.files(): # No files, no patterns. Display all revs. wanted = set(revs) copies = [] @@ -1117,7 +1113,7 @@ if rev[0] < cl_count: yield rev def iterfiles(): - for filename in m.files(): + for filename in match.files(): yield filename, None for filename_node in copies: yield filename_node @@ -1157,7 +1153,7 @@ yield change(j) for ctx in changerevgen(): - matches = filter(m, ctx.files()) + matches = filter(match, ctx.files()) if matches: fncache[ctx.rev()] = matches wanted.add(ctx.rev()) @@ -1210,7 +1206,7 @@ wanted.discard(x) def iterate(): - if follow and not m.files(): + if follow and not match.files(): ff = followfilter(onlyfirst=opts.get('follow_first')) def want(rev): return ff.match(rev) and rev in wanted @@ -1219,20 +1215,20 @@ return rev in wanted for i, window in increasing_windows(0, len(revs)): - yield 'window', revs[0] < revs[-1], revs[-1] nrevs = [rev for rev in revs[i:i+window] if want(rev)] for rev in sorted(nrevs): fns = fncache.get(rev) + ctx = change(rev) if not fns: def fns_generator(): - for f in change(rev).files(): - if m(f): + for f in ctx.files(): + if match(f): yield f fns = fns_generator() - yield 'add', rev, fns + yield 'add', ctx, fns for rev in nrevs: - yield 'iter', rev, None - return iterate(), m + yield 'iter', change(rev), None + return iterate() def commit(ui, repo, commitfunc, pats, opts): '''commit the specified files or all outstanding changes'''
--- a/mercurial/commands.py Tue Oct 27 21:59:44 2009 +0900 +++ b/mercurial/commands.py Tue Oct 27 17:14:19 2009 -0500 @@ -1267,7 +1267,8 @@ for i in xrange(blo, bhi): yield ('+', b[i]) - def display(fn, r, pstates, states): + def display(fn, ctx, pstates, states): + rev = ctx.rev() datefunc = ui.quiet and util.shortdate or util.datestr found = False filerevmatches = {} @@ -1276,17 +1277,17 @@ else: iter = [('', l) for l in states] for change, l in iter: - cols = [fn, str(r)] + cols = [fn, str(rev)] if opts.get('line_number'): cols.append(str(l.linenum)) if opts.get('all'): cols.append(change) if opts.get('user'): - cols.append(ui.shortuser(get(r).user())) + cols.append(ui.shortuser(ctx.user())) if opts.get('date'): - cols.append(datefunc(get(r).date())) + cols.append(datefunc(ctx.date())) if opts.get('files_with_matches'): - c = (fn, r) + c = (fn, rev) if c in filerevmatches: continue filerevmatches[c] = 1 @@ -1298,16 +1299,12 @@ skip = {} revfiles = {} - get = util.cachefunc(lambda r: repo[r]) - changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) + matchfn = cmdutil.match(repo, pats, opts) found = False follow = opts.get('follow') - for st, rev, fns in changeiter: - if st == 'window': - matches.clear() - revfiles.clear() - elif st == 'add': - ctx = get(rev) + for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, matchfn, opts): + if st == 'add': + rev = ctx.rev() pctx = ctx.parents()[0] parent = pctx.rev() matches.setdefault(rev, {}) @@ -1341,7 +1338,8 @@ except error.LookupError: pass elif st == 'iter': - parent = get(rev).parents()[0].rev() + rev = ctx.rev() + parent = ctx.parents()[0].rev() for fn in sorted(revfiles.get(rev, [])): states = matches[rev][fn] copy = copies.get(rev, {}).get(fn) @@ -1351,12 +1349,14 @@ continue pstates = matches.get(parent, {}).get(copy or fn, []) if pstates or states: - r = display(fn, rev, pstates, states) + r = display(fn, ctx, pstates, states) found = found or r if r and not opts.get('all'): skip[fn] = True if copy: skip[copy] = True + del matches[rev] + del revfiles[rev] def heads(ui, repo, *branchrevs, **opts): """show current repository heads or show branch heads @@ -1990,9 +1990,7 @@ will appear in files:. """ - get = util.cachefunc(lambda r: repo[r]) - changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) - + matchfn = cmdutil.match(repo, pats, opts) limit = cmdutil.loglimit(opts) count = 0 @@ -2039,7 +2037,8 @@ only_branches = opts.get('only_branch') displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn) - for st, rev, fns in changeiter: + for st, ctx, fns in cmdutil.walkchangerevs(ui, repo, matchfn, opts): + rev = ctx.rev() if st == 'add': parents = [p for p in repo.changelog.parentrevs(rev) if p != nullrev] @@ -2048,7 +2047,6 @@ if opts.get('only_merges') and len(parents) != 2: continue - ctx = get(rev) if only_branches and ctx.branch() not in only_branches: continue @@ -2081,6 +2079,7 @@ elif st == 'iter': if count == limit: break + if displayer.flush(rev): count += 1