mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
grep: exit loop immediately, if matching is found in the file for "hg grep -l"
Before this patch, internal function "display()" of "hg grep" is not efficient for "-l"/"--files-with-matches", because loop is continued, even after the first matching is found in the specified file. This patch exits loop immediately, if matching is found for "--files-with-matches". In this case, "before is None" is equal to "opts.get('files_with_matches')".
This commit is contained in:
parent
e9f33efda3
commit
2add9630f2
@ -3364,10 +3364,7 @@ def grep(ui, repo, pattern, *pats, **opts):
|
||||
cols.append((ui.shortuser(ctx.user()), 'grep.user'))
|
||||
if opts.get('date'):
|
||||
cols.append((datefunc(ctx.date()), 'grep.date'))
|
||||
if opts.get('files_with_matches'):
|
||||
if found:
|
||||
continue
|
||||
else:
|
||||
if not opts.get('files_with_matches'):
|
||||
before = l.line[:l.colstart]
|
||||
match = l.line[l.colstart:l.colend]
|
||||
after = l.line[l.colend:]
|
||||
@ -3385,6 +3382,8 @@ def grep(ui, repo, pattern, *pats, **opts):
|
||||
ui.write(after)
|
||||
ui.write(eol)
|
||||
found = True
|
||||
if before is None:
|
||||
break
|
||||
return found
|
||||
|
||||
skip = {}
|
||||
|
Loading…
Reference in New Issue
Block a user