Mercurial > hg
comparison hgext/narrow/narrowcommands.py @ 39544:10a8472f6662
narrow: drop support for remote expansion (BC)
Previous patches to validate narrow patterns accidentically dropped
support for the include: syntax that allows patterns to be expanded
from a remote.
This feature was never implemented in core and is only implemented on
Google's custom server. Per @martinvonz's review comment in D4522, it
is OK to drop this feature since it isn't used.
The concept of this feature does seem useful. I anticipate it making
a comeback some day in some shape or form. But for now, let's jettison
the dead code.
Differential Revision: https://phab.mercurial-scm.org/D4530
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 11 Sep 2018 15:53:12 -0700 |
parents | 8301741e1f89 |
children | 4afd2af36456 |
comparison
equal
deleted
inserted
replaced
39543:2182e67ea912 | 39544:10a8472f6662 |
---|---|
60 entry[1].append(('', 'depth', '', | 60 entry[1].append(('', 'depth', '', |
61 _("limit the history fetched by distance from heads"))) | 61 _("limit the history fetched by distance from heads"))) |
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) |
87 wrappedextraprepare = util.nullcontextmanager() | 68 wrappedextraprepare = util.nullcontextmanager() |
88 opts_narrow = opts['narrow'] | 69 opts_narrow = opts['narrow'] |
113 if opts_narrow: | 94 if opts_narrow: |
114 def pullbundle2extraprepare_widen(orig, pullop, kwargs): | 95 def pullbundle2extraprepare_widen(orig, pullop, kwargs): |
115 # Create narrow spec patterns from clone flags | 96 # Create narrow spec patterns from clone flags |
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 | |
119 # If necessary, ask the server to expand the narrowspec. | |
120 includepats, excludepats = expandpull( | |
121 pullop, includepats, excludepats) | |
122 | 99 |
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. |
126 includepats = {'path:.'} | 103 includepats = {'path:.'} |
290 repo.destroyed() | 267 repo.destroyed() |
291 | 268 |
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() |
302 kwargs['includepats'] = newincludes | 275 kwargs['includepats'] = newincludes |
303 kwargs['excludepats'] = newexcludes | 276 kwargs['excludepats'] = newexcludes |
400 raise error.Abort(_("including other spec files using '%include' " | 373 raise error.Abort(_("including other spec files using '%include' " |
401 "is not supported in narrowspec")) | 374 "is not supported in narrowspec")) |
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']) |
411 removedexcludes = narrowspec.parsepatterns(opts['removeexclude']) | 381 removedexcludes = narrowspec.parsepatterns(opts['removeexclude']) |
412 widening = addedincludes or removedexcludes | 382 widening = addedincludes or removedexcludes |