prefetchtrees: allow only one revision to be specified as the base revision

Summary:
The `prefetch` command only allows for one revision to be specified as
the base revision. Eventually, we plan to merge `prefetch` and `prefetchtrees`
into a single command and therefore, this commit takes a step towards making
the interface to these commands exactly the same.

Test Plan: Ran all the tests.

Reviewers: #fbhgext, durham

Reviewed By: #fbhgext, durham

Differential Revision: https://phab.mercurial-scm.org/D1415
This commit is contained in:
Saurabh Singh 2017-11-16 15:28:07 -08:00
parent e36323d62f
commit a17e4403ef

View File

@ -999,23 +999,20 @@ def wrappropertycache(cls, propname, wrapper):
@command('prefetchtrees', [
('r', 'rev', '', _("revs to prefetch the trees for")),
('', 'base', '', _("revs that are assumed to already be local")),
('b', 'base', '', _("rev that is assumed to already be local")),
] + commands.walkopts, _('--rev REVS PATTERN..'))
def prefetchtrees(ui, repo, *args, **opts):
revs = repo.revs(opts.get('rev'))
baserevs = []
if opts.get('base'):
baserevs = repo.revs(opts.get('base'))
mfnodes = set()
for rev in revs:
mfnodes.add(repo[rev].manifestnode())
basemfnodes = set()
for rev in baserevs:
basemfnodes.add(repo[rev].manifestnode())
basemfnode = set()
base = opts.get('base')
if base:
basemfnode.add(repo[base].manifestnode())
_prefetchtrees(repo, '', mfnodes, basemfnodes, [])
_prefetchtrees(repo, '', mfnodes, basemfnode, [])
def _prefetchtrees(repo, rootdir, mfnodes, basemfnodes, directories):
# If possible, use remotefilelog's more expressive fallbackpath