[PATCH 15 of 19 STABLE] largefiles: refactoring of file list generation for STANDIN matcher

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Mon Feb 27 04:46:40 CST 2012


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1330335216 -32400
# Branch stable
# Node ID 0e26a7e35a1ec4cfde13987fd15e977336e570ce
# Parent  b728948758a3dd40ab955b314dbcc3a3f12f924c
largefiles: refactoring of file list generation for STANDIN matcher

this patch examines specified patterns in steps below:

    1. STANDIN or not
    2. exact name of normal file or not
    3. exact name of large file or not
    4. directory pattern for large file or not
    5. otherwise

this order can avoid resource consumption for building 'dirs()'
information up, when all specified patterns are files or STANDIN, even
if they are only known in 1st context.

diff -r b728948758a3 -r 0e26a7e35a1e hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py	Mon Feb 27 18:33:36 2012 +0900
+++ b/hgext/largefiles/reposetup.py	Mon Feb 27 18:33:36 2012 +0900
@@ -151,18 +151,26 @@
 
                 # Create a copy of match that matches standins instead
                 # of largefiles.
+                if parentworking:
+                    finctx = lambda f: inctx(f, ctx2)
+                    dinctx = lambda d: inctxdirs(d, ctx2)
+                else:
+                    finctx = lambda f: inctx(f, ctx2) or inctx(f, ctx1)
+                    dinctx = lambda d: inctxdirs(d, ctx2) or inctxdirs(d, ctx1)
                 def filefn(files):
                     if not working:
                         return # 'match.files()' is never used in this case
                     for f in files:
-                        if not lfutil.isstandin(f):
-                            sf = lfutil.standin(f)
-                            if (inctx(sf, ctx2) or inctxdirs(sf, ctx2) or
-                                (not parentworking and
-                                 (inctx(sf, ctx1) or inctxdirs(sf, ctx1)))):
-                                yield sf
-                                continue
-                        # not 'known largefile', or 'STANDIN direct' pattern
+                        if lfutil.isstandin(f) or finctx(f):
+                            yield f # STANDIN or exact name of normal file
+                            continue
+                        sf = lfutil.standin(f)
+                        if finctx(sf):
+                            yield sf # exact name of large file
+                            continue
+                        if dinctx(sf):
+                            yield sf # directory pattern for large file
+                            continue
                         yield f
                 def matchfn(orgmatchfn, f):
                     wf = lfutil.splitstandin(f)


More information about the Mercurial-devel mailing list