Mercurial > hg-stable
changeset 3950:3d3007064a17
grep: incrementing is always False during 'iter'
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Fri, 22 Dec 2006 22:16:05 +0100 |
parents | be5d099e7a62 |
children | cb66641cdee3 |
files | mercurial/commands.py tests/test-grep tests/test-grep.out |
diffstat | 3 files changed, 15 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Thu Dec 21 20:41:56 2006 +0100 +++ b/mercurial/commands.py Fri Dec 22 22:16:05 2006 +0100 @@ -1151,7 +1151,7 @@ def display(fn, rev, states, prevstates): counts = {'-': 0, '+': 0} filerevmatches = {} - if incrementing or not opts['all']: + if not opts['all']: a, b, r = prevstates, states, rev else: a, b, r = states, prevstates, prev.get(fn, -1) @@ -1179,11 +1179,9 @@ get = util.cachefunc(lambda r: repo.changectx(r).changeset()) changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) count = 0 - incrementing = False follow = opts.get('follow') for st, rev, fns in changeiter: if st == 'window': - incrementing = rev matches.clear() elif st == 'add': mf = repo.changectx(rev).manifest() @@ -1209,7 +1207,7 @@ if copy: skip[copy] = True continue - if incrementing or not opts['all'] or fstate[fn]: + if not opts['all'] or fstate[fn]: pos, neg = display(fn, rev, m, fstate[fn]) count += pos + neg if pos and not opts['all']: @@ -1221,14 +1219,13 @@ fstate[copy] = m prev[fn] = rev - if not incrementing: - fstate = fstate.items() - fstate.sort() - for fn, state in fstate: - if fn in skip: - continue - if fn not in copies.get(prev[fn], {}): - display(fn, rev, {}, state) + fstate = fstate.items() + fstate.sort() + for fn, state in fstate: + if fn in skip: + continue + if fn not in copies.get(prev[fn], {}): + display(fn, rev, {}, state) return (count == 0 and 1) or 0 def heads(ui, repo, **opts):
--- a/tests/test-grep Thu Dec 21 20:41:56 2006 +0100 +++ b/tests/test-grep Fri Dec 22 22:16:05 2006 +0100 @@ -17,8 +17,11 @@ head -n 3 port > port1 mv port1 port hg commit -m 4 -u spam -d '4 0' +echo % simple hg grep port port +echo % all hg grep --all -nu port port +echo % other hg grep import port hg cp port port2
--- a/tests/test-grep.out Thu Dec 21 20:41:56 2006 +0100 +++ b/tests/test-grep.out Fri Dec 22 22:16:05 2006 +0100 @@ -1,6 +1,8 @@ +% simple port:4:export port:4:vaportight port:4:import/export +% all port:4:4:-:spam:import/export port:3:4:+:eggs:import/export port:2:1:-:spam:import @@ -10,6 +12,7 @@ port:2:3:+:spam:import/export port:1:2:+:eggs:export port:0:1:+:spam:import +% other port:4:import/export % follow port:0:import