Comments
Patch
@@ -368,3 +368,20 @@
binfile.bin:0:+: Binary file matches
$ cd ..
+
+Test for showing working of unmodified flag
+
+ $ hg init sng
+ $ cd sng
+ $ echo "unmod" >> um
+ $ hg ci -A -m "adds unmod to um"
+ adding um
+ $ echo "something else" >> new
+ $ hg ci -A -m "second commit"
+ adding new
+ $ hg grep -r "." "unmod"
+ [1]
+ $ hg grep -r "." "unmod" --unmodified
+ um:1:unmod
+
+ $ cd ..
@@ -2408,6 +2408,8 @@
('n', 'line-number', None, _('print matching line numbers')),
('r', 'rev', [],
_('only search files changed within revision range'), _('REV')),
+ ('', 'unmodified', False,
+ _('include all files in the changeset while grepping')),
('u', 'user', None, _('list the author (long with -v)')),
('d', 'date', None, _('list the date (short with -q)')),
] + formatteropts + walkopts,
@@ -1881,6 +1881,7 @@
yielding each context, the iterator will first call the prepare
function on each context in the window in forward order.'''
+ unmodified = opts.get('unmodified')
follow = opts.get('follow') or opts.get('follow_first')
revs = _walkrevs(repo, opts)
if not revs:
@@ -1990,7 +1991,11 @@
ctx = change(rev)
if not fns:
def fns_generator():
- for f in ctx.files():
+ if unmodified and len(revs) == 1:
+ fiter = iter(ctx)
+ else:
+ fiter = ctx.files()
+ for f in fiter:
if match(f):
yield f
fns = fns_generator()