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
--- a/hgext/narrow/TODO.rst Fri Sep 07 18:35:54 2018 -0700
+++ b/hgext/narrow/TODO.rst Tue Sep 11 15:53:12 2018 -0700
@@ -28,10 +28,3 @@
narrowrepo.setnarrowpats() or narrowspec.save() need to make sure
they're holding the wlock.
-
-Implement a simple version of the expandnarrow wireproto command for
-core. Having configurable shorthands for narrowspecs has been useful
-at Google (and sparse has a similar feature from Facebook), so it
-probably makes sense to implement the feature in core. (Google's
-handler is entirely custom to Google, with a custom format related to
-bazel's build language, so it's not in the narrowhg distribution.)
--- a/hgext/narrow/narrowcommands.py Fri Sep 07 18:35:54 2018 -0700
+++ b/hgext/narrow/narrowcommands.py Tue Sep 11 15:53:12 2018 -0700
@@ -62,25 +62,6 @@
extensions.wrapcommand(commands.table, 'archive', archivenarrowcmd)
-def expandpull(pullop, includepats, excludepats):
- if not narrowspec.needsexpansion(includepats):
- return includepats, excludepats
-
- heads = pullop.heads or pullop.rheads
- includepats, excludepats = pullop.remote.expandnarrow(
- includepats, excludepats, heads)
- pullop.repo.ui.debug('Expanded narrowspec to inc=%s, exc=%s\n' % (
- includepats, excludepats))
-
- includepats = set(includepats)
- excludepats = set(excludepats)
-
- # Nefarious remote could supply unsafe patterns. Validate them.
- narrowspec.validatepatterns(includepats)
- narrowspec.validatepatterns(excludepats)
-
- return includepats, excludepats
-
def clonenarrowcmd(orig, ui, repo, *args, **opts):
"""Wraps clone command, so 'hg clone' first wraps localrepo.clone()."""
opts = pycompat.byteskwargs(opts)
@@ -116,10 +97,6 @@
includepats = narrowspec.parsepatterns(opts['include'])
excludepats = narrowspec.parsepatterns(opts['exclude'])
- # If necessary, ask the server to expand the narrowspec.
- includepats, excludepats = expandpull(
- pullop, includepats, excludepats)
-
if not includepats and excludepats:
# If nothing was included, we assume the user meant to include
# everything, except what they asked to exclude.
@@ -292,10 +269,6 @@
def _widen(ui, repo, remote, commoninc, newincludes, newexcludes):
newmatch = narrowspec.match(repo.root, newincludes, newexcludes)
- # TODO(martinvonz): Get expansion working with widening/narrowing.
- if narrowspec.needsexpansion(newincludes):
- raise error.Abort('Expansion not yet supported on pull')
-
def pullbundle2extraprepare_widen(orig, pullop, kwargs):
orig(pullop, kwargs)
# The old{in,ex}cludepats have already been set by orig()
@@ -402,9 +375,6 @@
opts['addinclude'].extend(includepats)
opts['addexclude'].extend(excludepats)
- if narrowspec.needsexpansion(opts['addinclude'] + opts['addexclude']):
- raise error.Abort('Expansion not yet supported on widen/narrow')
-
addedincludes = narrowspec.parsepatterns(opts['addinclude'])
removedincludes = narrowspec.parsepatterns(opts['removeinclude'])
addedexcludes = narrowspec.parsepatterns(opts['addexclude'])
--- a/hgext/narrow/narrowwirepeer.py Fri Sep 07 18:35:54 2018 -0700
+++ b/hgext/narrow/narrowwirepeer.py Tue Sep 11 15:53:12 2018 -0700
@@ -7,13 +7,9 @@
from __future__ import absolute_import
-from mercurial.i18n import _
from mercurial import (
- error,
extensions,
hg,
- narrowspec,
- node,
wireprotov1server,
)
@@ -21,27 +17,6 @@
ELLIPSESCAP = 'exp-ellipses-1'
def uisetup():
- def peersetup(ui, peer):
- # We must set up the expansion before reposetup below, since it's used
- # at clone time before we have a repo.
- class expandingpeer(peer.__class__):
- def expandnarrow(self, narrow_include, narrow_exclude, nodes):
- ui.status(_("expanding narrowspec\n"))
- if not self.capable('exp-expandnarrow'):
- raise error.Abort(
- 'peer does not support expanding narrowspecs')
-
- hex_nodes = (node.hex(n) for n in nodes)
- new_narrowspec = self._call(
- 'expandnarrow',
- includepats=','.join(narrow_include),
- excludepats=','.join(narrow_exclude),
- nodes=','.join(hex_nodes))
-
- return narrowspec.parseserverpatterns(new_narrowspec)
- peer.__class__ = expandingpeer
- hg.wirepeersetupfuncs.append(peersetup)
-
extensions.wrapfunction(wireprotov1server, '_capabilities', addnarrowcap)
def addnarrowcap(orig, repo, proto):
--- a/mercurial/narrowspec.py Fri Sep 07 18:35:54 2018 -0700
+++ b/mercurial/narrowspec.py Tue Sep 11 15:53:12 2018 -0700
@@ -146,9 +146,6 @@
return matchmod.match(root, '', [], include=include or [],
exclude=exclude or [])
-def needsexpansion(includes):
- return [i for i in includes if i.startswith('include:')]
-
def load(repo):
try:
spec = repo.svfs.read(FILENAME)