Show More
@@ -15,6 +15,7 b' from __future__ import absolute_import' | |||||
15 | testedwith = 'ships-with-hg-core' |
|
15 | testedwith = 'ships-with-hg-core' | |
16 |
|
16 | |||
17 | from mercurial import ( |
|
17 | from mercurial import ( | |
|
18 | changegroup, | |||
18 | extensions, |
|
19 | extensions, | |
19 | hg, |
|
20 | hg, | |
20 | localrepo, |
|
21 | localrepo, | |
@@ -55,7 +56,7 b" configitem('experimental', 'narrowserveb" | |||||
55 | # Export the commands table for Mercurial to see. |
|
56 | # Export the commands table for Mercurial to see. | |
56 | cmdtable = narrowcommands.table |
|
57 | cmdtable = narrowcommands.table | |
57 |
|
58 | |||
58 |
localrepo.localrepository._basesupported.add( |
|
59 | localrepo.localrepository._basesupported.add(changegroup.NARROW_REQUIREMENT) | |
59 |
|
60 | |||
60 | def uisetup(ui): |
|
61 | def uisetup(ui): | |
61 | """Wraps user-facing mercurial commands with narrow-aware versions.""" |
|
62 | """Wraps user-facing mercurial commands with narrow-aware versions.""" | |
@@ -71,7 +72,7 b' def reposetup(ui, repo):' | |||||
71 | if not isinstance(repo, localrepo.localrepository): |
|
72 | if not isinstance(repo, localrepo.localrepository): | |
72 | return |
|
73 | return | |
73 |
|
74 | |||
74 |
if |
|
75 | if changegroup.NARROW_REQUIREMENT in repo.requirements: | |
75 | narrowrepo.wraprepo(repo, True) |
|
76 | narrowrepo.wraprepo(repo, True) | |
76 | narrowcopies.setup(repo) |
|
77 | narrowcopies.setup(repo) | |
77 | narrowdirstate.setup(repo) |
|
78 | narrowdirstate.setup(repo) |
@@ -30,10 +30,6 b' from mercurial import (' | |||||
30 | wireproto, |
|
30 | wireproto, | |
31 | ) |
|
31 | ) | |
32 |
|
32 | |||
33 | from . import ( |
|
|||
34 | narrowrepo, |
|
|||
35 | ) |
|
|||
36 |
|
||||
37 | NARROWCAP = 'narrow' |
|
33 | NARROWCAP = 'narrow' | |
38 | _NARROWACL_SECTION = 'narrowhgacl' |
|
34 | _NARROWACL_SECTION = 'narrowhgacl' | |
39 | _CHANGESPECPART = NARROWCAP + ':changespec' |
|
35 | _CHANGESPECPART = NARROWCAP + ':changespec' | |
@@ -366,8 +362,8 b' def _handlechangespec_2(op, inpart):' | |||||
366 | includepats = set(inpart.params.get(_SPECPART_INCLUDE, '').splitlines()) |
|
362 | includepats = set(inpart.params.get(_SPECPART_INCLUDE, '').splitlines()) | |
367 | excludepats = set(inpart.params.get(_SPECPART_EXCLUDE, '').splitlines()) |
|
363 | excludepats = set(inpart.params.get(_SPECPART_EXCLUDE, '').splitlines()) | |
368 | narrowspec.save(op.repo, includepats, excludepats) |
|
364 | narrowspec.save(op.repo, includepats, excludepats) | |
369 |
if not |
|
365 | if not changegroup.NARROW_REQUIREMENT in op.repo.requirements: | |
370 |
op.repo.requirements.add( |
|
366 | op.repo.requirements.add(changegroup.NARROW_REQUIREMENT) | |
371 | op.repo._writerequirements() |
|
367 | op.repo._writerequirements() | |
372 | op.repo.invalidate(clearfilecache=True) |
|
368 | op.repo.invalidate(clearfilecache=True) | |
373 |
|
369 |
@@ -19,15 +19,11 b' from mercurial import (' | |||||
19 | util, |
|
19 | util, | |
20 | ) |
|
20 | ) | |
21 |
|
21 | |||
22 | from . import ( |
|
|||
23 | narrowrepo, |
|
|||
24 | ) |
|
|||
25 |
|
||||
26 | def setup(): |
|
22 | def setup(): | |
27 |
|
23 | |||
28 | def supportedoutgoingversions(orig, repo): |
|
24 | def supportedoutgoingversions(orig, repo): | |
29 | versions = orig(repo) |
|
25 | versions = orig(repo) | |
30 |
if |
|
26 | if changegroup.NARROW_REQUIREMENT in repo.requirements: | |
31 | versions.discard('01') |
|
27 | versions.discard('01') | |
32 | versions.discard('02') |
|
28 | versions.discard('02') | |
33 | return versions |
|
29 | return versions |
@@ -10,6 +10,7 b' import itertools' | |||||
10 |
|
10 | |||
11 | from mercurial.i18n import _ |
|
11 | from mercurial.i18n import _ | |
12 | from mercurial import ( |
|
12 | from mercurial import ( | |
|
13 | changegroup, | |||
13 | cmdutil, |
|
14 | cmdutil, | |
14 | commands, |
|
15 | commands, | |
15 | discovery, |
|
16 | discovery, | |
@@ -105,7 +106,7 b' def clonenarrowcmd(orig, ui, repo, *args' | |||||
105 | repo.__class__.__bases__ = (repo.__class__.__bases__[0], |
|
106 | repo.__class__.__bases__ = (repo.__class__.__bases__[0], | |
106 | repo.unfiltered().__class__) |
|
107 | repo.unfiltered().__class__) | |
107 | if opts_narrow: |
|
108 | if opts_narrow: | |
108 |
repo.requirements.add( |
|
109 | repo.requirements.add(changegroup.NARROW_REQUIREMENT) | |
109 | repo._writerequirements() |
|
110 | repo._writerequirements() | |
110 |
|
111 | |||
111 | return orig(repo, *args, **kwargs) |
|
112 | return orig(repo, *args, **kwargs) | |
@@ -118,7 +119,7 b' def clonenarrowcmd(orig, ui, repo, *args' | |||||
118 | def pullnarrowcmd(orig, ui, repo, *args, **opts): |
|
119 | def pullnarrowcmd(orig, ui, repo, *args, **opts): | |
119 | """Wraps pull command to allow modifying narrow spec.""" |
|
120 | """Wraps pull command to allow modifying narrow spec.""" | |
120 | wrappedextraprepare = util.nullcontextmanager() |
|
121 | wrappedextraprepare = util.nullcontextmanager() | |
121 |
if |
|
122 | if changegroup.NARROW_REQUIREMENT in repo.requirements: | |
122 |
|
123 | |||
123 | def pullbundle2extraprepare_widen(orig, pullop, kwargs): |
|
124 | def pullbundle2extraprepare_widen(orig, pullop, kwargs): | |
124 | orig(pullop, kwargs) |
|
125 | orig(pullop, kwargs) | |
@@ -132,7 +133,7 b' def pullnarrowcmd(orig, ui, repo, *args,' | |||||
132 |
|
133 | |||
133 | def archivenarrowcmd(orig, ui, repo, *args, **opts): |
|
134 | def archivenarrowcmd(orig, ui, repo, *args, **opts): | |
134 | """Wraps archive command to narrow the default includes.""" |
|
135 | """Wraps archive command to narrow the default includes.""" | |
135 |
if |
|
136 | if changegroup.NARROW_REQUIREMENT in repo.requirements: | |
136 | repo_includes, repo_excludes = repo.narrowpats |
|
137 | repo_includes, repo_excludes = repo.narrowpats | |
137 | includes = set(opts.get(r'include', [])) |
|
138 | includes = set(opts.get(r'include', [])) | |
138 | excludes = set(opts.get(r'exclude', [])) |
|
139 | excludes = set(opts.get(r'exclude', [])) | |
@@ -146,7 +147,7 b' def archivenarrowcmd(orig, ui, repo, *ar' | |||||
146 |
|
147 | |||
147 | def pullbundle2extraprepare(orig, pullop, kwargs): |
|
148 | def pullbundle2extraprepare(orig, pullop, kwargs): | |
148 | repo = pullop.repo |
|
149 | repo = pullop.repo | |
149 |
if |
|
150 | if changegroup.NARROW_REQUIREMENT not in repo.requirements: | |
150 | return orig(pullop, kwargs) |
|
151 | return orig(pullop, kwargs) | |
151 |
|
152 | |||
152 | if narrowbundle2.NARROWCAP not in pullop.remotebundle2caps: |
|
153 | if narrowbundle2.NARROWCAP not in pullop.remotebundle2caps: | |
@@ -333,7 +334,7 b' def trackedcmd(ui, repo, remotepath=None' | |||||
333 | empty and will not match any files. |
|
334 | empty and will not match any files. | |
334 | """ |
|
335 | """ | |
335 | opts = pycompat.byteskwargs(opts) |
|
336 | opts = pycompat.byteskwargs(opts) | |
336 |
if |
|
337 | if changegroup.NARROW_REQUIREMENT not in repo.requirements: | |
337 | ui.warn(_('The narrow command is only supported on respositories cloned' |
|
338 | ui.warn(_('The narrow command is only supported on respositories cloned' | |
338 | ' with --narrow.\n')) |
|
339 | ' with --narrow.\n')) | |
339 | return 1 |
|
340 | return 1 |
@@ -9,6 +9,7 b' from __future__ import absolute_import' | |||||
9 |
|
9 | |||
10 | from mercurial import ( |
|
10 | from mercurial import ( | |
11 | bundlerepo, |
|
11 | bundlerepo, | |
|
12 | changegroup, | |||
12 | hg, |
|
13 | hg, | |
13 | localrepo, |
|
14 | localrepo, | |
14 | match as matchmod, |
|
15 | match as matchmod, | |
@@ -20,19 +21,15 b' from . import (' | |||||
20 | narrowrevlog, |
|
21 | narrowrevlog, | |
21 | ) |
|
22 | ) | |
22 |
|
23 | |||
23 | # When narrowing is finalized and no longer subject to format changes, |
|
|||
24 | # we should move this to just "narrow" or similar. |
|
|||
25 | REQUIREMENT = 'narrowhg-experimental' |
|
|||
26 |
|
||||
27 | def wrappostshare(orig, sourcerepo, destrepo, **kwargs): |
|
24 | def wrappostshare(orig, sourcerepo, destrepo, **kwargs): | |
28 | orig(sourcerepo, destrepo, **kwargs) |
|
25 | orig(sourcerepo, destrepo, **kwargs) | |
29 | if REQUIREMENT in sourcerepo.requirements: |
|
26 | if changegroup.NARROW_REQUIREMENT in sourcerepo.requirements: | |
30 | with destrepo.wlock(): |
|
27 | with destrepo.wlock(): | |
31 | with destrepo.vfs('shared', 'a') as fp: |
|
28 | with destrepo.vfs('shared', 'a') as fp: | |
32 | fp.write(narrowspec.FILENAME + '\n') |
|
29 | fp.write(narrowspec.FILENAME + '\n') | |
33 |
|
30 | |||
34 | def unsharenarrowspec(orig, ui, repo, repopath): |
|
31 | def unsharenarrowspec(orig, ui, repo, repopath): | |
35 | if (REQUIREMENT in repo.requirements |
|
32 | if (changegroup.NARROW_REQUIREMENT in repo.requirements | |
36 | and repo.path == repopath and repo.shared()): |
|
33 | and repo.path == repopath and repo.shared()): | |
37 | srcrepo = hg.sharedreposource(repo) |
|
34 | srcrepo = hg.sharedreposource(repo) | |
38 | with srcrepo.vfs(narrowspec.FILENAME) as f: |
|
35 | with srcrepo.vfs(narrowspec.FILENAME) as f: |
@@ -32,6 +32,10 b' from . import (' | |||||
32 | _CHANGEGROUPV2_DELTA_HEADER = "20s20s20s20s20s" |
|
32 | _CHANGEGROUPV2_DELTA_HEADER = "20s20s20s20s20s" | |
33 | _CHANGEGROUPV3_DELTA_HEADER = ">20s20s20s20s20sH" |
|
33 | _CHANGEGROUPV3_DELTA_HEADER = ">20s20s20s20s20sH" | |
34 |
|
34 | |||
|
35 | # When narrowing is finalized and no longer subject to format changes, | |||
|
36 | # we should move this to just "narrow" or similar. | |||
|
37 | NARROW_REQUIREMENT = 'narrowhg-experimental' | |||
|
38 | ||||
35 | readexactly = util.readexactly |
|
39 | readexactly = util.readexactly | |
36 |
|
40 | |||
37 | def getchunk(stream): |
|
41 | def getchunk(stream): |
General Comments 0
You need to be logged in to leave comments.
Login now