[PATCH 09 of 19 STABLE] largefiles: use dirstate instead of lfdirstate for resource efficiency

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


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1330335216 -32400
# Branch stable
# Node ID d9217e9e3d58f84a077305fff6468d47d284ca03
# Parent  2456abdf233742c14519360bb30786f0741291d3
largefiles: use dirstate instead of lfdirstate for resource efficiency

original implementation requires largefiles specific dirstate object
('lfdirstate') and its 'dirs()' information to examine whether
specified patterns are related to largefiles or not.

'dirs()' of 'dirstate' is referred also from manifest walking in
'localrepository', but one of 'lfdirstate' is referred from few places
only in largefiles implementation.

so, this patch examines it by looking STANDIN-nized name up in
'dirstate' instead of 'lfdirstate' to avoid additional resource
consumption for 'dirs()' of it.

with this patch, 'lfdirstate' is useless until 'working' route is
executed, so this patch also delays initialization of it.

diff -r 2456abdf2337 -r d9217e9e3d58 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
@@ -118,12 +118,13 @@
                 # command line.  If there were, and none of them were
                 # largefiles, we should just bail here and let super
                 # handle it -- thus gaining a big performance boost.
-                lfdirstate = lfutil.openlfdirstate(ui, self)
                 if match.files() and not match.anypats():
+                    dirstate = repo.dirstate
                     for f in match.files():
                         if lfutil.isstandin(f):
                             continue
-                        if f in lfdirstate or f in lfdirstate.dirs():
+                        sf = lfutil.standin(f)
+                        if sf in dirstate or sf in dirstate.dirs():
                             break
                     else:
                         return super(lfiles_repo, self).status(node1, node2,
@@ -158,6 +159,7 @@
                 result = super(lfiles_repo, self).status(node1, node2, m,
                     True, clean, unknown, listsubrepos)
                 if working:
+                    lfdirstate = lfutil.openlfdirstate(ui, self)
                     try:
                         # Any non-largefiles that were explicitly listed must be
                         # taken out or lfdirstate.status will report an error.
@@ -169,11 +171,13 @@
                         lfdirstate._ignore = _ignoreoverride
 
                         def filefn(files):
+                            dirstate = repo.dirstate
                             for f in files:
                                 # ignore 'STANDIN direct' pattern
                                 if lfutil.isstandin(f):
                                     continue
-                                if f in lfdirstate or f in lfdirstate.dirs():
+                                sf = lfutil.standin(f)
+                                if sf in dirstate or sf in dirstate.dirs():
                                     yield f
                         match = match.convert(filefn)
                         # Don't waste time getting the ignored and unknown


More information about the Mercurial-devel mailing list