Changeset View
Changeset View
Standalone View
Standalone View
mercurial/cmdutil.py
Show First 20 Lines • Show All 1875 Lines • ▼ Show 20 Line(s) | def walkchangerevs(repo, match, opts, prepare): | ||||
We walk a window of revisions in the desired order. Within the | We walk a window of revisions in the desired order. Within the | ||||
window, we first walk forwards to gather data, then in the desired | window, we first walk forwards to gather data, then in the desired | ||||
order (usually backwards) to display it. | order (usually backwards) to display it. | ||||
This function returns an iterator yielding contexts. Before | This function returns an iterator yielding contexts. Before | ||||
yielding each context, the iterator will first call the prepare | yielding each context, the iterator will first call the prepare | ||||
function on each context in the window in forward order.''' | function on each context in the window in forward order.''' | ||||
allfiles = opts.get('allfiles') | |||||
follow = opts.get('follow') or opts.get('follow_first') | follow = opts.get('follow') or opts.get('follow_first') | ||||
revs = _walkrevs(repo, opts) | revs = _walkrevs(repo, opts) | ||||
if not revs: | if not revs: | ||||
return [] | return [] | ||||
if allfiles and len(revs) > 1: | |||||
raise error.Abort(_("multiple revisions not supported with --allfiles")) | |||||
wanted = set() | wanted = set() | ||||
slowpath = match.anypats() or (not match.always() and opts.get('removed')) | slowpath = match.anypats() or (not match.always() and opts.get('removed')) | ||||
fncache = {} | fncache = {} | ||||
change = repo.__getitem__ | change = repo.__getitem__ | ||||
# First step is to fill wanted, the set of revisions that we want to yield. | # First step is to fill wanted, the set of revisions that we want to yield. | ||||
# When it does not induce extra cost, we also fill fncache for revisions in | # When it does not induce extra cost, we also fill fncache for revisions in | ||||
# wanted: a cache of filenames that were changed (ctx.files()) and that | # wanted: a cache of filenames that were changed (ctx.files()) and that | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | def iterate(): | ||||
break | break | ||||
elif want(rev): | elif want(rev): | ||||
nrevs.append(rev) | nrevs.append(rev) | ||||
for rev in sorted(nrevs): | for rev in sorted(nrevs): | ||||
fns = fncache.get(rev) | fns = fncache.get(rev) | ||||
ctx = change(rev) | ctx = change(rev) | ||||
if not fns: | if not fns: | ||||
def fns_generator(): | def fns_generator(): | ||||
for f in ctx.files(): | if allfiles: | ||||
fiter = iter(ctx) | |||||
else: | |||||
fiter = ctx.files() | |||||
for f in fiter: | |||||
if match(f): | if match(f): | ||||
yield f | yield f | ||||
fns = fns_generator() | fns = fns_generator() | ||||
prepare(ctx, fns) | prepare(ctx, fns) | ||||
for rev in nrevs: | for rev in nrevs: | ||||
yield change(rev) | yield change(rev) | ||||
if stopiteration: | if stopiteration: | ||||
▲ Show 20 Lines • Show All 1261 Lines • Show Last 20 Lines |