##// END OF EJS Templates
narrow: drop support for remote expansion (BC)...
Gregory Szorc -
r39581:10a8472f default
parent child Browse files
Show More
@@ -28,10 +28,3 b' format.'
28
28
29 narrowrepo.setnarrowpats() or narrowspec.save() need to make sure
29 narrowrepo.setnarrowpats() or narrowspec.save() need to make sure
30 they're holding the wlock.
30 they're holding the wlock.
31
32 Implement a simple version of the expandnarrow wireproto command for
33 core. Having configurable shorthands for narrowspecs has been useful
34 at Google (and sparse has a similar feature from Facebook), so it
35 probably makes sense to implement the feature in core. (Google's
36 handler is entirely custom to Google, with a custom format related to
37 bazel's build language, so it's not in the narrowhg distribution.)
@@ -62,25 +62,6 b' def setup():'
62
62
63 extensions.wrapcommand(commands.table, 'archive', archivenarrowcmd)
63 extensions.wrapcommand(commands.table, 'archive', archivenarrowcmd)
64
64
65 def expandpull(pullop, includepats, excludepats):
66 if not narrowspec.needsexpansion(includepats):
67 return includepats, excludepats
68
69 heads = pullop.heads or pullop.rheads
70 includepats, excludepats = pullop.remote.expandnarrow(
71 includepats, excludepats, heads)
72 pullop.repo.ui.debug('Expanded narrowspec to inc=%s, exc=%s\n' % (
73 includepats, excludepats))
74
75 includepats = set(includepats)
76 excludepats = set(excludepats)
77
78 # Nefarious remote could supply unsafe patterns. Validate them.
79 narrowspec.validatepatterns(includepats)
80 narrowspec.validatepatterns(excludepats)
81
82 return includepats, excludepats
83
84 def clonenarrowcmd(orig, ui, repo, *args, **opts):
65 def clonenarrowcmd(orig, ui, repo, *args, **opts):
85 """Wraps clone command, so 'hg clone' first wraps localrepo.clone()."""
66 """Wraps clone command, so 'hg clone' first wraps localrepo.clone()."""
86 opts = pycompat.byteskwargs(opts)
67 opts = pycompat.byteskwargs(opts)
@@ -116,10 +97,6 b' def clonenarrowcmd(orig, ui, repo, *args'
116 includepats = narrowspec.parsepatterns(opts['include'])
97 includepats = narrowspec.parsepatterns(opts['include'])
117 excludepats = narrowspec.parsepatterns(opts['exclude'])
98 excludepats = narrowspec.parsepatterns(opts['exclude'])
118
99
119 # If necessary, ask the server to expand the narrowspec.
120 includepats, excludepats = expandpull(
121 pullop, includepats, excludepats)
122
123 if not includepats and excludepats:
100 if not includepats and excludepats:
124 # If nothing was included, we assume the user meant to include
101 # If nothing was included, we assume the user meant to include
125 # everything, except what they asked to exclude.
102 # everything, except what they asked to exclude.
@@ -292,10 +269,6 b' def _narrow(ui, repo, remote, commoninc,'
292 def _widen(ui, repo, remote, commoninc, newincludes, newexcludes):
269 def _widen(ui, repo, remote, commoninc, newincludes, newexcludes):
293 newmatch = narrowspec.match(repo.root, newincludes, newexcludes)
270 newmatch = narrowspec.match(repo.root, newincludes, newexcludes)
294
271
295 # TODO(martinvonz): Get expansion working with widening/narrowing.
296 if narrowspec.needsexpansion(newincludes):
297 raise error.Abort('Expansion not yet supported on pull')
298
299 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
272 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
300 orig(pullop, kwargs)
273 orig(pullop, kwargs)
301 # The old{in,ex}cludepats have already been set by orig()
274 # The old{in,ex}cludepats have already been set by orig()
@@ -402,9 +375,6 b' def trackedcmd(ui, repo, remotepath=None'
402 opts['addinclude'].extend(includepats)
375 opts['addinclude'].extend(includepats)
403 opts['addexclude'].extend(excludepats)
376 opts['addexclude'].extend(excludepats)
404
377
405 if narrowspec.needsexpansion(opts['addinclude'] + opts['addexclude']):
406 raise error.Abort('Expansion not yet supported on widen/narrow')
407
408 addedincludes = narrowspec.parsepatterns(opts['addinclude'])
378 addedincludes = narrowspec.parsepatterns(opts['addinclude'])
409 removedincludes = narrowspec.parsepatterns(opts['removeinclude'])
379 removedincludes = narrowspec.parsepatterns(opts['removeinclude'])
410 addedexcludes = narrowspec.parsepatterns(opts['addexclude'])
380 addedexcludes = narrowspec.parsepatterns(opts['addexclude'])
@@ -7,13 +7,9 b''
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 from mercurial.i18n import _
11 from mercurial import (
10 from mercurial import (
12 error,
13 extensions,
11 extensions,
14 hg,
12 hg,
15 narrowspec,
16 node,
17 wireprotov1server,
13 wireprotov1server,
18 )
14 )
19
15
@@ -21,27 +17,6 b" NARROWCAP = 'exp-narrow-1'"
21 ELLIPSESCAP = 'exp-ellipses-1'
17 ELLIPSESCAP = 'exp-ellipses-1'
22
18
23 def uisetup():
19 def uisetup():
24 def peersetup(ui, peer):
25 # We must set up the expansion before reposetup below, since it's used
26 # at clone time before we have a repo.
27 class expandingpeer(peer.__class__):
28 def expandnarrow(self, narrow_include, narrow_exclude, nodes):
29 ui.status(_("expanding narrowspec\n"))
30 if not self.capable('exp-expandnarrow'):
31 raise error.Abort(
32 'peer does not support expanding narrowspecs')
33
34 hex_nodes = (node.hex(n) for n in nodes)
35 new_narrowspec = self._call(
36 'expandnarrow',
37 includepats=','.join(narrow_include),
38 excludepats=','.join(narrow_exclude),
39 nodes=','.join(hex_nodes))
40
41 return narrowspec.parseserverpatterns(new_narrowspec)
42 peer.__class__ = expandingpeer
43 hg.wirepeersetupfuncs.append(peersetup)
44
45 extensions.wrapfunction(wireprotov1server, '_capabilities', addnarrowcap)
20 extensions.wrapfunction(wireprotov1server, '_capabilities', addnarrowcap)
46
21
47 def addnarrowcap(orig, repo, proto):
22 def addnarrowcap(orig, repo, proto):
@@ -146,9 +146,6 b' def match(root, include=None, exclude=No'
146 return matchmod.match(root, '', [], include=include or [],
146 return matchmod.match(root, '', [], include=include or [],
147 exclude=exclude or [])
147 exclude=exclude or [])
148
148
149 def needsexpansion(includes):
150 return [i for i in includes if i.startswith('include:')]
151
152 def load(repo):
149 def load(repo):
153 try:
150 try:
154 spec = repo.svfs.read(FILENAME)
151 spec = repo.svfs.read(FILENAME)
General Comments 0
You need to be logged in to leave comments. Login now