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

sangeet259 (Sangeet Kumar Mishra) phabricator at mercurial-scm.org
Mon Mar 26 14:22:09 UTC 2018


sangeet259 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  If grep is passed a revset in forwards order via -r , say -r 0:tip
  Then the output is errorneous. This patch fixes that. The ouput was wrong because
  we deleted the last revision key in the matches and when we moved to the next
  revision we didn't had this to comapare the diff. So the pstates dict was always
  empty and in the SequenceMatcher, to convert and empty pstate to the states
  dictionary you would always insert. This patch keeps the matches dictionary until
  the end of this window and clears it at once when this window ends. This solves the
  above mentioned problem and also do not cause any memory leak.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2610,8 +2610,9 @@
                         skip[fn] = True
                         if copy:
                             skip[copy] = True
-            del matches[rev]
             del revfiles[rev]
+            if not revfiles:
+                matches.clear()
     fm.end()
 
     return not found



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


More information about the Mercurial-devel mailing list