largefiles: optimize performance when updating (
issue3440)
Previously, when updating, cachelfiles was called blindly on all largefiles
in the repository at the revision being updated to, despite the fact that
a list of which largefiles needs to be updated has already been collected. This
optimization constrains the cachelfiles call to only the largefiles that need
to be updated.
On a repository with about 80 largefiles, updating between two revisions that
only change one largefile goes from approximately 6.7 seconds to 3.3 seconds.
--- a/hgext/largefiles/lfcommands.py Sun May 13 12:52:24 2012 +0200
+++ b/hgext/largefiles/lfcommands.py Sat May 12 15:41:27 2012 +0200
@@ -365,7 +365,7 @@
store = basestore._openstore(repo)
return store.verify(revs, contents=contents)
-def cachelfiles(ui, repo, node):
+def cachelfiles(ui, repo, node, filelist=None):
'''cachelfiles ensures that all largefiles needed by the specified revision
are present in the repository's largefile cache.
@@ -373,6 +373,8 @@
by this operation; missing is the list of files that were needed but could
not be found.'''
lfiles = lfutil.listlfiles(repo, node)
+ if filelist:
+ lfiles = set(lfiles) & set(filelist)
toget = []
for lfile in lfiles:
@@ -431,7 +433,7 @@
if printmessage and lfiles:
ui.status(_('getting changed largefiles\n'))
printed = True
- cachelfiles(ui, repo, '.')
+ cachelfiles(ui, repo, '.', lfiles)
updated, removed = 0, 0
for i in map(lambda f: _updatelfile(repo, lfdirstate, f), lfiles):