[PATCH 1 of 3 STABLE] largefiles: introduce the 'composelargefilematcher()' method

Matt Harbison mharbison72 at gmail.com
Mon Dec 22 05:39:17 UTC 2014


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1419190966 18000
#      Sun Dec 21 14:42:46 2014 -0500
# Branch stable
# Node ID 9c7547afd19febf973c1f1891f3ccd75625aaace
# Parent  444603a7ebeb746b98de3ce993783c1d74fbf481
largefiles: introduce the 'composelargefilematcher()' method

This is a copy/paste (with the necessary tweaks) of the composenormalfilematcher
method currently on default, which does the inverse- this trims the normal files
out of the matcher.  It will be used in the next patch.

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -23,6 +23,18 @@
 
 # -- Utility functions: commonly/repeatedly needed functionality ---------------
 
+def composelargefilematcher(match, manifest):
+    '''create a matcher that matches only the largefiles in the original
+    matcher'''
+    m = copy.copy(match)
+    lfile = lambda f: lfutil.standin(f) in manifest
+    m._files = filter(lfile, m._files)
+    m._fmap = set(m._files)
+    m._always = False
+    origmatchfn = m.matchfn
+    m.matchfn = lambda f: lfile(f) and origmatchfn(f)
+    return m
+
 def installnormalfilesmatchfn(manifest):
     '''installmatchfn with a matchfn that ignores all largefiles'''
     def overridematch(ctx, pats=[], opts={}, globbed=False,


More information about the Mercurial-devel mailing list