Mercurial > public > mercurial-scm > hg-stable
diff mercurial/cmdutil.py @ 9667:8743f2e1bc54
merge changes from mpm
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Fri, 30 Oct 2009 09:53:39 +0100 |
parents | 71e081b88f3e 1de5ebfa5585 |
children | 2c24471d478c |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Wed Oct 28 22:47:46 2009 -0500 +++ b/mercurial/cmdutil.py Fri Oct 30 09:53:39 2009 +0100 @@ -1022,24 +1022,26 @@ def finddate(ui, repo, date): """Find the tipmost changeset that matches the given date spec""" + df = util.matchdate(date) m = matchall(repo) results = {} - for st, ctx, fns in walkchangerevs(ui, repo, m, {'rev': None}): + + def prep(ctx, fns): + d = ctx.date() + if df(d[0]): + results[rev] = d + + for ctx in walkchangerevs(repo, m, {'rev': None}, prep): rev = ctx.rev() - if st == 'add': - d = ctx.date() - if df(d[0]): - results[rev] = d - elif st == 'iter': - if rev in results: - ui.status(_("Found revision %s from %s\n") % - (rev, util.datestr(results[rev]))) - return str(rev) + if rev in results: + ui.status(_("Found revision %s from %s\n") % + (rev, util.datestr(results[rev]))) + return str(rev) raise util.Abort(_("revision matching date not found")) -def walkchangerevs(ui, repo, match, opts): +def walkchangerevs(repo, match, opts, prepare): '''Iterate over files and the revs in which they changed. Callers most commonly need to iterate backwards over the history @@ -1050,15 +1052,9 @@ window, we first walk forwards to gather data, then in the desired order (usually backwards) to display it. - 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 - possible display - - "iter", rev, None: in-order traversal of the revs earlier iterated - over with "add" - use to display data''' + This function returns an iterator yielding contexts. Before + yielding each context, the iterator will first call the prepare + function on each context in the window in forward order.''' def increasing_windows(start, end, windowsize=8, sizelimit=512): if start < end: @@ -1093,6 +1089,7 @@ # No files, no patterns. Display all revs. wanted = set(revs) copies = [] + if not slowpath: # Only files, no patterns. Check the history of each file. def filerevgen(filelog, node): @@ -1129,8 +1126,6 @@ slowpath = True break else: - ui.warn(_('%s:%s copy source revision cannot be found!\n') - % (file_, short(node))) continue for rev, copied in filerevgen(filelog, node): if rev <= maxrev: @@ -1215,6 +1210,7 @@ return rev in wanted for i, window in increasing_windows(0, len(revs)): + change = util.cachefunc(repo.changectx) nrevs = [rev for rev in revs[i:i+window] if want(rev)] for rev in sorted(nrevs): fns = fncache.get(rev) @@ -1225,9 +1221,9 @@ if match(f): yield f fns = fns_generator() - yield 'add', ctx, fns + prepare(ctx, fns) for rev in nrevs: - yield 'iter', change(rev), None + yield change(rev) return iterate() def commit(ui, repo, commitfunc, pats, opts):