[PATCH 2 of 2] largefiles: fix some badly named function parameters

Greg Ward greg at gerg.ca
Tue Oct 18 18:48:57 CDT 2011


# HG changeset patch
# User Greg Ward <greg at gerg.ca>
# Date 1318775085 14400
# Branch stable
# Node ID dd8cf8f16b1066557576128b2d9c492c77a48b5e
# Parent  16b1a228f85d9759f9a06384b269e4b47f6e9945
largefiles: fix some badly named function parameters

overrides.py contains several functions that temporarily override
scmutil.match(), which always takes a changectx object as the first
parameter. But these overrides name that parameter either 'repo' or
'ctxorrepo', which is misleading. So rename them to 'ctx' and remove
the special type-sensitive handling of the one called 'ctxorrepo'.

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -24,9 +24,9 @@
     '''overrides scmutil.match so that the matcher it returns will ignore all
     largefiles'''
     oldmatch = None # for the closure
-    def override_match(repo, pats=[], opts={}, globbed=False,
+    def override_match(ctx, pats=[], opts={}, globbed=False,
             default='relpath'):
-        match = oldmatch(repo, pats, opts, globbed, default)
+        match = oldmatch(ctx, pats, opts, globbed, default)
         m = copy.copy(match)
         notlfile = lambda f: not (lfutil.isstandin(f) or lfutil.standin(f) in
                 manifest)
@@ -341,7 +341,7 @@
 
             manifest = repo[None].manifest()
             oldmatch = None # for the closure
-            def override_match(repo, pats=[], opts={}, globbed=False,
+            def override_match(ctx, pats=[], opts={}, globbed=False,
                     default='relpath'):
                 newpats = []
                 # The patterns were previously mangled to add the standin
@@ -351,7 +351,7 @@
                         newpats.append(pat.replace(lfutil.shortname, ''))
                     else:
                         newpats.append(pat)
-                match = oldmatch(repo, newpats, opts, globbed, default)
+                match = oldmatch(ctx, newpats, opts, globbed, default)
                 m = copy.copy(match)
                 lfile = lambda f: lfutil.standin(f) in manifest
                 m._files = [lfutil.standin(f) for f in m._files if lfile(f)]
@@ -443,16 +443,12 @@
         try:
             ctx = repo[opts.get('rev')]
             oldmatch = None # for the closure
-            def override_match(ctxorrepo, pats=[], opts={}, globbed=False,
+            def override_match(ctx, pats=[], opts={}, globbed=False,
                     default='relpath'):
-                if util.safehasattr(ctxorrepo, 'match'):
-                    ctx0 = ctxorrepo
-                else:
-                    ctx0 = ctxorrepo[None]
-                match = oldmatch(ctxorrepo, pats, opts, globbed, default)
+                match = oldmatch(ctx, pats, opts, globbed, default)
                 m = copy.copy(match)
                 def tostandin(f):
-                    if lfutil.standin(f) in ctx0 or lfutil.standin(f) in ctx:
+                    if lfutil.standin(f) in ctx or lfutil.standin(f) in ctx:
                         return lfutil.standin(f)
                     elif lfutil.standin(f) in repo[None]:
                         return None


More information about the Mercurial-devel mailing list