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) |