Show More
@@ -35,6 +35,7 b' from . import (' | |||
|
35 | 35 | logcmdutil, |
|
36 | 36 | logexchange, |
|
37 | 37 | merge as mergemod, |
|
38 | narrowspec, | |
|
38 | 39 | node, |
|
39 | 40 | phases, |
|
40 | 41 | scmutil, |
@@ -500,7 +501,8 b' def _copycache(srcrepo, dstcachedir, fna' | |||
|
500 | 501 | util.copyfile(srcbranchcache, dstbranchcache) |
|
501 | 502 | |
|
502 | 503 | def clone(ui, peeropts, source, dest=None, pull=False, revs=None, |
|
503 |
update=True, stream=False, branch=None, shareopts=None |
|
|
504 | update=True, stream=False, branch=None, shareopts=None, | |
|
505 | storeincludepats=None, storeexcludepats=None): | |
|
504 | 506 | """Make a copy of an existing repository. |
|
505 | 507 | |
|
506 | 508 | Create a copy of an existing repository in a new directory. The |
@@ -542,6 +544,13 b' def clone(ui, peeropts, source, dest=Non' | |||
|
542 | 544 | repository. "identity" means the name is derived from the node of the first |
|
543 | 545 | changeset in the repository. "remote" means the name is derived from the |
|
544 | 546 | remote's path/URL. Defaults to "identity." |
|
547 | ||
|
548 | storeincludepats and storeexcludepats: sets of file patterns to include and | |
|
549 | exclude in the repository copy, respectively. If not defined, all files | |
|
550 | will be included (a "full" clone). Otherwise a "narrow" clone containing | |
|
551 | only the requested files will be performed. If ``storeincludepats`` is not | |
|
552 | defined but ``storeexcludepats`` is, ``storeincludepats`` is assumed to be | |
|
553 | ``path:.``. If both are empty sets, no files will be cloned. | |
|
545 | 554 | """ |
|
546 | 555 | |
|
547 | 556 | if isinstance(source, bytes): |
@@ -574,6 +583,24 b' def clone(ui, peeropts, source, dest=Non' | |||
|
574 | 583 | elif destvfs.listdir(): |
|
575 | 584 | raise error.Abort(_("destination '%s' is not empty") % dest) |
|
576 | 585 | |
|
586 | createopts = {} | |
|
587 | narrow = False | |
|
588 | ||
|
589 | if storeincludepats is not None: | |
|
590 | narrowspec.validatepatterns(storeincludepats) | |
|
591 | narrow = True | |
|
592 | ||
|
593 | if storeexcludepats is not None: | |
|
594 | narrowspec.validatepatterns(storeexcludepats) | |
|
595 | narrow = True | |
|
596 | ||
|
597 | if narrow: | |
|
598 | # Include everything by default if only exclusion patterns defined. | |
|
599 | if storeexcludepats and not storeincludepats: | |
|
600 | storeincludepats = {'path:.'} | |
|
601 | ||
|
602 | createopts['narrowfiles'] = True | |
|
603 | ||
|
577 | 604 | shareopts = shareopts or {} |
|
578 | 605 | sharepool = shareopts.get('pool') |
|
579 | 606 | sharenamemode = shareopts.get('mode') |
@@ -605,6 +632,11 b' def clone(ui, peeropts, source, dest=Non' | |||
|
605 | 632 | raise error.Abort(_('unknown share naming mode: %s') % |
|
606 | 633 | sharenamemode) |
|
607 | 634 | |
|
635 | # TODO this is a somewhat arbitrary restriction. | |
|
636 | if narrow: | |
|
637 | ui.status(_('(pooled storage not supported for narrow clones)\n')) | |
|
638 | sharepath = None | |
|
639 | ||
|
608 | 640 | if sharepath: |
|
609 | 641 | return clonewithshare(ui, peeropts, sharepath, source, srcpeer, |
|
610 | 642 | dest, pull=pull, rev=revs, update=update, |
@@ -625,6 +657,10 b' def clone(ui, peeropts, source, dest=Non' | |||
|
625 | 657 | and not phases.hassecret(srcrepo)): |
|
626 | 658 | copy = not pull and not revs |
|
627 | 659 | |
|
660 | # TODO this is a somewhat arbitrary restriction. | |
|
661 | if narrow: | |
|
662 | copy = False | |
|
663 | ||
|
628 | 664 | if copy: |
|
629 | 665 | try: |
|
630 | 666 | # we use a lock here because if we race with commit, we |
@@ -671,8 +707,9 b' def clone(ui, peeropts, source, dest=Non' | |||
|
671 | 707 | node=node.hex(node.nullid)) |
|
672 | 708 | else: |
|
673 | 709 | try: |
|
674 | destpeer = peer(srcrepo or ui, peeropts, dest, create=True) | |
|
675 | 710 |
|
|
711 | destpeer = peer(srcrepo or ui, peeropts, dest, create=True, | |
|
712 | createopts=createopts) | |
|
676 | 713 | except OSError as inst: |
|
677 | 714 | if inst.errno == errno.EEXIST: |
|
678 | 715 | cleandir = None |
@@ -714,6 +751,12 b' def clone(ui, peeropts, source, dest=Non' | |||
|
714 | 751 | exchange.pull(local, srcpeer, revs, |
|
715 | 752 | streamclonerequested=stream) |
|
716 | 753 | elif srcrepo: |
|
754 | # TODO lift restriction once exchange.push() accepts narrow | |
|
755 | # push. | |
|
756 | if narrow: | |
|
757 | raise error.Abort(_('narrow clone not available for ' | |
|
758 | 'remote destinations')) | |
|
759 | ||
|
717 | 760 | exchange.push(srcrepo, destpeer, revs=revs, |
|
718 | 761 | bookmarks=srcrepo._bookmarks.keys()) |
|
719 | 762 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now