comparison tests/pullext.py @ 40393:229d23cdb203

exchangev2: support fetching shallow files history This commit teaches the exchangev2 client code to handle fetching shallow files data. Only shallow fetching of files data is supported: shallow fetching of changeset and manifest data is explicitly not yet supported. Previously, we would fetch file revisions for changesets that were received by the current pull operation. In the new model, we calculate the set of "relevant" changesets given the pull depth and only fetch files data for those changesets. We also teach the "filesdata" command invocation to vary parameters as needed. The implementation here is far from complete or optimal. Subsequent pulls will end up re-fetching a lot of files data. But the application of this data should mostly be a no-op on the client, so it isn't a big deal. Depending on the order file revisions are fetched in, revisions could get inserted with the wrong revision number relationships. I think the best way to deal with this is to remove revision numbers from storage and to either dynamically derive them (by reconstructing a DAG from nodes/parents) or remove revision numbers from the file storage interface completely. A missing API that we'll likely want to write pretty soon is "ensure files for revision(s) are present." We can kind of cajole exchangev2.pull() to do this. But it isn't very efficient. For example, in simple cases like widening the store to obtain data for a single revision, it is probably more efficient to walk the manifest and find exactly which file revisions are missing and to make explicit requests for just their data. In more advanced cases, asking the server for all files data may be more efficient, even though it requires sending data the client already has. There is tons of room for future experimentation here. And TBH I'm not sure what the final state will be. Anyway, this commit gets us pretty close to being able to have shallow and narrow checkouts with exchangev2/sqlite storage. Close enough that a minimal extension should be able to provide fill in the gaps until the code in core stabilizes and there is a user-facing way to trigger the narrow/shallow bits from `hg clone` without also implying using of the narrow extension... Differential Revision: https://phab.mercurial-scm.org/D5169
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 19 Oct 2018 12:30:49 +0200
parents 55836a34f41b
children 70a00a8cd66e
comparison
equal deleted inserted replaced
40392:595641bd8404 40393:229d23cdb203
8 from __future__ import absolute_import 8 from __future__ import absolute_import
9 9
10 from mercurial.i18n import _ 10 from mercurial.i18n import _
11 from mercurial import ( 11 from mercurial import (
12 commands, 12 commands,
13 error,
13 extensions, 14 extensions,
14 localrepo, 15 localrepo,
15 repository, 16 repository,
16 ) 17 )
17 18
18 def clonecommand(orig, ui, repo, *args, **kwargs): 19 def clonecommand(orig, ui, repo, *args, **kwargs):
19 if kwargs.get(r'include') or kwargs.get(r'exclude'): 20 if kwargs.get(r'include') or kwargs.get(r'exclude'):
20 kwargs[r'narrow'] = True 21 kwargs[r'narrow'] = True
22
23 if kwargs.get(r'depth'):
24 try:
25 kwargs[r'depth'] = int(kwargs[r'depth'])
26 except ValueError:
27 raise error.Abort(_('--depth must be an integer'))
21 28
22 return orig(ui, repo, *args, **kwargs) 29 return orig(ui, repo, *args, **kwargs)
23 30
24 def featuresetup(ui, features): 31 def featuresetup(ui, features):
25 features.add(repository.NARROW_REQUIREMENT) 32 features.add(repository.NARROW_REQUIREMENT)
26 33
27 def extsetup(ui): 34 def extsetup(ui):
28 entry = extensions.wrapcommand(commands.table, 'clone', clonecommand) 35 entry = extensions.wrapcommand(commands.table, 'clone', clonecommand)
29 36
30 hasinclude = any(x[1] == 'include' for x in entry[1]) 37 hasinclude = any(x[1] == 'include' for x in entry[1])
38 hasdepth = any(x[1] == 'depth' for x in entry[1])
31 39
32 if not hasinclude: 40 if not hasinclude:
33 entry[1].append(('', 'include', [], 41 entry[1].append(('', 'include', [],
34 _('pattern of file/directory to clone'))) 42 _('pattern of file/directory to clone')))
35 entry[1].append(('', 'exclude', [], 43 entry[1].append(('', 'exclude', [],
36 _('pattern of file/directory to not clone'))) 44 _('pattern of file/directory to not clone')))
37 45
46 if not hasdepth:
47 entry[1].append(('', 'depth', '',
48 _('ancestry depth of changesets to fetch')))
49
38 localrepo.featuresetupfuncs.add(featuresetup) 50 localrepo.featuresetupfuncs.add(featuresetup)