[PATCH STABLE] largefiles: only cache largefiles in new heads
Na'Tosha Bard
natosha at unity3d.com
Fri Feb 10 14:30:58 UTC 2012
# HG changeset patch
# User Na'Tosha Bard <natosha at unity3d.com>
# Date 1328881569 -3600
# Node ID c587d2e33acfa899872af94a83480a28475dfb63
# Parent e1d8218d733bb318605308fa8c6f261f49d0c163
largefiles: only cache largefiles in new heads
This fixes a serious performance regression in largefiles introduced in
Mercurial 2.1. Caching new largefiles on pull is necessary, because
otherwise largefiles will be missing (and unable to be downloaded) when
the user tries to merge or rebase a new head with an old one. But this
is an expensive operation and should only be done for heads that are new
from the pull, rather than on all heads in the repository.
diff -r e1d8218d733b -r c587d2e33acf hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py Mon Feb 06 15:36:44 2012 -0600
+++ b/hgext/largefiles/lfutil.py Fri Feb 10 14:46:09 2012 +0100
@@ -449,3 +449,11 @@
class storeprotonotcapable(Exception):
def __init__(self, storetypes):
self.storetypes = storetypes
+
+def getcurrentheads(repo):
+ branches = repo.branchmap()
+ heads = []
+ for branch in branches:
+ newheads = repo.branchheads(branch)
+ heads = heads + newheads
+ return heads
diff -r e1d8218d733b -r c587d2e33acf hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py Mon Feb 06 15:36:44 2012 -0600
+++ b/hgext/largefiles/overrides.py Fri Feb 10 14:46:09 2012 +0100
@@ -660,6 +660,7 @@
repo.lfpullsource = source
if not source:
source = 'default'
+ oldheads = lfutil.getcurrentheads(repo)
result = orig(ui, repo, source, **opts)
# If we do not have the new largefiles for any new heads we pulled, we
# will run into a problem later if we try to merge or rebase with one of
@@ -667,12 +668,11 @@
# cache.
ui.status(_("caching new largefiles\n"))
numcached = 0
- branches = repo.branchmap()
- for branch in branches:
- heads = repo.branchheads(branch)
- for head in heads:
- (cached, missing) = lfcommands.cachelfiles(ui, repo, head)
- numcached += len(cached)
+ heads = lfutil.getcurrentheads(repo)
+ newheads = set(heads).difference(set(oldheads))
+ for head in newheads:
+ (cached, missing) = lfcommands.cachelfiles(ui, repo, head)
+ numcached += len(cached)
ui.status(_("%d largefiles cached\n" % numcached))
return result
More information about the Mercurial-devel
mailing list