diff --git a/hgext/churn.py b/hgext/churn.py --- a/hgext/churn.py +++ b/hgext/churn.py @@ -53,15 +53,17 @@ def countrate(ui, repo, amap, *pats, **o if opts.get('date'): df = util.matchdate(opts['date']) - get = util.cachefunc(lambda r: repo[r].changeset()) + get = util.cachefunc(lambda r: repo[r]) changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) for st, rev, fns in changeiter: + if not st == 'add': continue - if df and not df(get(rev)[2][0]): # doesn't match date format + + ctx = get(rev) + if df and not df(ctx.date()[0]): # doesn't match date format continue - ctx = repo[rev] key = getkey(ctx) key = amap.get(key, key) # alias remap if opts.get('changesets'): diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -987,12 +987,12 @@ def show_changeset(ui, repo, opts, buffe def finddate(ui, repo, date): """Find the tipmost changeset that matches the given date spec""" df = util.matchdate(date) - get = util.cachefunc(lambda r: repo[r].changeset()) + get = util.cachefunc(lambda r: repo[r]) changeiter, matchfn = walkchangerevs(ui, repo, [], get, {'rev':None}) results = {} for st, rev, fns in changeiter: if st == 'add': - d = get(rev)[2] + d = get(rev).date() if df(d[0]): results[rev] = d elif st == 'iter': @@ -1118,13 +1118,13 @@ def walkchangerevs(ui, repo, pats, chang def changerevgen(): for i, window in increasing_windows(len(repo) - 1, nullrev): for j in xrange(i - window, i + 1): - yield j, change(j)[3] + yield change(j) - for rev, changefiles in changerevgen(): - matches = filter(m, changefiles) + for ctx in changerevgen(): + matches = filter(m, ctx.files()) if matches: - fncache[rev] = matches - wanted.add(rev) + fncache[ctx.rev()] = matches + wanted.add(ctx.rev()) class followfilter(object): def __init__(self, onlyfirst=False): @@ -1189,7 +1189,7 @@ def walkchangerevs(ui, repo, pats, chang fns = fncache.get(rev) if not fns: def fns_generator(): - for f in change(rev)[3]: + for f in change(rev).files(): if m(f): yield f fns = fns_generator() diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1275,9 +1275,9 @@ def grep(ui, repo, pattern, *pats, **opt if opts.get('all'): cols.append(change) if opts.get('user'): - cols.append(ui.shortuser(get(r)[1])) + cols.append(ui.shortuser(get(r).user())) if opts.get('date'): - cols.append(datefunc(get(r)[2])) + cols.append(datefunc(get(r).date())) if opts.get('files_with_matches'): c = (fn, r) if c in filerevmatches: @@ -1291,7 +1291,7 @@ def grep(ui, repo, pattern, *pats, **opt skip = {} revfiles = {} - get = util.cachefunc(lambda r: repo[r].changeset()) + get = util.cachefunc(lambda r: repo[r]) changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) found = False follow = opts.get('follow') @@ -1300,7 +1300,7 @@ def grep(ui, repo, pattern, *pats, **opt matches.clear() revfiles.clear() elif st == 'add': - ctx = repo[rev] + ctx = get(rev) pctx = ctx.parents()[0] parent = pctx.rev() matches.setdefault(rev, {}) @@ -1334,7 +1334,7 @@ def grep(ui, repo, pattern, *pats, **opt except error.LookupError: pass elif st == 'iter': - parent = repo[rev].parents()[0].rev() + parent = get(rev).parents()[0].rev() for fn in sorted(revfiles.get(rev, [])): states = matches[rev][fn] copy = copies.get(rev, {}).get(fn) @@ -1982,7 +1982,7 @@ def log(ui, repo, *pats, **opts): will appear in files:. """ - get = util.cachefunc(lambda r: repo[r].changeset()) + get = util.cachefunc(lambda r: repo[r]) changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) limit = cmdutil.loglimit(opts) @@ -2040,40 +2040,37 @@ def log(ui, repo, *pats, **opts): if opts.get('only_merges') and len(parents) != 2: continue - if only_branches: - revbranch = get(rev)[5]['branch'] - if revbranch not in only_branches: - continue - - if df: - changes = get(rev) - if not df(changes[2][0]): - continue + ctx = get(rev) + if only_branches and ctx.branch() not in only_branches: + continue + + if df and not df(ctx.date()): + continue if opts.get('keyword'): - changes = get(rev) miss = 0 for k in [kw.lower() for kw in opts['keyword']]: - if not (k in changes[1].lower() or - k in changes[4].lower() or - k in " ".join(changes[3]).lower()): + if not (k in ctx.user().lower() or + k in ctx.description().lower() or + k in " ".join(ctx.files()[3]).lower()): miss = 1 break if miss: continue if opts['user']: - changes = get(rev) - if not [k for k in opts['user'] if k in changes[1]]: + if not [k for k in opts['user'] if k in ctx.user()]: continue copies = [] if opts.get('copies') and rev: - for fn in get(rev)[3]: + for fn in ctx.files(): rename = getrenamed(fn, rev) if rename: copies.append((fn, rename[0])) - displayer.show(context.changectx(repo, rev), copies=copies) + + displayer.show(ctx, copies=copies) + elif st == 'iter': if count == limit: break if displayer.flush(rev): diff --git a/tests/test-grep b/tests/test-grep --- a/tests/test-grep +++ b/tests/test-grep @@ -22,14 +22,14 @@ hg grep '**test**' echo % simple hg grep port port echo % all -hg grep --all -nu port port +hg grep --traceback --all -nu port port echo % other hg grep import port hg cp port port2 hg commit -m 4 -u spam -d '5 0' -echo '% follow' -hg grep -f 'import$' port2 +echo % follow +hg grep --traceback -f 'import$' port2 echo deport >> port2 hg commit -m 5 -u eggs -d '6 0' hg grep -f --all -nu port port2