Patchwork D2943: grep: fixes errorneous output of grep in forward order

login
register
mail settings
Submitter phabricator
Date March 27, 2018, 2:55 p.m.
Message ID <a9cbd5151494d77a3c8f2505e0cd002a@localhost.localdomain>
Download mbox | patch
Permalink /patch/29908/
State Not Applicable
Headers show

Comments

phabricator - March 27, 2018, 2:55 p.m.
sangeet259 updated this revision to Diff 7342.
sangeet259 edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2943?vs=7321&id=7342

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

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

CHANGE DETAILS




To: sangeet259, #hg-reviewers, yuja
Cc: yuja, 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
@@ -330,6 +330,18 @@ 
   color:3:-:red
   color:1:+:red
 
+
+Issue3885: test that changing revision order does not alter the
+revisions printed, just their order.
+
+  $ hg grep --all red -r "all()"
+  color:1:+:red
+  color:3:-:red
+
+  $ hg grep --all red -r "reverse(all())"
+  color:3:-:red
+  color:1:+:red
+
   $ cd ..
 
   $ hg init a
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2589,8 +2589,11 @@ 
                     skip[fn] = True
                     if copy:
                         skip[copy] = True
-        del matches[rev]
         del revfiles[rev]
+        # We will keep the matches dict for the duration of the window
+        # clear the matches dict once the window is over
+        if not revfiles:
+            matches.clear()
     fm.end()
 
     return not found