From patchwork Mon Mar 26 14:22:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D2943: grep: fixes errorneous output of grep in forward order From: phabricator X-Patchwork-Id: 29863 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Mon, 26 Mar 2018 14:22:09 +0000 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 To: sangeet259, #hg-reviewers Cc: mercurial-devel 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