[PATCH 6 of 8 STABLE RFC] largefiles: use 'dirstate._dirs' instead of 'os.path.lexists()' for performance
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Fri Feb 17 16:07:32 UTC 2012
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1329494573 -32400
# Branch stable
# Node ID 5bd50be1b934b1a7f08cb32dd60c49800a2bc5a4
# Parent 82a87da836d10865af586152c2473bc24dd0cfd4
largefiles: use 'dirstate._dirs' instead of 'os.path.lexists()' for performance
this patch assumes that cost of 'dirstate.dirs()', which mainly
processes string/map, is less enough thatn 'os.path.lexists()', which
causes I/O system call.
this patch introduces 'dirstate.dirs()' as public interface to access
'dirstate._dirs'.
diff -r 82a87da836d1 -r 5bd50be1b934 hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py Sat Feb 18 01:02:53 2012 +0900
+++ b/hgext/largefiles/reposetup.py Sat Feb 18 01:02:53 2012 +0900
@@ -109,8 +109,8 @@
except KeyError:
return False
- def hasstandin(f):
- return os.path.lexists(repo.wjoin(lfutil.standin(f)))
+ def hasstandin(f, dirstate):
+ return lfutil.standin(f) in dirstate.dirs()
if match is None:
match = match_.always(self.root, self.getcwd())
@@ -122,7 +122,7 @@
lfdirstate = lfutil.openlfdirstate(ui, self)
if parentworking and match.files() and not match.anypats():
for f in match.files():
- if (f in lfdirstate) or hasstandin(f):
+ if (f in lfdirstate) or hasstandin(f, repo.dirstate):
break
else:
return super(lfiles_repo, self).status(node1, node2,
@@ -176,7 +176,7 @@
match = copy.copy(match)
match._files = [f for f in match._files
if ((not lfutil.isstandin(f)) and
- hasstandin(f))]
+ hasstandin(f, lfdirstate))]
match._fmap = set(match._files)
# Don't waste time getting the ignored and unknown
# files again; we already have them
diff -r 82a87da836d1 -r 5bd50be1b934 mercurial/dirstate.py
--- a/mercurial/dirstate.py Sat Feb 18 01:02:53 2012 +0900
+++ b/mercurial/dirstate.py Sat Feb 18 01:02:53 2012 +0900
@@ -731,3 +731,6 @@
return (lookup, modified, added, removed, deleted, unknown, ignored,
clean)
+
+ def dirs(self):
+ return self._dirs
More information about the Mercurial-devel
mailing list