[PATCH 12 of 12 misc largefiles] largefiles: revert override, install matchfn outside the try/except restoring it

Mads Kiilerich mads at kiilerich.com
Sun Apr 13 16:59:15 UTC 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1397407543 -7200
#      Sun Apr 13 18:45:43 2014 +0200
# Node ID 07b55fef14409ca13429e22b55422e7eebc2d79b
# Parent  e254736cd3353a7d024170e41cf207bfa9342375
largefiles: revert override, install matchfn outside the try/except restoring it

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -598,31 +598,30 @@ def overriderevert(orig, ui, repo, *pats
 
         oldstandins = lfutil.getstandinsstate(repo)
 
+        def overridematch(ctx, pats=[], opts={}, globbed=False,
+                default='relpath'):
+            match = oldmatch(ctx, pats, opts, globbed, default)
+            m = copy.copy(match)
+            def tostandin(f):
+                if lfutil.standin(f) in ctx:
+                    return lfutil.standin(f)
+                elif lfutil.standin(f) in repo[None]:
+                    return None
+                return f
+            m._files = [tostandin(f) for f in m._files]
+            m._files = [f for f in m._files if f is not None]
+            m._fmap = set(m._files)
+            m._always = False
+            origmatchfn = m.matchfn
+            def matchfn(f):
+                if lfutil.isstandin(f):
+                    return (origmatchfn(lfutil.splitstandin(f)) and
+                            (f in repo[None] or f in ctx))
+                return origmatchfn(f)
+            m.matchfn = matchfn
+            return m
+        oldmatch = installmatchfn(overridematch)
         try:
-            def overridematch(ctx, pats=[], opts={}, globbed=False,
-                    default='relpath'):
-                match = oldmatch(ctx, pats, opts, globbed, default)
-                m = copy.copy(match)
-                def tostandin(f):
-                    if lfutil.standin(f) in ctx:
-                        return lfutil.standin(f)
-                    elif lfutil.standin(f) in repo[None]:
-                        return None
-                    return f
-                m._files = [tostandin(f) for f in m._files]
-                m._files = [f for f in m._files if f is not None]
-                m._fmap = set(m._files)
-                m._always = False
-                origmatchfn = m.matchfn
-                def matchfn(f):
-                    if lfutil.isstandin(f):
-                        return (origmatchfn(lfutil.splitstandin(f)) and
-                                (f in repo[None] or f in ctx))
-                    return origmatchfn(f)
-                m.matchfn = matchfn
-                return m
-            oldmatch = installmatchfn(overridematch)
-            overridematch(repo[None], pats, opts)
             orig(ui, repo, *pats, **opts)
         finally:
             restorematchfn()



More information about the Mercurial-devel mailing list