D2943: grep: fixes errorneous output of grep in forward order
pulkit closed this revision. pulkit added a comment. This was committed as https://www.mercurial-scm.org/repo/hg/rev/a2a6755a3def. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2943 To: pulkit, #hg-reviewers, yuja, sangeet259 Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2943: grep: fixes errorneous output of grep in forward order
yuja accepted this revision. yuja added a comment. This revision is now accepted and ready to land. Queued, thanks. Adjusted the commit message to close " (issue3885)". REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2943 To: sangeet259, #hg-reviewers, yuja Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2943: grep: fixes errorneous output of grep in forward order
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=7342 REVISION DETAIL https://phab.mercurial-scm.org/D2943 AFFECTED FILES mercurial/commands.py tests/test-grep.t CHANGE DETAILS 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 To: sangeet259, #hg-reviewers, yuja Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2943: grep: fixes errorneous output of grep in forward order
sangeet259 added a comment. @yuja rebase it on which revision? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2943 To: sangeet259, #hg-reviewers, yuja Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2943: grep: fixes errorneous output of grep in forward order
yuja requested changes to this revision. yuja added a comment. This revision now requires changes to proceed. > This patch keeps the matches dictionary until > the end of this window and clears it at once when this window ends. This is really helpful while reading the patch. Perhaps it's worth adding an inline comment? The change looks good, but can't be applied on the current tip. Can you rebase? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2943 To: sangeet259, #hg-reviewers, yuja Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2943: grep: fixes errorneous output of grep in forward order
sangeet259 updated this revision to Diff 7321. sangeet259 edited the summary of this revision. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2943?vs=7290=7321 REVISION DETAIL https://phab.mercurial-scm.org/D2943 AFFECTED FILES mercurial/commands.py tests/test-grep.t CHANGE DETAILS diff --git a/tests/test-grep.t b/tests/test-grep.t --- a/tests/test-grep.t +++ b/tests/test-grep.t @@ -328,6 +328,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 @@ -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 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2943: grep: fixes errorneous output of grep in forward order
sangeet259 added a comment. Currently, I am not sure what tests I should add, the tests in test-grep.t are passing. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2943 To: sangeet259, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2943: grep: fixes errorneous output of grep in forward order
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 ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel