Patchwork D3920: grep: hide cryptic revision number by default

login
register
mail settings
Submitter phabricator
Date July 11, 2018, 6:12 p.m.
Message ID <f7b9cb353f80cf34465810cda23232a8@localhost.localdomain>
Download mbox | patch
Permalink /patch/32796/
State Not Applicable
Headers show

Comments

phabricator - July 11, 2018, 6:12 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGaabc01da9834: grep: hide cryptic revision number by default (authored by yuja, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3920?vs=9537&id=9550

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-grep.t

CHANGE DETAILS




To: yuja, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/tests/test-grep.t b/tests/test-grep.t
--- a/tests/test-grep.t
+++ b/tests/test-grep.t
@@ -416,8 +416,8 @@ 
 
   $ echo modified >> new
   $ hg grep --all-files mod
-  new:2147483647:modified
-  um:2147483647:unmod
+  new:modified
+  um:unmod
 
  which can be overridden by -rREV
 
@@ -427,8 +427,8 @@ 
 commands.all-files can be negated by --no-all-files
 
   $ hg grep --config commands.grep.all-files=True mod
-  new:2147483647:modified
-  um:2147483647:unmod
+  new:modified
+  um:unmod
   $ hg grep --config commands.grep.all-files=True --no-all-files mod
   um:0:unmod
 
@@ -469,5 +469,25 @@ 
   $ hg add file1
   $ hg commit -m "adds file1"
   $ hg mv file1 file2
+
+wdir revision is hidden by default:
+
   $ hg grep "some"
-  file2:2147483647:some text
+  file2:some text
+
+but it should be available in template dict:
+
+  $ hg grep "some" -Tjson
+  [
+   {
+    "date": [0, 0],
+    "file": "file2",
+    "line_number": 1,
+    "node": "ffffffffffffffffffffffffffffffffffffffff",
+    "rev": 2147483647,
+    "texts": [{"matched": true, "text": "some"}, {"matched": false, "text": " text"}],
+    "user": "test"
+   }
+  ]
+
+  $ cd ..
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2538,7 +2538,8 @@ 
     if opts.get('all_files') is None and not opts.get('rev') and not diff:
         # experimental config: commands.grep.all-files
         opts['all_files'] = ui.configbool('commands', 'grep.all-files')
-    if opts.get('all_files') and not opts.get('rev'):
+    plaingrep = opts.get('all_files') and not opts.get('rev')
+    if plaingrep:
         opts['rev'] = ['wdir()']
 
     reflags = re.M
@@ -2648,7 +2649,7 @@ 
 
             cols = [
                 ('filename', fn, True),
-                ('rev', rev, True),
+                ('rev', rev, not plaingrep),
                 ('linenumber', l.linenum, opts.get('line_number')),
             ]
             if diff: