##// END OF EJS Templates
narrow: check "narrow" wire protocol capability, not bundle2 capability...
narrow: check "narrow" wire protocol capability, not bundle2 capability It seems like the new "narrow" wire protocol capability should be what determines if the server supports the "narrow" and "{,old}{in,ex}cludepats" arguments to the getbundle request. Differential Revision: https://phab.mercurial-scm.org/D4527

File last commit:

r39559:c9051404 default
r39564:2862e9b8 default
Show More
narrowwirepeer.py
65 lines | 2.3 KiB | text/x-python | PythonLexer
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 # narrowwirepeer.py - passes narrow spec with unbundle command
#
# Copyright 2017 Google, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
from mercurial.i18n import _
from mercurial import (
error,
extensions,
hg,
Gregory Szorc
narrowspec: move module into core...
r36178 narrowspec,
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 node,
Pulkit Goyal
narrow: add narrow and ellipses as server capabilities...
r39559 wireprotov1server,
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 )
Pulkit Goyal
narrow: add narrow and ellipses as server capabilities...
r39559 from . import narrowbundle2
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 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"))
Augie Fackler
narrowwirepeer: rename expandnarrow capability to exp-expandnarrow...
r36118 if not self.capable('exp-expandnarrow'):
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 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)
Pulkit Goyal
narrow: add narrow and ellipses as server capabilities...
r39559 extensions.wrapfunction(wireprotov1server, '_capabilities', addnarrowcap)
def addnarrowcap(orig, repo, proto):
"""add the narrow capability to the server"""
caps = orig(repo, proto)
caps.append(narrowbundle2.NARROWCAP)
if repo.ui.configbool('experimental', 'narrowservebrokenellipses'):
caps.append(narrowbundle2.ELLIPSESCAP)
return caps
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 def reposetup(repo):
def wirereposetup(ui, peer):
def wrapped(orig, cmd, *args, **kwargs):
if cmd == 'unbundle':
Augie Fackler
narrowwirepeer: add TODO about how we add wireproto args to unbundle :(...
r36119 # TODO: don't blindly add include/exclude wireproto
# arguments to unbundle.
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 include, exclude = repo.narrowpats
Augie Fackler
narrowwirepeer: add some strkwargs to fix a crash on py3...
r36369 kwargs[r"includepats"] = ','.join(include)
kwargs[r"excludepats"] = ','.join(exclude)
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 return orig(cmd, *args, **kwargs)
extensions.wrapfunction(peer, '_calltwowaystream', wrapped)
hg.wirepeersetupfuncs.append(wirereposetup)