[PATCH 2 of 4] local-clone: extract the listing of caches to copy
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Thu May 25 06:56:11 EDT 2017
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1495706347 -7200
# Thu May 25 11:59:07 2017 +0200
# Node ID 92bfcf826e4613c6d80afce8b6e3cad37539ca69
# Parent ee0b94add82334b4bae4603837fbc0244502a03b
# EXP-Topic clone-caches
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
# hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 92bfcf826e46
local-clone: extract the listing of caches to copy
Right now, the clone only copy the branchmap caches. There are multiple other
valuable caches that we should copy and extension might adds their own. So we
add a function to list the cache files to copy from the repository. The
repository argument is unused but extension will want it.
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -420,6 +420,14 @@ def _copycache(srcrepo, dstcachedir, fna
os.mkdir(dstcachedir)
util.copyfile(srcbranchcache, dstbranchcache)
+def _cachetocopy(srcrepo):
+ """return the list of cache file valuable to copy during a clone"""
+ # In local clones we're copying all nodes, not just served
+ # ones. Therefore copy all branch caches over.
+ cachefiles = ['branch2']
+ cachefiles.extend('branch2-%s' % f for f in repoview.filtertable)
+ return cachefiles
+
def clone(ui, peeropts, source, dest=None, pull=False, rev=None,
update=True, stream=False, branch=None, shareopts=None):
"""Make a copy of an existing repository.
@@ -578,11 +586,8 @@ def clone(ui, peeropts, source, dest=Non
util.copyfile(srcbookmarks, dstbookmarks)
dstcachedir = os.path.join(destpath, 'cache')
- # In local clones we're copying all nodes, not just served
- # ones. Therefore copy all branch caches over.
- _copycache(srcrepo, dstcachedir, 'branch2')
- for cachename in repoview.filtertable:
- _copycache(srcrepo, dstcachedir, 'branch2-%s' % cachename)
+ for cache in _cachetocopy(srcrepo):
+ _copycache(srcrepo, dstcachedir, cache)
# we need to re-init the repo after manually copying the data
# into it
More information about the Mercurial-devel
mailing list