comparison mercurial/hg.py @ 35766:72fdd99eb526

caches: make 'cachetocopy' available in scmutil For more code to use this information, we need it to be more publicly available.
author Boris Feld <boris.feld@octobus.net>
date Wed, 17 Jan 2018 17:46:49 +0100
parents 7ffbd911dbc9
children c8e2d6ed1f9e
comparison
equal deleted inserted replaced
35765:56c30b31afbe 35766:72fdd99eb526
19 ) 19 )
20 20
21 from . import ( 21 from . import (
22 bookmarks, 22 bookmarks,
23 bundlerepo, 23 bundlerepo,
24 cacheutil,
24 cmdutil, 25 cmdutil,
25 destutil, 26 destutil,
26 discovery, 27 discovery,
27 error, 28 error,
28 exchange, 29 exchange,
32 lock, 33 lock,
33 logexchange, 34 logexchange,
34 merge as mergemod, 35 merge as mergemod,
35 node, 36 node,
36 phases, 37 phases,
37 repoview,
38 scmutil, 38 scmutil,
39 sshpeer, 39 sshpeer,
40 statichttprepo, 40 statichttprepo,
41 ui as uimod, 41 ui as uimod,
42 unionrepo, 42 unionrepo,
457 if os.path.exists(srcbranchcache): 457 if os.path.exists(srcbranchcache):
458 if not os.path.exists(dstcachedir): 458 if not os.path.exists(dstcachedir):
459 os.mkdir(dstcachedir) 459 os.mkdir(dstcachedir)
460 util.copyfile(srcbranchcache, dstbranchcache) 460 util.copyfile(srcbranchcache, dstbranchcache)
461 461
462 def _cachetocopy(srcrepo):
463 """return the list of cache file valuable to copy during a clone"""
464 # In local clones we're copying all nodes, not just served
465 # ones. Therefore copy all branch caches over.
466 cachefiles = ['branch2']
467 cachefiles += ['branch2-%s' % f for f in repoview.filtertable]
468 cachefiles += ['rbc-names-v1', 'rbc-revs-v1']
469 cachefiles += ['tags2']
470 cachefiles += ['tags2-%s' % f for f in repoview.filtertable]
471 cachefiles += ['hgtagsfnodes1']
472 return cachefiles
473
474 def clone(ui, peeropts, source, dest=None, pull=False, rev=None, 462 def clone(ui, peeropts, source, dest=None, pull=False, rev=None,
475 update=True, stream=False, branch=None, shareopts=None): 463 update=True, stream=False, branch=None, shareopts=None):
476 """Make a copy of an existing repository. 464 """Make a copy of an existing repository.
477 465
478 Create a copy of an existing repository in a new directory. The 466 Create a copy of an existing repository in a new directory. The
627 dstbookmarks = os.path.join(destpath, 'bookmarks') 615 dstbookmarks = os.path.join(destpath, 'bookmarks')
628 if os.path.exists(srcbookmarks): 616 if os.path.exists(srcbookmarks):
629 util.copyfile(srcbookmarks, dstbookmarks) 617 util.copyfile(srcbookmarks, dstbookmarks)
630 618
631 dstcachedir = os.path.join(destpath, 'cache') 619 dstcachedir = os.path.join(destpath, 'cache')
632 for cache in _cachetocopy(srcrepo): 620 for cache in cacheutil.cachetocopy(srcrepo):
633 _copycache(srcrepo, dstcachedir, cache) 621 _copycache(srcrepo, dstcachedir, cache)
634 622
635 # we need to re-init the repo after manually copying the data 623 # we need to re-init the repo after manually copying the data
636 # into it 624 # into it
637 destpeer = peer(srcrepo, peeropts, dest) 625 destpeer = peer(srcrepo, peeropts, dest)