D3976: grep: add MULTIREV support to --all-files flag
sangeet259 (Sangeet Kumar Mishra)
phabricator at mercurial-scm.org
Wed Jul 25 11:56:56 UTC 2018
sangeet259 updated this revision to Diff 9663.
sangeet259 edited the summary of this revision.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D3976?vs=9657&id=9663
REVISION DETAIL
https://phab.mercurial-scm.org/D3976
AFFECTED FILES
mercurial/cmdutil.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
@@ -491,3 +491,12 @@
]
$ cd ..
+
+test -rMULTIREV with --all-files
+
+ $ cd sng
+ $ hg rm um
+ $ hg commit -m "deletes um"
+ $ hg grep -r "0:2" "unmod" --all-files
+ um:0:unmod
+ $ cd ..
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1889,9 +1889,7 @@
revs = _walkrevs(repo, opts)
if not revs:
return []
- if allfiles and len(revs) > 1:
- raise error.Abort(_("multiple revisions not supported with "
- "--all-files"))
+
wanted = set()
slowpath = match.anypats() or (not match.always() and opts.get('removed'))
fncache = {}
@@ -1983,6 +1981,11 @@
it = iter(revs)
stopiteration = False
+
+ # the files dictionary stores all the files that have been looked at
+ # in the allfiles mode
+ files ={}
+
for windowsize in increasingwindows():
nrevs = []
for i in xrange(windowsize):
@@ -1998,12 +2001,15 @@
if not fns:
def fns_generator():
if allfiles:
- fiter = iter(ctx)
+ for f in ctx:
+ if match(f):
+ if f not in files:
+ files[f] = ctx
+ yield f
else:
- fiter = ctx.files()
- for f in fiter:
- if match(f):
- yield f
+ for f in ctx.files():
+ if match(f):
+ yield f
fns = fns_generator()
prepare(ctx, fns)
for rev in nrevs:
To: sangeet259, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list