[PATCH 1 of 6] log: pass ctx to makefilematcher() and makehunksfilter() functions
Yuya Nishihara
yuya at tcha.org
Wed Feb 7 13:25:02 UTC 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1516509631 -32400
# Sun Jan 21 13:40:31 2018 +0900
# Node ID ca578149cc821eb207e2a844c6cf74e6b66f860c
# Parent b62c4154bb287fe0f4c15cdb0d2ef290069288df
log: pass ctx to makefilematcher() and makehunksfilter() functions
This isn't important, but seems more consisntent as changesetprinter.show()
takes a ctx, not a revision number.
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -392,7 +392,7 @@ def overridelog(orig, ui, repo, *pats, *
def overridemakefilematcher(repo, pats, opts, badfn=None):
wctx = repo[None]
match, pats = oldmatchandpats(wctx, pats, opts, badfn=badfn)
- return lambda rev: match
+ return lambda ctx: match
oldmatchandpats = installmatchandpatsfn(overridematchandpats)
oldmakefilematcher = logcmdutil._makenofollowfilematcher
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3461,11 +3461,11 @@ def log(ui, repo, *pats, **opts):
if rename:
copies.append((fn, rename[0]))
if filematcher:
- revmatchfn = filematcher(ctx.rev())
+ revmatchfn = filematcher(ctx)
else:
revmatchfn = None
if hunksfilter:
- revhunksfilter = hunksfilter(rev)
+ revhunksfilter = hunksfilter(ctx)
else:
revhunksfilter = None
displayer.show(ctx, copies=copies, matchfn=revmatchfn,
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -614,8 +614,8 @@ def _fileancestors(repo, revs, match, fo
# revision, stored in "fcache". "fcache" is populated as a side effect
# of the graph traversal.
fcache = {}
- def filematcher(rev):
- return scmutil.matchfiles(repo, fcache.get(rev, []))
+ def filematcher(ctx):
+ return scmutil.matchfiles(repo, fcache.get(ctx.rev(), []))
def revgen():
for rev, cs in dagop.filectxancestors(fctxs, followfirst=followfirst):
@@ -709,7 +709,7 @@ def _initialrevs(repo, opts):
def getrevs(repo, pats, opts):
"""Return (revs, filematcher) where revs is a smartset
- filematcher is a callable taking a revision number and returning a match
+ filematcher is a callable taking a changectx and returning a match
objects filtering the files to be detailed when displaying the revision.
"""
follow = opts.get('follow') or opts.get('follow_first')
@@ -729,7 +729,7 @@ def getrevs(repo, pats, opts):
if filematcher is None:
filematcher = _makenofollowfilematcher(repo, pats, opts)
if filematcher is None:
- def filematcher(rev):
+ def filematcher(ctx):
return match
expr = _makerevset(repo, match, pats, slowpath, opts)
@@ -771,11 +771,11 @@ def getlinerangerevs(repo, userrevs, opt
"revs" are revisions obtained by processing "line-range" log options and
walking block ancestors of each specified file/line-range.
- "filematcher(rev) -> match" is a factory function returning a match object
+ "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(rev) -> filterfn(fctx, hunks)" is a factory function
+ "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.
"""
@@ -803,8 +803,8 @@ def getlinerangerevs(repo, userrevs, opt
def nofilterhunksfn(fctx, hunks):
return hunks
- def hunksfilter(rev):
- fctxlineranges = linerangesbyrev.get(rev)
+ def hunksfilter(ctx):
+ fctxlineranges = linerangesbyrev.get(ctx.rev())
if fctxlineranges is None:
return nofilterhunksfn
@@ -824,8 +824,8 @@ def getlinerangerevs(repo, userrevs, opt
return filterfn
- def filematcher(rev):
- files = list(linerangesbyrev.get(rev, []))
+ def filematcher(ctx):
+ files = list(linerangesbyrev.get(ctx.rev(), []))
return scmutil.matchfiles(repo, files)
revs = sorted(linerangesbyrev, reverse=True)
@@ -886,7 +886,7 @@ def displaygraph(ui, repo, dag, displaye
copies.append((fn, rename[0]))
revmatchfn = None
if filematcher is not None:
- revmatchfn = filematcher(ctx.rev())
+ revmatchfn = filematcher(ctx)
edges = edgefn(type, char, state, rev, parents)
firstedge = next(edges)
width = firstedge[2]
More information about the Mercurial-devel
mailing list