Mercurial > public > mercurial-scm > hg
comparison mercurial/hg.py @ 40331:ac59de55c8b4
exchange: support declaring pull depth
Upcoming commits will teach exchangev2 how to perform a shallow
clone. This commit teaches hg.clone(), exchange.pull(), and
exchange.pulloperation to recognize a request for a shallow clone
by having the caller specify a numeric depth of the maximum number of
ancestor changesets to fetch.
There are certainly other ways we could control shallow-ness. But this
one is simple to implement and is also how the narrow extension
controls things. So it seems to make sense to start here.
Differential Revision: https://phab.mercurial-scm.org/D5136
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 14 Sep 2018 14:56:13 -0700 |
parents | 6637b079ae45 |
children | b14fdf1fb615 |
comparison
equal
deleted
inserted
replaced
40330:00a4cd368e3f | 40331:ac59de55c8b4 |
---|---|
477 os.mkdir(dstcachedir) | 477 os.mkdir(dstcachedir) |
478 util.copyfile(srcbranchcache, dstbranchcache) | 478 util.copyfile(srcbranchcache, dstbranchcache) |
479 | 479 |
480 def clone(ui, peeropts, source, dest=None, pull=False, revs=None, | 480 def clone(ui, peeropts, source, dest=None, pull=False, revs=None, |
481 update=True, stream=False, branch=None, shareopts=None, | 481 update=True, stream=False, branch=None, shareopts=None, |
482 storeincludepats=None, storeexcludepats=None): | 482 storeincludepats=None, storeexcludepats=None, depth=None): |
483 """Make a copy of an existing repository. | 483 """Make a copy of an existing repository. |
484 | 484 |
485 Create a copy of an existing repository in a new directory. The | 485 Create a copy of an existing repository in a new directory. The |
486 source and destination are URLs, as passed to the repository | 486 source and destination are URLs, as passed to the repository |
487 function. Returns a pair of repository peers, the source and | 487 function. Returns a pair of repository peers, the source and |
747 overrides = {('ui', 'quietbookmarkmove'): True} | 747 overrides = {('ui', 'quietbookmarkmove'): True} |
748 with local.ui.configoverride(overrides, 'clone'): | 748 with local.ui.configoverride(overrides, 'clone'): |
749 exchange.pull(local, srcpeer, revs, | 749 exchange.pull(local, srcpeer, revs, |
750 streamclonerequested=stream, | 750 streamclonerequested=stream, |
751 includepats=storeincludepats, | 751 includepats=storeincludepats, |
752 excludepats=storeexcludepats) | 752 excludepats=storeexcludepats, |
753 depth=depth) | |
753 elif srcrepo: | 754 elif srcrepo: |
754 # TODO lift restriction once exchange.push() accepts narrow | 755 # TODO lift restriction once exchange.push() accepts narrow |
755 # push. | 756 # push. |
756 if narrow: | 757 if narrow: |
757 raise error.Abort(_('narrow clone not available for ' | 758 raise error.Abort(_('narrow clone not available for ' |