Patchwork [1,of,8] largefiles: split the creation of a normal matcher out of its install method

login
register
mail settings
Submitter Matt Harbison
Date Nov. 27, 2014, 1:12 a.m.
Message ID <36938964dbce5fc575dc.1417050734@Envy>
Download mbox | patch
Permalink /patch/6870/
State Superseded
Headers show

Comments

Matt Harbison - Nov. 27, 2014, 1:12 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1416626685 18000
#      Fri Nov 21 22:24:45 2014 -0500
# Node ID 36938964dbce5fc575dce8d6c07d4aec4d3d8af3
# Parent  b5e2128ce9e6cc0b6a2b20cc2763f9e6c351625b
largefiles: split the creation of a normal matcher out of its install method

Refactoring addremove to support subrepos will need the ability to keep passing
the same matcher and narrowing it, instead of monkey patching scmutil's matcher.
Augie Fackler - Dec. 2, 2014, 3:55 p.m.
On Wed, Nov 26, 2014 at 08:12:14PM -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1416626685 18000
> #      Fri Nov 21 22:24:45 2014 -0500
> # Node ID 36938964dbce5fc575dce8d6c07d4aec4d3d8af3
> # Parent  b5e2128ce9e6cc0b6a2b20cc2763f9e6c351625b
> largefiles: split the creation of a normal matcher out of its install method

This one seems virtuous on its own, so I'm going to go ahead and queue it.

I picked up Martin's patch, so I'll do a review of the rest of this
series, but you should plan for a v3 once you see this patch make it
to mpm's repo.

>
> Refactoring addremove to support subrepos will need the ability to keep passing
> the same matcher and narrowing it, instead of monkey patching scmutil's matcher.
>
> diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
> --- a/hgext/largefiles/overrides.py
> +++ b/hgext/largefiles/overrides.py
> @@ -22,20 +22,23 @@
>
>  # -- Utility functions: commonly/repeatedly needed functionality ---------------
>
> +def composenormalfilematcher(match, manifest):
> +    m = copy.copy(match)
> +    notlfile = lambda f: not (lfutil.isstandin(f) or lfutil.standin(f) in
> +            manifest)
> +    m._files = filter(notlfile, m._files)
> +    m._fmap = set(m._files)
> +    m._always = False
> +    origmatchfn = m.matchfn
> +    m.matchfn = lambda f: notlfile(f) and origmatchfn(f)
> +    return m
> +
>  def installnormalfilesmatchfn(manifest):
>      '''installmatchfn with a matchfn that ignores all largefiles'''
>      def overridematch(ctx, pats=[], opts={}, globbed=False,
>              default='relpath'):
>          match = oldmatch(ctx, pats, opts, globbed, default)
> -        m = copy.copy(match)
> -        notlfile = lambda f: not (lfutil.isstandin(f) or lfutil.standin(f) in
> -                manifest)
> -        m._files = filter(notlfile, m._files)
> -        m._fmap = set(m._files)
> -        m._always = False
> -        origmatchfn = m.matchfn
> -        m.matchfn = lambda f: notlfile(f) and origmatchfn(f)
> -        return m
> +        return composenormalfilematcher(match, manifest)
>      oldmatch = installmatchfn(overridematch)
>
>  def installmatchfn(f):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -22,20 +22,23 @@ 
 
 # -- Utility functions: commonly/repeatedly needed functionality ---------------
 
+def composenormalfilematcher(match, manifest):
+    m = copy.copy(match)
+    notlfile = lambda f: not (lfutil.isstandin(f) or lfutil.standin(f) in
+            manifest)
+    m._files = filter(notlfile, m._files)
+    m._fmap = set(m._files)
+    m._always = False
+    origmatchfn = m.matchfn
+    m.matchfn = lambda f: notlfile(f) and origmatchfn(f)
+    return m
+
 def installnormalfilesmatchfn(manifest):
     '''installmatchfn with a matchfn that ignores all largefiles'''
     def overridematch(ctx, pats=[], opts={}, globbed=False,
             default='relpath'):
         match = oldmatch(ctx, pats, opts, globbed, default)
-        m = copy.copy(match)
-        notlfile = lambda f: not (lfutil.isstandin(f) or lfutil.standin(f) in
-                manifest)
-        m._files = filter(notlfile, m._files)
-        m._fmap = set(m._files)
-        m._always = False
-        origmatchfn = m.matchfn
-        m.matchfn = lambda f: notlfile(f) and origmatchfn(f)
-        return m
+        return composenormalfilematcher(match, manifest)
     oldmatch = installmatchfn(overridematch)
 
 def installmatchfn(f):