[Updated] D8543: grep: don't go in an infinite loop when given empty regex
valentin.gatienbaron (Valentin Gatien-Baron)
phabricator at mercurial-scm.org
Mon May 18 17:11:58 UTC 2020
Closed by commit rHGf90957c947f4: grep: don't go in an infinite loop when given empty regex (authored by valentin.gatienbaron).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D8543?vs=21407&id=21421
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D8543/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D8543
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
@@ -660,7 +660,7 @@
$ echo 'added, missing' > added-missing; hg add added-missing; rm added-missing
$ echo 'untracked' > untracked
$ hg rm old
- $ hg grep '[^Z]'
+ $ hg grep ''
added:added
new:something else
new:modified
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3428,8 +3428,11 @@
m = regexp.search(self.line, p)
if not m:
break
- yield m.span()
- p = m.end()
+ if m.end() == p:
+ p += 1
+ else:
+ yield m.span()
+ p = m.end()
matches = {}
copies = {}
To: valentin.gatienbaron, #hg-reviewers
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200518/fcd9b03d/attachment-0002.html>
More information about the Mercurial-patches
mailing list