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

login
register
mail settings
Submitter Mads Kiilerich
Date April 13, 2014, 4:59 p.m.
Message ID <07b55fef14409ca13429.1397408355@localhost.localdomain>
Download mbox | patch
Permalink /patch/4328/
State Accepted
Commit ec309395aa45826022396144fb432d52522b4330
Headers show

Comments

Mads Kiilerich - April 13, 2014, 4:59 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@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
Matt Mackall - April 17, 2014, 3:47 p.m.
On Sun, 2014-04-13 at 18:59 +0200, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@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

These all look good, queued for default, thanks.

Patch

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()