Show More
@@ -35,6 +35,7 b' from . import (' | |||||
35 | logcmdutil, |
|
35 | logcmdutil, | |
36 | logexchange, |
|
36 | logexchange, | |
37 | merge as mergemod, |
|
37 | merge as mergemod, | |
|
38 | narrowspec, | |||
38 | node, |
|
39 | node, | |
39 | phases, |
|
40 | phases, | |
40 | scmutil, |
|
41 | scmutil, | |
@@ -500,7 +501,8 b' def _copycache(srcrepo, dstcachedir, fna' | |||||
500 | util.copyfile(srcbranchcache, dstbranchcache) |
|
501 | util.copyfile(srcbranchcache, dstbranchcache) | |
501 |
|
502 | |||
502 | def clone(ui, peeropts, source, dest=None, pull=False, revs=None, |
|
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 | """Make a copy of an existing repository. |
|
506 | """Make a copy of an existing repository. | |
505 |
|
507 | |||
506 | Create a copy of an existing repository in a new directory. The |
|
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 | repository. "identity" means the name is derived from the node of the first |
|
544 | repository. "identity" means the name is derived from the node of the first | |
543 | changeset in the repository. "remote" means the name is derived from the |
|
545 | changeset in the repository. "remote" means the name is derived from the | |
544 | remote's path/URL. Defaults to "identity." |
|
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 | if isinstance(source, bytes): |
|
556 | if isinstance(source, bytes): | |
@@ -574,6 +583,24 b' def clone(ui, peeropts, source, dest=Non' | |||||
574 | elif destvfs.listdir(): |
|
583 | elif destvfs.listdir(): | |
575 | raise error.Abort(_("destination '%s' is not empty") % dest) |
|
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 | shareopts = shareopts or {} |
|
604 | shareopts = shareopts or {} | |
578 | sharepool = shareopts.get('pool') |
|
605 | sharepool = shareopts.get('pool') | |
579 | sharenamemode = shareopts.get('mode') |
|
606 | sharenamemode = shareopts.get('mode') | |
@@ -605,6 +632,11 b' def clone(ui, peeropts, source, dest=Non' | |||||
605 | raise error.Abort(_('unknown share naming mode: %s') % |
|
632 | raise error.Abort(_('unknown share naming mode: %s') % | |
606 | sharenamemode) |
|
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 | if sharepath: |
|
640 | if sharepath: | |
609 | return clonewithshare(ui, peeropts, sharepath, source, srcpeer, |
|
641 | return clonewithshare(ui, peeropts, sharepath, source, srcpeer, | |
610 | dest, pull=pull, rev=revs, update=update, |
|
642 | dest, pull=pull, rev=revs, update=update, | |
@@ -625,6 +657,10 b' def clone(ui, peeropts, source, dest=Non' | |||||
625 | and not phases.hassecret(srcrepo)): |
|
657 | and not phases.hassecret(srcrepo)): | |
626 | copy = not pull and not revs |
|
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 | if copy: |
|
664 | if copy: | |
629 | try: |
|
665 | try: | |
630 | # we use a lock here because if we race with commit, we |
|
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 | node=node.hex(node.nullid)) |
|
707 | node=node.hex(node.nullid)) | |
672 | else: |
|
708 | else: | |
673 | try: |
|
709 | try: | |
674 | destpeer = peer(srcrepo or ui, peeropts, dest, create=True) |
|
710 | # only pass ui when no srcrepo | |
675 | # only pass ui when no srcrepo |
|
711 | destpeer = peer(srcrepo or ui, peeropts, dest, create=True, | |
|
712 | createopts=createopts) | |||
676 | except OSError as inst: |
|
713 | except OSError as inst: | |
677 | if inst.errno == errno.EEXIST: |
|
714 | if inst.errno == errno.EEXIST: | |
678 | cleandir = None |
|
715 | cleandir = None | |
@@ -714,6 +751,12 b' def clone(ui, peeropts, source, dest=Non' | |||||
714 | exchange.pull(local, srcpeer, revs, |
|
751 | exchange.pull(local, srcpeer, revs, | |
715 | streamclonerequested=stream) |
|
752 | streamclonerequested=stream) | |
716 | elif srcrepo: |
|
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 | exchange.push(srcrepo, destpeer, revs=revs, |
|
760 | exchange.push(srcrepo, destpeer, revs=revs, | |
718 | bookmarks=srcrepo._bookmarks.keys()) |
|
761 | bookmarks=srcrepo._bookmarks.keys()) | |
719 | else: |
|
762 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now