author | Yuya Nishihara <yuya@tcha.org> |
Sun, 29 Jul 2018 22:07:42 +0900 | |
changeset 39598 | 42209f55c599 |
parent 39544 | 10a8472f6662 |
child 39933 | d5498db5f86a |
permissions | -rw-r--r-- |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 |
# narrowwirepeer.py - passes narrow spec with unbundle command |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 |
# |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 |
# Copyright 2017 Google, Inc. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
4 |
# |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 |
# This software may be used and distributed according to the terms of the |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
6 |
# GNU General Public License version 2 or any later version. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
7 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 |
from __future__ import absolute_import |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 |
from mercurial import ( |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
11 |
extensions, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
12 |
hg, |
39523
c90514043eaa
narrow: add narrow and ellipses as server capabilities
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36351
diff
changeset
|
13 |
wireprotov1server, |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
14 |
) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
15 |
|
39530
576b92928cc7
narrow: mark wire proto capability names experimental and versioned
Martin von Zweigbergk <martinvonz@google.com>
parents:
39529
diff
changeset
|
16 |
NARROWCAP = 'exp-narrow-1' |
576b92928cc7
narrow: mark wire proto capability names experimental and versioned
Martin von Zweigbergk <martinvonz@google.com>
parents:
39529
diff
changeset
|
17 |
ELLIPSESCAP = 'exp-ellipses-1' |
39523
c90514043eaa
narrow: add narrow and ellipses as server capabilities
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36351
diff
changeset
|
18 |
|
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 |
def uisetup(): |
39523
c90514043eaa
narrow: add narrow and ellipses as server capabilities
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36351
diff
changeset
|
20 |
extensions.wrapfunction(wireprotov1server, '_capabilities', addnarrowcap) |
c90514043eaa
narrow: add narrow and ellipses as server capabilities
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36351
diff
changeset
|
21 |
|
c90514043eaa
narrow: add narrow and ellipses as server capabilities
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36351
diff
changeset
|
22 |
def addnarrowcap(orig, repo, proto): |
c90514043eaa
narrow: add narrow and ellipses as server capabilities
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36351
diff
changeset
|
23 |
"""add the narrow capability to the server""" |
c90514043eaa
narrow: add narrow and ellipses as server capabilities
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36351
diff
changeset
|
24 |
caps = orig(repo, proto) |
39529
e82da0fcc7c5
narrow: move wire proto capabilities to narrowwirepeer
Martin von Zweigbergk <martinvonz@google.com>
parents:
39523
diff
changeset
|
25 |
caps.append(NARROWCAP) |
39523
c90514043eaa
narrow: add narrow and ellipses as server capabilities
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36351
diff
changeset
|
26 |
if repo.ui.configbool('experimental', 'narrowservebrokenellipses'): |
39529
e82da0fcc7c5
narrow: move wire proto capabilities to narrowwirepeer
Martin von Zweigbergk <martinvonz@google.com>
parents:
39523
diff
changeset
|
27 |
caps.append(ELLIPSESCAP) |
39523
c90514043eaa
narrow: add narrow and ellipses as server capabilities
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36351
diff
changeset
|
28 |
return caps |
c90514043eaa
narrow: add narrow and ellipses as server capabilities
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
36351
diff
changeset
|
29 |
|
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
30 |
def reposetup(repo): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
31 |
def wirereposetup(ui, peer): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
32 |
def wrapped(orig, cmd, *args, **kwargs): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
33 |
if cmd == 'unbundle': |
36102
b60c577b6e03
narrowwirepeer: add TODO about how we add wireproto args to unbundle :(
Augie Fackler <augie@google.com>
parents:
36101
diff
changeset
|
34 |
# TODO: don't blindly add include/exclude wireproto |
b60c577b6e03
narrowwirepeer: add TODO about how we add wireproto args to unbundle :(
Augie Fackler <augie@google.com>
parents:
36101
diff
changeset
|
35 |
# arguments to unbundle. |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
36 |
include, exclude = repo.narrowpats |
36351
87e950a070e6
narrowwirepeer: add some strkwargs to fix a crash on py3
Augie Fackler <augie@google.com>
parents:
36160
diff
changeset
|
37 |
kwargs[r"includepats"] = ','.join(include) |
87e950a070e6
narrowwirepeer: add some strkwargs to fix a crash on py3
Augie Fackler <augie@google.com>
parents:
36160
diff
changeset
|
38 |
kwargs[r"excludepats"] = ','.join(exclude) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
39 |
return orig(cmd, *args, **kwargs) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
40 |
extensions.wrapfunction(peer, '_calltwowaystream', wrapped) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
41 |
hg.wirepeersetupfuncs.append(wirereposetup) |