[PATCH 4 of 6] logcmdutil: create hunksfilter and filematcher even if no diff option given
Yuya Nishihara
yuya at tcha.org
Wed Feb 7 08:25:05 EST 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1516516477 -32400
# Sun Jan 21 15:34:37 2018 +0900
# Node ID 03f30f86c95a3847be7bb7b89a8cc22d9abee524
# Parent 44e6702bf9cdef9d9df717b8632c1ba5a213b797
logcmdutil: create hunksfilter and filematcher even if no diff option given
It's okay since 5fe6f946f111, "log: allow matchfn to be non-null even if both
--patch/--stat are off."
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3431,7 +3431,7 @@ def log(ui, repo, *pats, **opts):
revs, lrfilematcher, hunksfilter = logcmdutil.getlinerangerevs(
repo, revs, opts)
- if filematcher is not None and lrfilematcher is not None:
+ if filematcher is not None:
basefilematcher = filematcher
def filematcher(rev):
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -779,11 +779,9 @@ def getlinerangerevs(repo, userrevs, opt
"filematcher(ctx) -> match" is a factory function returning a match object
for a given revision for file patterns specified in --line-range option.
- If neither --stat nor --patch options are passed, "filematcher" is None.
"hunksfilter(ctx) -> filterfn(fctx, hunks)" is a factory function
returning a hunks filtering function.
- If neither --stat nor --patch options are passed, "filterhunks" is None.
"""
wctx = repo[None]
@@ -802,37 +800,33 @@ def getlinerangerevs(repo, userrevs, opt
rev, {}).setdefault(
fctx.path(), []).append(linerange)
- filematcher = None
- hunksfilter = None
- if opts.get('patch') or opts.get('stat'):
+ def nofilterhunksfn(fctx, hunks):
+ return hunks
- def nofilterhunksfn(fctx, hunks):
- return hunks
-
- def hunksfilter(ctx):
- fctxlineranges = linerangesbyrev.get(ctx.rev())
- if fctxlineranges is None:
- return nofilterhunksfn
+ def hunksfilter(ctx):
+ fctxlineranges = linerangesbyrev.get(ctx.rev())
+ if fctxlineranges is None:
+ return nofilterhunksfn
- def filterfn(fctx, hunks):
- lineranges = fctxlineranges.get(fctx.path())
- if lineranges is not None:
- for hr, lines in hunks:
- if hr is None: # binary
- yield hr, lines
- continue
- if any(mdiff.hunkinrange(hr[2:], lr)
- for lr in lineranges):
- yield hr, lines
- else:
- for hunk in hunks:
- yield hunk
+ def filterfn(fctx, hunks):
+ lineranges = fctxlineranges.get(fctx.path())
+ if lineranges is not None:
+ for hr, lines in hunks:
+ if hr is None: # binary
+ yield hr, lines
+ continue
+ if any(mdiff.hunkinrange(hr[2:], lr)
+ for lr in lineranges):
+ yield hr, lines
+ else:
+ for hunk in hunks:
+ yield hunk
- return filterfn
+ return filterfn
- def filematcher(ctx):
- files = list(linerangesbyrev.get(ctx.rev(), []))
- return scmutil.matchfiles(repo, files)
+ def filematcher(ctx):
+ files = list(linerangesbyrev.get(ctx.rev(), []))
+ return scmutil.matchfiles(repo, files)
revs = sorted(linerangesbyrev, reverse=True)
More information about the Mercurial-devel
mailing list