changeset 36002:f8ad57d24252

log: pass ctx to makefilematcher() and makehunksfilter() functions This isn't important, but seems more consistent as changesetprinter.show() takes a ctx, not a revision number.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 21 Jan 2018 13:40:31 +0900
parents 91aac8e6604d
children fcde8946c553
files hgext/largefiles/overrides.py mercurial/commands.py mercurial/logcmdutil.py
diffstat 3 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py	Sat Jan 27 19:02:33 2018 -0500
+++ b/hgext/largefiles/overrides.py	Sun Jan 21 13:40:31 2018 +0900
@@ -392,7 +392,7 @@
     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
--- a/mercurial/commands.py	Sat Jan 27 19:02:33 2018 -0500
+++ b/mercurial/commands.py	Sun Jan 21 13:40:31 2018 +0900
@@ -3461,11 +3461,11 @@
                 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,
--- a/mercurial/logcmdutil.py	Sat Jan 27 19:02:33 2018 -0500
+++ b/mercurial/logcmdutil.py	Sun Jan 21 13:40:31 2018 +0900
@@ -627,8 +627,8 @@
     # 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):
@@ -722,7 +722,7 @@
 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')
@@ -742,7 +742,7 @@
     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)
@@ -784,11 +784,11 @@
     "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.
     """
@@ -816,8 +816,8 @@
         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
 
@@ -837,8 +837,8 @@
 
             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)
@@ -899,7 +899,7 @@
                     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]