# HG changeset patch # User Na'Tosha Bard # Date 1336830087 -7200 # Node ID 28001e8a5149c0dcb90cc33c7d21412e405811a6 # Parent d947e1da12597090d71c3d97ec224b7aa5513330 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. diff -r d947e1da1259 -r 28001e8a5149 hgext/largefiles/lfcommands.py --- 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):