author | Boris Feld <boris.feld@octobus.net> |
Fri, 25 Jan 2019 14:52:31 -0500 | |
changeset 41434 | 48394923fbdc |
parent 41236 | 44a51c1c8e17 |
child 42209 | 280f7a095df8 |
permissions | -rw-r--r-- |
36079
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, |
40868
109a267acc1e
narrow: keep bookmarks temporarily stripped for as long as commits are
Martin von Zweigbergk <martinvonz@google.com>
parents:
40867
diff
changeset
|
23 |
localrepo, |
36160
9fd8c2a3db5a
narrowspec: move module into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36100
diff
changeset
|
24 |
narrowspec, |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
25 |
repair, |
38835
a232e6744ba3
narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents:
38808
diff
changeset
|
26 |
repository, |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
27 |
util, |
37613
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37084
diff
changeset
|
28 |
wireprototypes, |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
29 |
) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36967
diff
changeset
|
30 |
from mercurial.utils import ( |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36967
diff
changeset
|
31 |
stringutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36967
diff
changeset
|
32 |
) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
33 |
|
36087
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
34 |
_NARROWACL_SECTION = 'narrowhgacl' |
40755
e3792741e3fb
narrow: drop the bundle2 capability since we have server capabilities (BC)
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40492
diff
changeset
|
35 |
_CHANGESPECPART = 'narrow:changespec' |
e3792741e3fb
narrow: drop the bundle2 capability since we have server capabilities (BC)
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40492
diff
changeset
|
36 |
_SPECPART = 'narrow:spec' |
36087
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
37 |
_SPECPART_INCLUDE = 'include' |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
38 |
_SPECPART_EXCLUDE = 'exclude' |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
39 |
_KILLNODESIGNAL = 'KILL' |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
40 |
_DONESIGNAL = 'DONE' |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
41 |
_ELIDEDCSHEADER = '>20s20s20sl' # cset id, p1, p2, len(text) |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
42 |
_ELIDEDMFHEADER = '>20s20s20s20sl' # manifest id, p1, p2, link id, len(text) |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
43 |
_CSHEADERSIZE = struct.calcsize(_ELIDEDCSHEADER) |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
44 |
_MFHEADERSIZE = struct.calcsize(_ELIDEDMFHEADER) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
45 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
46 |
# 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
|
47 |
def getbundlechangegrouppart_narrow(bundler, repo, source, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
48 |
bundlecaps=None, b2caps=None, heads=None, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
49 |
common=None, **kwargs): |
38808
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
50 |
assert repo.ui.configbool('experimental', 'narrowservebrokenellipses') |
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
51 |
|
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
52 |
cgversions = b2caps.get('changegroup') |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
53 |
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
|
54 |
cgversions = [v for v in cgversions |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
55 |
if v in changegroup.supportedoutgoingversions(repo)] |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
56 |
if not cgversions: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
57 |
raise ValueError(_('no common changegroup version')) |
36354
0d5eaa97676b
narrowbundle2: drop legacy getcgkwargs variable
Augie Fackler <augie@google.com>
parents:
36349
diff
changeset
|
58 |
version = max(cgversions) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
59 |
else: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
60 |
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
|
61 |
" can't negotiate support for ellipsis nodes")) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
62 |
|
36355
cd4f13f1ea2f
narrowbundle2: use native string to get kwargs from dict
Augie Fackler <augie@google.com>
parents:
36354
diff
changeset
|
63 |
include = sorted(filter(bool, kwargs.get(r'includepats', []))) |
cd4f13f1ea2f
narrowbundle2: use native string to get kwargs from dict
Augie Fackler <augie@google.com>
parents:
36354
diff
changeset
|
64 |
exclude = sorted(filter(bool, kwargs.get(r'excludepats', []))) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
65 |
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
|
66 |
|
36357
adce75cdf8f8
narrowbundle2: more kwargs native string fixes
Augie Fackler <augie@google.com>
parents:
36355
diff
changeset
|
67 |
depth = kwargs.get(r'depth', None) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
68 |
if depth is not None: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
69 |
depth = int(depth) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
70 |
if depth < 1: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
71 |
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
|
72 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
73 |
heads = set(heads or repo.heads()) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
74 |
common = set(common or [nullid]) |
36357
adce75cdf8f8
narrowbundle2: more kwargs native string fixes
Augie Fackler <augie@google.com>
parents:
36355
diff
changeset
|
75 |
oldinclude = sorted(filter(bool, kwargs.get(r'oldincludepats', []))) |
adce75cdf8f8
narrowbundle2: more kwargs native string fixes
Augie Fackler <augie@google.com>
parents:
36355
diff
changeset
|
76 |
oldexclude = sorted(filter(bool, kwargs.get(r'oldexcludepats', []))) |
adce75cdf8f8
narrowbundle2: more kwargs native string fixes
Augie Fackler <augie@google.com>
parents:
36355
diff
changeset
|
77 |
known = {bin(n) for n in kwargs.get(r'known', [])} |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
78 |
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
|
79 |
# Steps: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
80 |
# 1. Send kill for "$known & ::common" |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
81 |
# |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
82 |
# 2. Send changegroup for ::common |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
83 |
# |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
84 |
# 3. Proceed. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
85 |
# |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
86 |
# 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
|
87 |
# 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
|
88 |
# 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
|
89 |
# |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
90 |
# a) apply this changegroup |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
91 |
# 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
|
92 |
# c) goto a |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
93 |
# |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
94 |
# 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
|
95 |
# 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
|
96 |
# 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
|
97 |
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
|
98 |
# 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
|
99 |
# 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
|
100 |
# 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
|
101 |
# single node. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
102 |
deadrevs = known |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
103 |
def genkills(): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
104 |
for r in deadrevs: |
36087
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
105 |
yield _KILLNODESIGNAL |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
106 |
yield repo.changelog.node(r) |
36087
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
107 |
yield _DONESIGNAL |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
108 |
bundler.newpart(_CHANGESPECPART, data=genkills()) |
38791
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
109 |
newvisit, newfull, newellipsis = exchange._computeellipsis( |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
110 |
repo, set(), common, known, newmatch) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
111 |
if newvisit: |
38910
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38884
diff
changeset
|
112 |
packer = changegroup.getbundler(version, repo, |
40344
2c5835b4246b
narrow: when widening, don't include manifests the client already has
Martin von Zweigbergk <martinvonz@google.com>
parents:
40072
diff
changeset
|
113 |
matcher=newmatch, |
38910
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38884
diff
changeset
|
114 |
ellipses=True, |
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38884
diff
changeset
|
115 |
shallow=depth is not None, |
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38884
diff
changeset
|
116 |
ellipsisroots=newellipsis, |
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38884
diff
changeset
|
117 |
fullnodes=newfull) |
39962
fa2395659828
narrow: pass 'narrow_widen' as source while generating changegroup
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39961
diff
changeset
|
118 |
cgdata = packer.generate(common, newvisit, False, 'narrow_widen') |
38910
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38884
diff
changeset
|
119 |
|
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38884
diff
changeset
|
120 |
part = bundler.newpart('changegroup', data=cgdata) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
121 |
part.addparam('version', version) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
122 |
if 'treemanifest' in repo.requirements: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
123 |
part.addparam('treemanifest', '1') |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
124 |
|
38791
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
125 |
visitnodes, relevant_nodes, ellipsisroots = exchange._computeellipsis( |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
126 |
repo, common, heads, set(), newmatch, depth=depth) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
127 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
128 |
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
|
129 |
if visitnodes: |
38910
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38884
diff
changeset
|
130 |
packer = changegroup.getbundler(version, repo, |
40344
2c5835b4246b
narrow: when widening, don't include manifests the client already has
Martin von Zweigbergk <martinvonz@google.com>
parents:
40072
diff
changeset
|
131 |
matcher=newmatch, |
38910
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38884
diff
changeset
|
132 |
ellipses=True, |
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38884
diff
changeset
|
133 |
shallow=depth is not None, |
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38884
diff
changeset
|
134 |
ellipsisroots=ellipsisroots, |
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38884
diff
changeset
|
135 |
fullnodes=relevant_nodes) |
39962
fa2395659828
narrow: pass 'narrow_widen' as source while generating changegroup
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39961
diff
changeset
|
136 |
cgdata = packer.generate(common, visitnodes, False, 'narrow_widen') |
38910
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38884
diff
changeset
|
137 |
|
245c58952298
changegroup: inline _packellipsischangegroup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38884
diff
changeset
|
138 |
part = bundler.newpart('changegroup', data=cgdata) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
139 |
part.addparam('version', version) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
140 |
if 'treemanifest' in repo.requirements: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
141 |
part.addparam('treemanifest', '1') |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
142 |
|
36087
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
143 |
@bundle2.parthandler(_SPECPART, (_SPECPART_INCLUDE, _SPECPART_EXCLUDE)) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
144 |
def _handlechangespec_2(op, inpart): |
36087
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
145 |
includepats = set(inpart.params.get(_SPECPART_INCLUDE, '').splitlines()) |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
146 |
excludepats = set(inpart.params.get(_SPECPART_EXCLUDE, '').splitlines()) |
39540
ce20caecacbd
narrow: validate patterns on incoming bundle2 part
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39529
diff
changeset
|
147 |
narrowspec.validatepatterns(includepats) |
ce20caecacbd
narrow: validate patterns on incoming bundle2 part
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39529
diff
changeset
|
148 |
narrowspec.validatepatterns(excludepats) |
ce20caecacbd
narrow: validate patterns on incoming bundle2 part
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39529
diff
changeset
|
149 |
|
38835
a232e6744ba3
narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents:
38808
diff
changeset
|
150 |
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:
38808
diff
changeset
|
151 |
op.repo.requirements.add(repository.NARROW_REQUIREMENT) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
152 |
op.repo._writerequirements() |
36469
28c7f580360b
narrow: reduce depedence on narrowspec.save()
Martin von Zweigbergk <martinvonz@google.com>
parents:
36464
diff
changeset
|
153 |
op.repo.setnarrowpats(includepats, excludepats) |
41236
44a51c1c8e17
narrow: move copytonarrowspec() out of setnarrowpats()
Martin von Zweigbergk <martinvonz@google.com>
parents:
41076
diff
changeset
|
154 |
narrowspec.copytoworkingcopy(op.repo) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
155 |
|
36087
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
156 |
@bundle2.parthandler(_CHANGESPECPART) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
157 |
def _handlechangespec(op, inpart): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
158 |
repo = op.repo |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
159 |
cl = repo.changelog |
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 |
# 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
|
162 |
# 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
|
163 |
# in the changegroup part. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
164 |
clkills = set() |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
165 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
166 |
# 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
|
167 |
# 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
|
168 |
# 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
|
169 |
# 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
|
170 |
chunksignal = changegroup.readexactly(inpart, 4) |
36087
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
171 |
while chunksignal != _DONESIGNAL: |
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
172 |
if chunksignal == _KILLNODESIGNAL: |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
173 |
# 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
|
174 |
ck = changegroup.readexactly(inpart, 20) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
175 |
if cl.hasnode(ck): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
176 |
clkills.add(ck) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
177 |
else: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
178 |
raise error.Abort( |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
179 |
_('unexpected changespec node chunk type: %s') % chunksignal) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
180 |
chunksignal = changegroup.readexactly(inpart, 4) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
181 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
182 |
if clkills: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
183 |
# preserve bookmarks that repair.strip() would otherwise strip |
40868
109a267acc1e
narrow: keep bookmarks temporarily stripped for as long as commits are
Martin von Zweigbergk <martinvonz@google.com>
parents:
40867
diff
changeset
|
184 |
op._bookmarksbackup = repo._bookmarks |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
185 |
class dummybmstore(dict): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
186 |
def applychanges(self, repo, tr, changes): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
187 |
pass |
40868
109a267acc1e
narrow: keep bookmarks temporarily stripped for as long as commits are
Martin von Zweigbergk <martinvonz@google.com>
parents:
40867
diff
changeset
|
188 |
localrepo.localrepository._bookmarks.set(repo, dummybmstore()) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
189 |
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
|
190 |
topic='widen') |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
191 |
if chgrpfile: |
41076
8ecb17b7f432
procutil: correct spelling of uninterruptable -> uninterruptible
Kyle Lippincott <spectral@google.com>
parents:
40868
diff
changeset
|
192 |
op._widen_uninterr = repo.ui.uninterruptible() |
38529
1ad873c3e4a4
narrowbundle2: when we handle a widen, mark the operation as unsafe
Augie Fackler <augie@google.com>
parents:
37613
diff
changeset
|
193 |
op._widen_uninterr.__enter__() |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
194 |
# 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
|
195 |
op._widen_bundle = chgrpfile |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
196 |
# 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
|
197 |
# 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
|
198 |
# 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
|
199 |
# because we're deepening a shallow repo). |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
200 |
if util.safehasattr(repo, 'setnewnarrowpats'): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
201 |
repo.setnewnarrowpats() |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
202 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
203 |
def handlechangegroup_widen(op, inpart): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
204 |
"""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
|
205 |
# 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
|
206 |
# 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
|
207 |
repo = op.repo |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
208 |
ui = op.ui |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
209 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
210 |
chgrpfile = op._widen_bundle |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
211 |
del op._widen_bundle |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
212 |
vfs = repo.vfs |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
213 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
214 |
ui.note(_("adding branch\n")) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
215 |
f = vfs.open(chgrpfile, "rb") |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
216 |
try: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
217 |
gen = exchange.readbundle(ui, f, chgrpfile, vfs) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
218 |
if not ui.verbose: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
219 |
# silence internal shuffling chatter |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
220 |
ui.pushbuffer() |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
221 |
if isinstance(gen, bundle2.unbundle20): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
222 |
with repo.transaction('strip') as tr: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
223 |
bundle2.processbundle(repo, gen, lambda: tr) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
224 |
else: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
225 |
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
|
226 |
if not ui.verbose: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
227 |
ui.popbuffer() |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
228 |
finally: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
229 |
f.close() |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
230 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
231 |
# remove undo files |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
232 |
for undovfs, undofile in repo.undofiles(): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
233 |
try: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
234 |
undovfs.unlink(undofile) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
235 |
except OSError as e: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
236 |
if e.errno != errno.ENOENT: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
237 |
ui.warn(_('error removing %s: %s\n') % |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36967
diff
changeset
|
238 |
(undovfs.join(undofile), stringutil.forcebytestr(e))) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
239 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
240 |
# Remove partial backup only if there were no exceptions |
38529
1ad873c3e4a4
narrowbundle2: when we handle a widen, mark the operation as unsafe
Augie Fackler <augie@google.com>
parents:
37613
diff
changeset
|
241 |
op._widen_uninterr.__exit__(None, None, None) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
242 |
vfs.unlink(chgrpfile) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
243 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
244 |
def setup(): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
245 |
"""Enable narrow repo support in bundle2-related extension points.""" |
37613
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37084
diff
changeset
|
246 |
getbundleargs = wireprototypes.GETBUNDLE_ARGUMENTS |
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37084
diff
changeset
|
247 |
|
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37084
diff
changeset
|
248 |
getbundleargs['narrow'] = 'boolean' |
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37084
diff
changeset
|
249 |
getbundleargs['depth'] = 'plain' |
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37084
diff
changeset
|
250 |
getbundleargs['oldincludepats'] = 'csv' |
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37084
diff
changeset
|
251 |
getbundleargs['oldexcludepats'] = 'csv' |
96d735601ca1
wireproto: move gboptsmap to wireprototypes and rename (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37084
diff
changeset
|
252 |
getbundleargs['known'] = 'csv' |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
253 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
254 |
# 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
|
255 |
origcgfn = exchange.getbundle2partsmapping['changegroup'] |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
256 |
def wrappedcgfn(*args, **kwargs): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
257 |
repo = args[1] |
36087
844f253dad5e
narrowbundle2: mark most constants as module-private
Augie Fackler <augie@google.com>
parents:
36086
diff
changeset
|
258 |
if repo.ui.has_section(_NARROWACL_SECTION): |
38807
98df52d5042c
exchange: make narrow ACL presence imply narrow=True
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38794
diff
changeset
|
259 |
kwargs = exchange.applynarrowacl(repo, kwargs) |
98df52d5042c
exchange: make narrow ACL presence imply narrow=True
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38794
diff
changeset
|
260 |
|
38808
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
261 |
if (kwargs.get(r'narrow', False) and |
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
262 |
repo.ui.configbool('experimental', 'narrowservebrokenellipses')): |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
263 |
getbundlechangegrouppart_narrow(*args, **kwargs) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
264 |
else: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
265 |
origcgfn(*args, **kwargs) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
266 |
exchange.getbundle2partsmapping['changegroup'] = wrappedcgfn |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
267 |
|
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
268 |
# 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
|
269 |
origcghandler = bundle2.parthandlermapping['changegroup'] |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
270 |
def wrappedcghandler(op, inpart): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
271 |
origcghandler(op, inpart) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
272 |
if util.safehasattr(op, '_widen_bundle'): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
273 |
handlechangegroup_widen(op, inpart) |
40868
109a267acc1e
narrow: keep bookmarks temporarily stripped for as long as commits are
Martin von Zweigbergk <martinvonz@google.com>
parents:
40867
diff
changeset
|
274 |
if util.safehasattr(op, '_bookmarksbackup'): |
109a267acc1e
narrow: keep bookmarks temporarily stripped for as long as commits are
Martin von Zweigbergk <martinvonz@google.com>
parents:
40867
diff
changeset
|
275 |
localrepo.localrepository._bookmarks.set(op.repo, |
109a267acc1e
narrow: keep bookmarks temporarily stripped for as long as commits are
Martin von Zweigbergk <martinvonz@google.com>
parents:
40867
diff
changeset
|
276 |
op._bookmarksbackup) |
109a267acc1e
narrow: keep bookmarks temporarily stripped for as long as commits are
Martin von Zweigbergk <martinvonz@google.com>
parents:
40867
diff
changeset
|
277 |
del op._bookmarksbackup |
109a267acc1e
narrow: keep bookmarks temporarily stripped for as long as commits are
Martin von Zweigbergk <martinvonz@google.com>
parents:
40867
diff
changeset
|
278 |
|
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
279 |
wrappedcghandler.params = origcghandler.params |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
280 |
bundle2.parthandlermapping['changegroup'] = wrappedcghandler |