author | Pulkit Goyal <pulkit@yandex-team.ru> |
Fri, 28 Sep 2018 19:21:24 +0300 | |
changeset 39963 | fa2395659828 |
parent 39962 | ad9ca365738b |
child 39986 | 825a636812a4 |
permissions | -rw-r--r-- |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 |
# narrowbundle2.py - bundle2 extensions for narrow repository support |
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 |
import errno |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
11 |
import struct |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
12 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
13 |
from mercurial.i18n import _ |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
14 |
from mercurial.node import ( |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
15 |
bin, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
16 |
nullid, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
17 |
) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 |
from mercurial import ( |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 |
bundle2, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 |
changegroup, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
21 |
error, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 |
exchange, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 |
extensions, |
39681
c73c7653dfb9
narrow: use diffmatcher to send only new filelogs in non-ellipses widening
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39557
diff
changeset
|
24 |
match as matchmod, |
36198
9fd8c2a3db5a
narrowspec: move module into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36138
diff
changeset
|
25 |
narrowspec, |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
26 |
repair, |
38874
a232e6744ba3
narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents:
38848
diff
changeset
|
27 |
repository, |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
28 |
util, |
37613
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37087
diff
changeset
|
29 |
wireprototypes, |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
30 |
) |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36973
diff
changeset
|
31 |
from mercurial.utils import ( |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36973
diff
changeset
|
32 |
stringutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36973
diff
changeset
|
33 |
) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
34 |
|
36124
bc01f48c18cc
narrowbundle2: make constants ALLCAPS to be a bit more readable
Augie Fackler <augie@google.com>
parents:
36119
diff
changeset
|
35 |
NARROWCAP = 'narrow' |
36125
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
36 |
_NARROWACL_SECTION = 'narrowhgacl' |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
37 |
_CHANGESPECPART = NARROWCAP + ':changespec' |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
38 |
_SPECPART = NARROWCAP + ':spec' |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
39 |
_SPECPART_INCLUDE = 'include' |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
40 |
_SPECPART_EXCLUDE = 'exclude' |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
41 |
_KILLNODESIGNAL = 'KILL' |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
42 |
_DONESIGNAL = 'DONE' |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
43 |
_ELIDEDCSHEADER = '>20s20s20sl' # cset id, p1, p2, len(text) |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
44 |
_ELIDEDMFHEADER = '>20s20s20s20sl' # manifest id, p1, p2, link id, len(text) |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
45 |
_CSHEADERSIZE = struct.calcsize(_ELIDEDCSHEADER) |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
46 |
_MFHEADERSIZE = struct.calcsize(_ELIDEDMFHEADER) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
47 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
48 |
# When advertising capabilities, always include narrow clone support. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
49 |
def getrepocaps_narrow(orig, repo, **kwargs): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
50 |
caps = orig(repo, **kwargs) |
36124
bc01f48c18cc
narrowbundle2: make constants ALLCAPS to be a bit more readable
Augie Fackler <augie@google.com>
parents:
36119
diff
changeset
|
51 |
caps[NARROWCAP] = ['v0'] |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
52 |
return caps |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
53 |
|
39963
fa2395659828
narrow: pass 'narrow_widen' as source while generating changegroup
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39962
diff
changeset
|
54 |
def widen_bundle(repo, diffmatcher, common, known, cgversion, ellipses): |
39962
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
55 |
"""generates changegroup for widening a narrow clone |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
56 |
|
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
57 |
repo is the localrepository instance |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
58 |
diffmatcher is a differencemacther of '(newincludes, newexcludes) - |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
59 |
(oldincludes, oldexcludes)' |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
60 |
common is set of common revs between server and client |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
61 |
known is a set of revs known on the client side (used in ellipses) |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
62 |
cgversion is the changegroup version to send |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
63 |
ellipses is boolean value telling whether to send ellipses data or not |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
64 |
|
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
65 |
returns changegroup data of the changegroup built or return None if there |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
66 |
are no common revs |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
67 |
""" |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
68 |
# XXX: This patch will start sending bundle2 after couple of patches when |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
69 |
# called from the wireprotocol command |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
70 |
common = repo.revs("::%ln", common) |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
71 |
commonnodes = set() |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
72 |
cl = repo.changelog |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
73 |
for c in common: |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
74 |
commonnodes.add(cl.node(c)) |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
75 |
if commonnodes: |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
76 |
# XXX: we should only send the filelogs (and treemanifest). user |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
77 |
# already has the changelog and manifest |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
78 |
packer = changegroup.getbundler(cgversion, repo, |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
79 |
filematcher=diffmatcher, |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
80 |
fullnodes=commonnodes) |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
81 |
cgdata = packer.generate(set([nullid]), list(commonnodes), False, |
39963
fa2395659828
narrow: pass 'narrow_widen' as source while generating changegroup
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39962
diff
changeset
|
82 |
'narrow_widen', changelog=False) |
39962
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
83 |
|
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
84 |
return cgdata |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
85 |
|
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
86 |
return None |
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
87 |
|
39391
3433e8f39905
narrow: rename getbundlechangegrouppart_nonellipsis function
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39383
diff
changeset
|
88 |
def getbundlechangegrouppart_widen(bundler, repo, source, bundlecaps=None, |
3433e8f39905
narrow: rename getbundlechangegrouppart_nonellipsis function
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39383
diff
changeset
|
89 |
b2caps=None, heads=None, common=None, |
3433e8f39905
narrow: rename getbundlechangegrouppart_nonellipsis function
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39383
diff
changeset
|
90 |
**kwargs): |
39383
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
91 |
"""Handling changegroup changegroup generation on the server when user |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
92 |
is widening their narrowspec""" |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
93 |
|
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
94 |
cgversions = b2caps.get('changegroup') |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
95 |
if cgversions: # 3.1 and 3.2 ship with an empty value |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
96 |
cgversions = [v for v in cgversions |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
97 |
if v in changegroup.supportedoutgoingversions(repo)] |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
98 |
if not cgversions: |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
99 |
raise ValueError(_('no common changegroup version')) |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
100 |
version = max(cgversions) |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
101 |
else: |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
102 |
raise ValueError(_("server does not advertise changegroup version," |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
103 |
" can't negotiate support for ellipsis nodes")) |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
104 |
|
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
105 |
include = sorted(filter(bool, kwargs.get(r'includepats', []))) |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
106 |
exclude = sorted(filter(bool, kwargs.get(r'excludepats', []))) |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
107 |
newmatch = narrowspec.match(repo.root, include=include, exclude=exclude) |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
108 |
oldinclude = sorted(filter(bool, kwargs.get(r'oldincludepats', []))) |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
109 |
oldexclude = sorted(filter(bool, kwargs.get(r'oldexcludepats', []))) |
39681
c73c7653dfb9
narrow: use diffmatcher to send only new filelogs in non-ellipses widening
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39557
diff
changeset
|
110 |
oldmatch = narrowspec.match(repo.root, include=oldinclude, |
c73c7653dfb9
narrow: use diffmatcher to send only new filelogs in non-ellipses widening
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39557
diff
changeset
|
111 |
exclude=oldexclude) |
c73c7653dfb9
narrow: use diffmatcher to send only new filelogs in non-ellipses widening
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39557
diff
changeset
|
112 |
diffmatch = matchmod.differencematcher(newmatch, oldmatch) |
39383
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
113 |
common = set(common or [nullid]) |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
114 |
|
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
115 |
if (oldinclude != include or oldexclude != exclude): |
39963
fa2395659828
narrow: pass 'narrow_widen' as source while generating changegroup
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39962
diff
changeset
|
116 |
cgdata = widen_bundle(repo, diffmatch, common, [], version, False) |
39962
ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39689
diff
changeset
|
117 |
if cgdata is not None: |
39383
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
118 |
part = bundler.newpart('changegroup', data=cgdata) |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
119 |
part.addparam('version', version) |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
120 |
if 'treemanifest' in repo.requirements: |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
121 |
part.addparam('treemanifest', '1') |
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
122 |
|
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
123 |
# Serve a changegroup for a client with a narrow clone. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
124 |
def getbundlechangegrouppart_narrow(bundler, repo, source, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
125 |
bundlecaps=None, b2caps=None, heads=None, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
126 |
common=None, **kwargs): |
38848
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38847
diff
changeset
|
127 |
assert repo.ui.configbool('experimental', 'narrowservebrokenellipses') |
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38847
diff
changeset
|
128 |
|
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
129 |
cgversions = b2caps.get('changegroup') |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
130 |
if cgversions: # 3.1 and 3.2 ship with an empty value |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
131 |
cgversions = [v for v in cgversions |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
132 |
if v in changegroup.supportedoutgoingversions(repo)] |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
133 |
if not cgversions: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
134 |
raise ValueError(_('no common changegroup version')) |
36387
0d5eaa97676b
narrowbundle2: drop legacy getcgkwargs variable
Augie Fackler <augie@google.com>
parents:
36382
diff
changeset
|
135 |
version = max(cgversions) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
136 |
else: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
137 |
raise ValueError(_("server does not advertise changegroup version," |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
138 |
" can't negotiate support for ellipsis nodes")) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
139 |
|
36388
cd4f13f1ea2f
narrowbundle2: use native string to get kwargs from dict
Augie Fackler <augie@google.com>
parents:
36387
diff
changeset
|
140 |
include = sorted(filter(bool, kwargs.get(r'includepats', []))) |
cd4f13f1ea2f
narrowbundle2: use native string to get kwargs from dict
Augie Fackler <augie@google.com>
parents:
36387
diff
changeset
|
141 |
exclude = sorted(filter(bool, kwargs.get(r'excludepats', []))) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
142 |
newmatch = narrowspec.match(repo.root, include=include, exclude=exclude) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
143 |
|
36390
adce75cdf8f8
narrowbundle2: more kwargs native string fixes
Augie Fackler <augie@google.com>
parents:
36388
diff
changeset
|
144 |
depth = kwargs.get(r'depth', None) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
145 |
if depth is not None: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
146 |
depth = int(depth) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
147 |
if depth < 1: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
148 |
raise error.Abort(_('depth must be positive, got %d') % depth) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
149 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
150 |
heads = set(heads or repo.heads()) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
151 |
common = set(common or [nullid]) |
36390
adce75cdf8f8
narrowbundle2: more kwargs native string fixes
Augie Fackler <augie@google.com>
parents:
36388
diff
changeset
|
152 |
oldinclude = sorted(filter(bool, kwargs.get(r'oldincludepats', []))) |
adce75cdf8f8
narrowbundle2: more kwargs native string fixes
Augie Fackler <augie@google.com>
parents:
36388
diff
changeset
|
153 |
oldexclude = sorted(filter(bool, kwargs.get(r'oldexcludepats', []))) |
adce75cdf8f8
narrowbundle2: more kwargs native string fixes
Augie Fackler <augie@google.com>
parents:
36388
diff
changeset
|
154 |
known = {bin(n) for n in kwargs.get(r'known', [])} |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
155 |
if known and (oldinclude != include or oldexclude != exclude): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
156 |
# Steps: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
157 |
# 1. Send kill for "$known & ::common" |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
158 |
# |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
159 |
# 2. Send changegroup for ::common |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
160 |
# |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
161 |
# 3. Proceed. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
162 |
# |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
163 |
# In the future, we can send kills for only the specific |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
164 |
# nodes we know should go away or change shape, and then |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
165 |
# send a data stream that tells the client something like this: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
166 |
# |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
167 |
# a) apply this changegroup |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
168 |
# b) apply nodes XXX, YYY, ZZZ that you already have |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
169 |
# c) goto a |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
170 |
# |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
171 |
# until they've built up the full new state. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
172 |
# Convert to revnums and intersect with "common". The client should |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
173 |
# have made it a subset of "common" already, but let's be safe. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
174 |
known = set(repo.revs("%ln & ::%ln", known, common)) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
175 |
# TODO: we could send only roots() of this set, and the |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
176 |
# list of nodes in common, and the client could work out |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
177 |
# what to strip, instead of us explicitly sending every |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
178 |
# single node. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
179 |
deadrevs = known |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
180 |
def genkills(): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
181 |
for r in deadrevs: |
36125
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
182 |
yield _KILLNODESIGNAL |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
183 |
yield repo.changelog.node(r) |
36125
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
184 |
yield _DONESIGNAL |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
185 |
bundler.newpart(_CHANGESPECPART, data=genkills()) |
38831
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38830
diff
changeset
|
186 |
newvisit, newfull, newellipsis = exchange._computeellipsis( |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
187 |
repo, set(), common, known, newmatch) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
188 |
if newvisit: |
38949
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38923
diff
changeset
|
189 |
packer = changegroup.getbundler(version, repo, |
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38923
diff
changeset
|
190 |
filematcher=newmatch, |
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38923
diff
changeset
|
191 |
ellipses=True, |
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38923
diff
changeset
|
192 |
shallow=depth is not None, |
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38923
diff
changeset
|
193 |
ellipsisroots=newellipsis, |
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38923
diff
changeset
|
194 |
fullnodes=newfull) |
39963
fa2395659828
narrow: pass 'narrow_widen' as source while generating changegroup
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39962
diff
changeset
|
195 |
cgdata = packer.generate(common, newvisit, False, 'narrow_widen') |
38949
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38923
diff
changeset
|
196 |
|
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38923
diff
changeset
|
197 |
part = bundler.newpart('changegroup', data=cgdata) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
198 |
part.addparam('version', version) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
199 |
if 'treemanifest' in repo.requirements: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
200 |
part.addparam('treemanifest', '1') |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
201 |
|
38831
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38830
diff
changeset
|
202 |
visitnodes, relevant_nodes, ellipsisroots = exchange._computeellipsis( |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
203 |
repo, common, heads, set(), newmatch, depth=depth) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
204 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
205 |
repo.ui.debug('Found %d relevant revs\n' % len(relevant_nodes)) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
206 |
if visitnodes: |
38949
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38923
diff
changeset
|
207 |
packer = changegroup.getbundler(version, repo, |
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38923
diff
changeset
|
208 |
filematcher=newmatch, |
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38923
diff
changeset
|
209 |
ellipses=True, |
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38923
diff
changeset
|
210 |
shallow=depth is not None, |
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38923
diff
changeset
|
211 |
ellipsisroots=ellipsisroots, |
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38923
diff
changeset
|
212 |
fullnodes=relevant_nodes) |
39963
fa2395659828
narrow: pass 'narrow_widen' as source while generating changegroup
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39962
diff
changeset
|
213 |
cgdata = packer.generate(common, visitnodes, False, 'narrow_widen') |
38949
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38923
diff
changeset
|
214 |
|
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38923
diff
changeset
|
215 |
part = bundler.newpart('changegroup', data=cgdata) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
216 |
part.addparam('version', version) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
217 |
if 'treemanifest' in repo.requirements: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
218 |
part.addparam('treemanifest', '1') |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
219 |
|
36125
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
220 |
@bundle2.parthandler(_SPECPART, (_SPECPART_INCLUDE, _SPECPART_EXCLUDE)) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
221 |
def _handlechangespec_2(op, inpart): |
36125
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
222 |
includepats = set(inpart.params.get(_SPECPART_INCLUDE, '').splitlines()) |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
223 |
excludepats = set(inpart.params.get(_SPECPART_EXCLUDE, '').splitlines()) |
39557
ce20caecacbd
narrow: validate patterns on incoming bundle2 part
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39546
diff
changeset
|
224 |
narrowspec.validatepatterns(includepats) |
ce20caecacbd
narrow: validate patterns on incoming bundle2 part
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39546
diff
changeset
|
225 |
narrowspec.validatepatterns(excludepats) |
ce20caecacbd
narrow: validate patterns on incoming bundle2 part
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39546
diff
changeset
|
226 |
|
38874
a232e6744ba3
narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents:
38848
diff
changeset
|
227 |
if not repository.NARROW_REQUIREMENT in op.repo.requirements: |
a232e6744ba3
narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents:
38848
diff
changeset
|
228 |
op.repo.requirements.add(repository.NARROW_REQUIREMENT) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
229 |
op.repo._writerequirements() |
36499
28c7f580360b
narrow: reduce depedence on narrowspec.save()
Martin von Zweigbergk <martinvonz@google.com>
parents:
36494
diff
changeset
|
230 |
op.repo.setnarrowpats(includepats, excludepats) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
231 |
|
36125
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
232 |
@bundle2.parthandler(_CHANGESPECPART) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
233 |
def _handlechangespec(op, inpart): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
234 |
repo = op.repo |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
235 |
cl = repo.changelog |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
236 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
237 |
# changesets which need to be stripped entirely. either they're no longer |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
238 |
# needed in the new narrow spec, or the server is sending a replacement |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
239 |
# in the changegroup part. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
240 |
clkills = set() |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
241 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
242 |
# A changespec part contains all the updates to ellipsis nodes |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
243 |
# that will happen as a result of widening or narrowing a |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
244 |
# repo. All the changes that this block encounters are ellipsis |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
245 |
# nodes or flags to kill an existing ellipsis. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
246 |
chunksignal = changegroup.readexactly(inpart, 4) |
36125
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
247 |
while chunksignal != _DONESIGNAL: |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
248 |
if chunksignal == _KILLNODESIGNAL: |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
249 |
# a node used to be an ellipsis but isn't anymore |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
250 |
ck = changegroup.readexactly(inpart, 20) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
251 |
if cl.hasnode(ck): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
252 |
clkills.add(ck) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
253 |
else: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
254 |
raise error.Abort( |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
255 |
_('unexpected changespec node chunk type: %s') % chunksignal) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
256 |
chunksignal = changegroup.readexactly(inpart, 4) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
257 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
258 |
if clkills: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
259 |
# preserve bookmarks that repair.strip() would otherwise strip |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
260 |
bmstore = repo._bookmarks |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
261 |
class dummybmstore(dict): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
262 |
def applychanges(self, repo, tr, changes): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
263 |
pass |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
264 |
def recordchange(self, tr): # legacy version |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
265 |
pass |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
266 |
repo._bookmarks = dummybmstore() |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
267 |
chgrpfile = repair.strip(op.ui, repo, list(clkills), backup=True, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
268 |
topic='widen') |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
269 |
repo._bookmarks = bmstore |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
270 |
if chgrpfile: |
38531
1ad873c3e4a4
narrowbundle2: when we handle a widen, mark the operation as unsafe
Augie Fackler <augie@google.com>
parents:
37613
diff
changeset
|
271 |
op._widen_uninterr = repo.ui.uninterruptable() |
1ad873c3e4a4
narrowbundle2: when we handle a widen, mark the operation as unsafe
Augie Fackler <augie@google.com>
parents:
37613
diff
changeset
|
272 |
op._widen_uninterr.__enter__() |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
273 |
# presence of _widen_bundle attribute activates widen handler later |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
274 |
op._widen_bundle = chgrpfile |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
275 |
# Set the new narrowspec if we're widening. The setnewnarrowpats() method |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
276 |
# will currently always be there when using the core+narrowhg server, but |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
277 |
# other servers may include a changespec part even when not widening (e.g. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
278 |
# because we're deepening a shallow repo). |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
279 |
if util.safehasattr(repo, 'setnewnarrowpats'): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
280 |
repo.setnewnarrowpats() |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
281 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
282 |
def handlechangegroup_widen(op, inpart): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
283 |
"""Changegroup exchange handler which restores temporarily-stripped nodes""" |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
284 |
# We saved a bundle with stripped node data we must now restore. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
285 |
# This approach is based on mercurial/repair.py@6ee26a53c111. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
286 |
repo = op.repo |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
287 |
ui = op.ui |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
288 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
289 |
chgrpfile = op._widen_bundle |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
290 |
del op._widen_bundle |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
291 |
vfs = repo.vfs |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
292 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
293 |
ui.note(_("adding branch\n")) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
294 |
f = vfs.open(chgrpfile, "rb") |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
295 |
try: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
296 |
gen = exchange.readbundle(ui, f, chgrpfile, vfs) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
297 |
if not ui.verbose: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
298 |
# silence internal shuffling chatter |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
299 |
ui.pushbuffer() |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
300 |
if isinstance(gen, bundle2.unbundle20): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
301 |
with repo.transaction('strip') as tr: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
302 |
bundle2.processbundle(repo, gen, lambda: tr) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
303 |
else: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
304 |
gen.apply(repo, 'strip', 'bundle:' + vfs.join(chgrpfile), True) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
305 |
if not ui.verbose: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
306 |
ui.popbuffer() |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
307 |
finally: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
308 |
f.close() |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
309 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
310 |
# remove undo files |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
311 |
for undovfs, undofile in repo.undofiles(): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
312 |
try: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
313 |
undovfs.unlink(undofile) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
314 |
except OSError as e: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
315 |
if e.errno != errno.ENOENT: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
316 |
ui.warn(_('error removing %s: %s\n') % |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36973
diff
changeset
|
317 |
(undovfs.join(undofile), stringutil.forcebytestr(e))) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
318 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
319 |
# Remove partial backup only if there were no exceptions |
38531
1ad873c3e4a4
narrowbundle2: when we handle a widen, mark the operation as unsafe
Augie Fackler <augie@google.com>
parents:
37613
diff
changeset
|
320 |
op._widen_uninterr.__exit__(None, None, None) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
321 |
vfs.unlink(chgrpfile) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
322 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
323 |
def setup(): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
324 |
"""Enable narrow repo support in bundle2-related extension points.""" |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
325 |
extensions.wrapfunction(bundle2, 'getrepocaps', getrepocaps_narrow) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
326 |
|
37613
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37087
diff
changeset
|
327 |
getbundleargs = wireprototypes.GETBUNDLE_ARGUMENTS |
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37087
diff
changeset
|
328 |
|
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37087
diff
changeset
|
329 |
getbundleargs['narrow'] = 'boolean' |
39383
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
330 |
getbundleargs['widen'] = 'boolean' |
37613
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37087
diff
changeset
|
331 |
getbundleargs['depth'] = 'plain' |
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37087
diff
changeset
|
332 |
getbundleargs['oldincludepats'] = 'csv' |
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37087
diff
changeset
|
333 |
getbundleargs['oldexcludepats'] = 'csv' |
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37087
diff
changeset
|
334 |
getbundleargs['includepats'] = 'csv' |
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37087
diff
changeset
|
335 |
getbundleargs['excludepats'] = 'csv' |
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37087
diff
changeset
|
336 |
getbundleargs['known'] = 'csv' |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
337 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
338 |
# Extend changegroup serving to handle requests from narrow clients. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
339 |
origcgfn = exchange.getbundle2partsmapping['changegroup'] |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
340 |
def wrappedcgfn(*args, **kwargs): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
341 |
repo = args[1] |
36125
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36124
diff
changeset
|
342 |
if repo.ui.has_section(_NARROWACL_SECTION): |
38847
98df52d5042c
exchange: make narrow ACL presence imply narrow=True
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38834
diff
changeset
|
343 |
kwargs = exchange.applynarrowacl(repo, kwargs) |
98df52d5042c
exchange: make narrow ACL presence imply narrow=True
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38834
diff
changeset
|
344 |
|
38848
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38847
diff
changeset
|
345 |
if (kwargs.get(r'narrow', False) and |
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38847
diff
changeset
|
346 |
repo.ui.configbool('experimental', 'narrowservebrokenellipses')): |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
347 |
getbundlechangegrouppart_narrow(*args, **kwargs) |
39383
c8e4eae84808
narrow: add server logic to send cg while widening without ellipsis
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38949
diff
changeset
|
348 |
elif kwargs.get(r'widen', False) and kwargs.get(r'narrow', False): |
39391
3433e8f39905
narrow: rename getbundlechangegrouppart_nonellipsis function
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39383
diff
changeset
|
349 |
getbundlechangegrouppart_widen(*args, **kwargs) |
36117
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
350 |
else: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
351 |
origcgfn(*args, **kwargs) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
352 |
exchange.getbundle2partsmapping['changegroup'] = wrappedcgfn |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
353 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
354 |
# Extend changegroup receiver so client can fixup after widen requests. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
355 |
origcghandler = bundle2.parthandlermapping['changegroup'] |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
356 |
def wrappedcghandler(op, inpart): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
357 |
origcghandler(op, inpart) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
358 |
if util.safehasattr(op, '_widen_bundle'): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
359 |
handlechangegroup_widen(op, inpart) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
360 |
wrappedcghandler.params = origcghandler.params |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
361 |
bundle2.parthandlermapping['changegroup'] = wrappedcghandler |