# HG changeset patch # User Matt Mackall # Date 2006-10-26 19:04:58 # Node ID 7ed86c28f1ae6a88b55e9fe53e36203ab417da4c # Parent c136c28a425a8e18444ee06c03f969fab94c5e72 Fixups for hg grep - kill trimuser function - remove ucache - simplify descending logic - fix files with matches logic - correct tests diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -298,13 +298,6 @@ def write_bundle(cg, filename=None, comp if cleanup is not None: os.unlink(cleanup) -def trimuser(ui, name, rev, revcache): - """trim the name of the user who committed a change""" - user = revcache.get(rev) - if user is None: - user = revcache[rev] = ui.shortuser(name) - return user - class changeset_printer(object): '''show changeset information when templating not requested.''' @@ -1470,29 +1463,23 @@ def grep(ui, repo, pattern, *pats, **opt yield ('+', b[i]) prev = {} - ucache = {} def display(fn, rev, states, prevstates): counts = {'-': 0, '+': 0} filerevmatches = {} if incrementing or not opts['all']: - a, b = prevstates, states + a, b, r = prevstates, states, rev else: - a, b = states, prevstates + a, b, r = states, prevstates, prev.get(fn, -1) for change, l in difflinestates(a, b): - if incrementing or not opts['all']: - r = rev - else: - r = prev[fn] cols = [fn, str(r)] if opts['line_number']: cols.append(str(l.linenum)) if opts['all']: cols.append(change) if opts['user']: - cols.append(trimuser(ui, getchange(r)[1], rev, - ucache)) + cols.append(ui.shortuser(getchange(r)[1])) if opts['files_with_matches']: - c = (fn, rev) + c = (fn, r) if c in filerevmatches: continue filerevmatches[c] = 1 diff --git a/tests/test-grep.out b/tests/test-grep.out --- a/tests/test-grep.out +++ b/tests/test-grep.out @@ -9,7 +9,7 @@ port:2:1:+:spam:export port:2:2:+:spam:vaportight port:2:3:+:spam:import/export port:1:2:+:eggs:export -port:0:1:+:eggs:import +port:0:1:+:spam:import port:4:import/export % follow port:0:import @@ -22,4 +22,4 @@ port:2:1:+:spam:export port:2:2:+:spam:vaportight port:2:3:+:spam:import/export port:1:2:+:eggs:export -port:0:1:+:eggs:import +port:0:1:+:spam:import