Patchwork D5776: grep: move writing of path outside of column loop

login
register
mail settings
Submitter phabricator
Date Feb. 2, 2019, 2:11 a.m.
Message ID <266b6c96947150aa087ea719875a261a@localhost.localdomain>
Download mbox | patch
Permalink /patch/38316/
State Not Applicable
Headers show

Comments

phabricator - Feb. 2, 2019, 2:11 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG426ad3866f9d: grep: move writing of path outside of column loop (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5776?vs=13663&id=13693

REVISION DETAIL
  https://phab.mercurial-scm.org/D5776

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2867,18 +2867,18 @@ 
             except error.WdirUnsupported:
                 return ctx[fn].isbinary()
 
-        fieldnamemap = {'filename': 'path', 'linenumber': 'lineno'}
+        fieldnamemap = {'linenumber': 'lineno'}
         if diff:
             iter = difflinestates(pstates, states)
         else:
             iter = [('', l) for l in states]
         for change, l in iter:
             fm.startitem()
             fm.context(ctx=ctx)
             fm.data(node=fm.hexfunc(scmutil.binnode(ctx)))
+            fm.write('path', '%s', fn, label='grep.filename')
 
             cols = [
-                ('filename', '%s', fn, True),
                 ('rev', '%d', rev, not plaingrep),
                 ('linenumber', '%d', l.linenum, opts.get('line_number')),
             ]
@@ -2889,13 +2889,11 @@ 
                 ('date', '%s', fm.formatdate(ctx.date(), datefmt),
                  opts.get('date')),
             ])
-            lastcol = next(
-                name for name, fmt, data, cond in reversed(cols) if cond)
             for name, fmt, data, cond in cols:
+                if cond:
+                    fm.plain(sep, label='grep.sep')
                 field = fieldnamemap.get(name, name)
                 fm.condwrite(cond, field, fmt, data, label='grep.%s' % name)
-                if cond and name != lastcol:
-                    fm.plain(sep, label='grep.sep')
             if not opts.get('files_with_matches'):
                 fm.plain(sep, label='grep.sep')
                 if not opts.get('text') and binary():