Mercurial > hg
view hgext/narrow/narrowwirepeer.py @ 40023:10cf8b116dd8
wireprotov2: advertise redirect targets in capabilities
This is pretty straightforward.
Redirect targets will require an extension to support. So we've added
a function that can be wrapped to define redirect targets.
To test this, we teach our simple cache test extension to read
redirect targets from a file. It's a bit hacky. But it gets the
job done.
Differential Revision: https://phab.mercurial-scm.org/D4775
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 26 Sep 2018 17:46:48 -0700 |
parents | a24f4638d6c1 |
children | 8feae5b989bc |
line wrap: on
line source
# 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 import ( extensions, hg, wireprotoserver, wireprotov1server, ) def uisetup(): extensions.wrapfunction(wireprotov1server, '_capabilities', addnarrowcap) def addnarrowcap(orig, repo, proto): """add the narrow capability to the server""" caps = orig(repo, proto) caps.append(wireprotoserver.NARROWCAP) if repo.ui.configbool('experimental', 'narrowservebrokenellipses'): caps.append(wireprotoserver.ELLIPSESCAP) return caps def reposetup(repo): def wirereposetup(ui, peer): def wrapped(orig, cmd, *args, **kwargs): if cmd == 'unbundle': # TODO: don't blindly add include/exclude wireproto # arguments to unbundle. include, exclude = repo.narrowpats kwargs[r"includepats"] = ','.join(include) kwargs[r"excludepats"] = ','.join(exclude) return orig(cmd, *args, **kwargs) extensions.wrapfunction(peer, '_calltwowaystream', wrapped) hg.wirepeersetupfuncs.append(wirereposetup)