author | Augie Fackler <augie@google.com> |
Sat, 01 Oct 2016 15:10:38 -0400 | |
changeset 30037 | cd7276f7ea83 |
parent 29819 | 8d226db31f20 |
child 30068 | a76d5ba7ac43 |
permissions | -rw-r--r-- |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
1 |
# exchange.py - utility to exchange data between repos. |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
2 |
# |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
3 |
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
4 |
# |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
5 |
# This software may be used and distributed according to the terms of the |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
6 |
# GNU General Public License version 2 or any later version. |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
7 |
|
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
8 |
from __future__ import absolute_import |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
9 |
|
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
10 |
import errno |
29341
0d83ad967bf8
cleanup: replace uses of util.(md5|sha1|sha256|sha512) with hashlib.\1
Augie Fackler <raf@durin42.com>
parents:
29064
diff
changeset
|
11 |
import hashlib |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
12 |
|
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
13 |
from .i18n import _ |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
14 |
from .node import ( |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
15 |
hex, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
16 |
nullid, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
17 |
) |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
18 |
from . import ( |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
19 |
base85, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
20 |
bookmarks as bookmod, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
21 |
bundle2, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
22 |
changegroup, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
23 |
discovery, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
24 |
error, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
25 |
lock as lockmod, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
26 |
obsolete, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
27 |
phases, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
28 |
pushkey, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
29 |
scmutil, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
30 |
sslutil, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
31 |
streamclone, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
32 |
tags, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
33 |
url as urlmod, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
34 |
util, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
35 |
) |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
36 |
|
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
37 |
urlerr = util.urlerr |
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
38 |
urlreq = util.urlreq |
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
39 |
|
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
40 |
# Maps bundle compression human names to internal representation. |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
41 |
_bundlespeccompressions = {'none': None, |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
42 |
'bzip2': 'BZ', |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
43 |
'gzip': 'GZ', |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
44 |
} |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
45 |
|
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
46 |
# Maps bundle version human names to changegroup versions. |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
47 |
_bundlespeccgversions = {'v1': '01', |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
48 |
'v2': '02', |
26756
9e272a96f764
exchange: support for streaming clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26732
diff
changeset
|
49 |
'packed1': 's1', |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
50 |
'bundle2': '02', #legacy |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
51 |
} |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
52 |
|
26646
77769354d4ad
exchange: support preserving external names when parsing bundle specs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26645
diff
changeset
|
53 |
def parsebundlespec(repo, spec, strict=True, externalnames=False): |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
54 |
"""Parse a bundle string specification into parts. |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
55 |
|
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
56 |
Bundle specifications denote a well-defined bundle/exchange format. |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
57 |
The content of a given specification should not change over time in |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
58 |
order to ensure that bundles produced by a newer version of Mercurial are |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
59 |
readable from an older version. |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
60 |
|
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
61 |
The string currently has the form: |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
62 |
|
26759
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
63 |
<compression>-<type>[;<parameter0>[;<parameter1>]] |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
64 |
|
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
65 |
Where <compression> is one of the supported compression formats |
26759
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
66 |
and <type> is (currently) a version string. A ";" can follow the type and |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
67 |
all text afterwards is interpretted as URI encoded, ";" delimited key=value |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
68 |
pairs. |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
69 |
|
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
70 |
If ``strict`` is True (the default) <compression> is required. Otherwise, |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
71 |
it is optional. |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
72 |
|
26646
77769354d4ad
exchange: support preserving external names when parsing bundle specs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26645
diff
changeset
|
73 |
If ``externalnames`` is False (the default), the human-centric names will |
77769354d4ad
exchange: support preserving external names when parsing bundle specs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26645
diff
changeset
|
74 |
be converted to their internal representation. |
77769354d4ad
exchange: support preserving external names when parsing bundle specs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26645
diff
changeset
|
75 |
|
26759
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
76 |
Returns a 3-tuple of (compression, version, parameters). Compression will |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
77 |
be ``None`` if not in strict mode and a compression isn't defined. |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
78 |
|
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
79 |
An ``InvalidBundleSpecification`` is raised when the specification is |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
80 |
not syntactically well formed. |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
81 |
|
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
82 |
An ``UnsupportedBundleSpecification`` is raised when the compression or |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
83 |
bundle type/version is not recognized. |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
84 |
|
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
85 |
Note: this function will likely eventually return a more complex data |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
86 |
structure, including bundle2 part information. |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
87 |
""" |
26759
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
88 |
def parseparams(s): |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
89 |
if ';' not in s: |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
90 |
return s, {} |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
91 |
|
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
92 |
params = {} |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
93 |
version, paramstr = s.split(';', 1) |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
94 |
|
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
95 |
for p in paramstr.split(';'): |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
96 |
if '=' not in p: |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
97 |
raise error.InvalidBundleSpecification( |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
98 |
_('invalid bundle specification: ' |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
99 |
'missing "=" in parameter: %s') % p) |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
100 |
|
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
101 |
key, value = p.split('=', 1) |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
102 |
key = urlreq.unquote(key) |
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
103 |
value = urlreq.unquote(value) |
26759
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
104 |
params[key] = value |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
105 |
|
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
106 |
return version, params |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
107 |
|
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
108 |
|
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
109 |
if strict and '-' not in spec: |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
110 |
raise error.InvalidBundleSpecification( |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
111 |
_('invalid bundle specification; ' |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
112 |
'must be prefixed with compression: %s') % spec) |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
113 |
|
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
114 |
if '-' in spec: |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
115 |
compression, version = spec.split('-', 1) |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
116 |
|
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
117 |
if compression not in _bundlespeccompressions: |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
118 |
raise error.UnsupportedBundleSpecification( |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
119 |
_('%s compression is not supported') % compression) |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
120 |
|
26759
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
121 |
version, params = parseparams(version) |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
122 |
|
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
123 |
if version not in _bundlespeccgversions: |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
124 |
raise error.UnsupportedBundleSpecification( |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
125 |
_('%s is not a recognized bundle version') % version) |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
126 |
else: |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
127 |
# Value could be just the compression or just the version, in which |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
128 |
# case some defaults are assumed (but only when not in strict mode). |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
129 |
assert not strict |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
130 |
|
26759
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
131 |
spec, params = parseparams(spec) |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
132 |
|
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
133 |
if spec in _bundlespeccompressions: |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
134 |
compression = spec |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
135 |
version = 'v1' |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
136 |
if 'generaldelta' in repo.requirements: |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
137 |
version = 'v2' |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
138 |
elif spec in _bundlespeccgversions: |
26756
9e272a96f764
exchange: support for streaming clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26732
diff
changeset
|
139 |
if spec == 'packed1': |
9e272a96f764
exchange: support for streaming clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26732
diff
changeset
|
140 |
compression = 'none' |
9e272a96f764
exchange: support for streaming clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26732
diff
changeset
|
141 |
else: |
9e272a96f764
exchange: support for streaming clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26732
diff
changeset
|
142 |
compression = 'bzip2' |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
143 |
version = spec |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
144 |
else: |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
145 |
raise error.UnsupportedBundleSpecification( |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
146 |
_('%s is not a recognized bundle specification') % spec) |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
147 |
|
26760
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
148 |
# The specification for packed1 can optionally declare the data formats |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
149 |
# required to apply it. If we see this metadata, compare against what the |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
150 |
# repo supports and error if the bundle isn't compatible. |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
151 |
if version == 'packed1' and 'requirements' in params: |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
152 |
requirements = set(params['requirements'].split(',')) |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
153 |
missingreqs = requirements - repo.supportedformats |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
154 |
if missingreqs: |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
155 |
raise error.UnsupportedBundleSpecification( |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
156 |
_('missing support for repository features: %s') % |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
157 |
', '.join(sorted(missingreqs))) |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
158 |
|
26646
77769354d4ad
exchange: support preserving external names when parsing bundle specs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26645
diff
changeset
|
159 |
if not externalnames: |
77769354d4ad
exchange: support preserving external names when parsing bundle specs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26645
diff
changeset
|
160 |
compression = _bundlespeccompressions[compression] |
77769354d4ad
exchange: support preserving external names when parsing bundle specs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26645
diff
changeset
|
161 |
version = _bundlespeccgversions[version] |
26759
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
162 |
return compression, version, params |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
163 |
|
21064
4d9d490d7bbe
bundle2: add a ui argument to readbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21063
diff
changeset
|
164 |
def readbundle(ui, fh, fname, vfs=None): |
21065
f9a9a6d63e89
bundle2: prepare readbundle to return more that one type of bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21064
diff
changeset
|
165 |
header = changegroup.readexactly(fh, 4) |
21063
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
166 |
|
21065
f9a9a6d63e89
bundle2: prepare readbundle to return more that one type of bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21064
diff
changeset
|
167 |
alg = None |
21063
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
168 |
if not fname: |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
169 |
fname = "stream" |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
170 |
if not header.startswith('HG') and header.startswith('\0'): |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
171 |
fh = changegroup.headerlessfixup(fh, header) |
21065
f9a9a6d63e89
bundle2: prepare readbundle to return more that one type of bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21064
diff
changeset
|
172 |
header = "HG10" |
f9a9a6d63e89
bundle2: prepare readbundle to return more that one type of bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21064
diff
changeset
|
173 |
alg = 'UN' |
21063
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
174 |
elif vfs: |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
175 |
fname = vfs.join(fname) |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
176 |
|
21065
f9a9a6d63e89
bundle2: prepare readbundle to return more that one type of bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21064
diff
changeset
|
177 |
magic, version = header[0:2], header[2:4] |
21063
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
178 |
|
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
179 |
if magic != 'HG': |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26566
diff
changeset
|
180 |
raise error.Abort(_('%s: not a Mercurial bundle') % fname) |
21065
f9a9a6d63e89
bundle2: prepare readbundle to return more that one type of bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21064
diff
changeset
|
181 |
if version == '10': |
f9a9a6d63e89
bundle2: prepare readbundle to return more that one type of bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21064
diff
changeset
|
182 |
if alg is None: |
f9a9a6d63e89
bundle2: prepare readbundle to return more that one type of bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21064
diff
changeset
|
183 |
alg = changegroup.readexactly(fh, 2) |
22390
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22354
diff
changeset
|
184 |
return changegroup.cg1unpacker(fh, alg) |
24649
2d15c59a001b
bundle2: detect bundle2 stream/request on /HG2./ instead of /HG2Y/
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24641
diff
changeset
|
185 |
elif version.startswith('2'): |
25640
39f0064a3079
bundle2.getunbundler: rename "header" to "magicstring"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25559
diff
changeset
|
186 |
return bundle2.getunbundler(ui, fh, magicstring=magic + version) |
26756
9e272a96f764
exchange: support for streaming clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26732
diff
changeset
|
187 |
elif version == 'S1': |
9e272a96f764
exchange: support for streaming clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26732
diff
changeset
|
188 |
return streamclone.streamcloneapplier(fh) |
21065
f9a9a6d63e89
bundle2: prepare readbundle to return more that one type of bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21064
diff
changeset
|
189 |
else: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26566
diff
changeset
|
190 |
raise error.Abort(_('%s: unknown bundle version %s') % (fname, version)) |
21063
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
191 |
|
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
192 |
def getbundlespec(ui, fh): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
193 |
"""Infer the bundlespec from a bundle file handle. |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
194 |
|
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
195 |
The input file handle is seeked and the original seek position is not |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
196 |
restored. |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
197 |
""" |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
198 |
def speccompression(alg): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
199 |
for k, v in _bundlespeccompressions.items(): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
200 |
if v == alg: |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
201 |
return k |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
202 |
return None |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
203 |
|
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
204 |
b = readbundle(ui, fh, None) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
205 |
if isinstance(b, changegroup.cg1unpacker): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
206 |
alg = b._type |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
207 |
if alg == '_truncatedBZ': |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
208 |
alg = 'BZ' |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
209 |
comp = speccompression(alg) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
210 |
if not comp: |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
211 |
raise error.Abort(_('unknown compression algorithm: %s') % alg) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
212 |
return '%s-v1' % comp |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
213 |
elif isinstance(b, bundle2.unbundle20): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
214 |
if 'Compression' in b.params: |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
215 |
comp = speccompression(b.params['Compression']) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
216 |
if not comp: |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
217 |
raise error.Abort(_('unknown compression algorithm: %s') % comp) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
218 |
else: |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
219 |
comp = 'none' |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
220 |
|
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
221 |
version = None |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
222 |
for part in b.iterparts(): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
223 |
if part.type == 'changegroup': |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
224 |
version = part.params['version'] |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
225 |
if version in ('01', '02'): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
226 |
version = 'v2' |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
227 |
else: |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
228 |
raise error.Abort(_('changegroup version %s does not have ' |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
229 |
'a known bundlespec') % version, |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
230 |
hint=_('try upgrading your Mercurial ' |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
231 |
'client')) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
232 |
|
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
233 |
if not version: |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
234 |
raise error.Abort(_('could not identify changegroup version in ' |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
235 |
'bundle')) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
236 |
|
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
237 |
return '%s-%s' % (comp, version) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
238 |
elif isinstance(b, streamclone.streamcloneapplier): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
239 |
requirements = streamclone.readbundle1header(fh)[2] |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
240 |
params = 'requirements=%s' % ','.join(sorted(requirements)) |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
241 |
return 'none-packed1;%s' % urlreq.quote(params) |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
242 |
else: |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
243 |
raise error.Abort(_('unknown bundle type: %s') % b) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
244 |
|
22346
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
245 |
def buildobsmarkerspart(bundler, markers): |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
246 |
"""add an obsmarker part to the bundler with <markers> |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
247 |
|
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
248 |
No part is created if markers is empty. |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
249 |
Raises ValueError if the bundler doesn't support any known obsmarker format. |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
250 |
""" |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
251 |
if markers: |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
252 |
remoteversions = bundle2.obsmarkersversion(bundler.capabilities) |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
253 |
version = obsolete.commonversion(remoteversions) |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
254 |
if version is None: |
26779
aaa33ec3c951
grammar: use does instead of do where appropriate
timeless@mozdev.org
parents:
26761
diff
changeset
|
255 |
raise ValueError('bundler does not support common obsmarker format') |
22346
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
256 |
stream = obsolete.encodemarkers(markers, True, version=version) |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
257 |
return bundler.newpart('obsmarkers', data=stream) |
22346
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
258 |
return None |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
259 |
|
29819
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
260 |
def _computeoutgoing(repo, heads, common): |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
261 |
"""Computes which revs are outgoing given a set of common |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
262 |
and a set of heads. |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
263 |
|
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
264 |
This is a separate function so extensions can have access to |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
265 |
the logic. |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
266 |
|
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
267 |
Returns a discovery.outgoing object. |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
268 |
""" |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
269 |
cl = repo.changelog |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
270 |
if common: |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
271 |
hasnode = cl.hasnode |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
272 |
common = [n for n in common if hasnode(n)] |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
273 |
else: |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
274 |
common = [nullid] |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
275 |
if not heads: |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
276 |
heads = cl.heads() |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
277 |
return discovery.outgoing(repo, common, heads) |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
278 |
|
29696
2db085d5f5a2
bundle2: rename the _canusebundle2 method to _forcebundle1
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29389
diff
changeset
|
279 |
def _forcebundle1(op): |
2db085d5f5a2
bundle2: rename the _canusebundle2 method to _forcebundle1
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29389
diff
changeset
|
280 |
"""return true if a pull/push must use bundle1 |
24650
b83a8f512a80
exchange: introduce a '_canusebundle2' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24649
diff
changeset
|
281 |
|
29697
6786c3f8684d
bundle2: add a devel option controling bundle version used for exchange
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29696
diff
changeset
|
282 |
This function is used to allow testing of the older bundle version""" |
6786c3f8684d
bundle2: add a devel option controling bundle version used for exchange
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29696
diff
changeset
|
283 |
ui = op.repo.ui |
6786c3f8684d
bundle2: add a devel option controling bundle version used for exchange
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29696
diff
changeset
|
284 |
forcebundle1 = False |
6786c3f8684d
bundle2: add a devel option controling bundle version used for exchange
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29696
diff
changeset
|
285 |
# The goal is this config is to allow developper to choose the bundle |
6786c3f8684d
bundle2: add a devel option controling bundle version used for exchange
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29696
diff
changeset
|
286 |
# version used during exchanged. This is especially handy during test. |
6786c3f8684d
bundle2: add a devel option controling bundle version used for exchange
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29696
diff
changeset
|
287 |
# Value is a list of bundle version to be picked from, highest version |
6786c3f8684d
bundle2: add a devel option controling bundle version used for exchange
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29696
diff
changeset
|
288 |
# should be used. |
6786c3f8684d
bundle2: add a devel option controling bundle version used for exchange
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29696
diff
changeset
|
289 |
# |
6786c3f8684d
bundle2: add a devel option controling bundle version used for exchange
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29696
diff
changeset
|
290 |
# developer config: devel.legacy.exchange |
6786c3f8684d
bundle2: add a devel option controling bundle version used for exchange
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29696
diff
changeset
|
291 |
exchange = ui.configlist('devel', 'legacy.exchange') |
29703
39537bc64442
bundle2: remove 'experimental.bundle2-exp' boolean config (BC)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29697
diff
changeset
|
292 |
forcebundle1 = 'bundle2' not in exchange and 'bundle1' in exchange |
29697
6786c3f8684d
bundle2: add a devel option controling bundle version used for exchange
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29696
diff
changeset
|
293 |
return forcebundle1 or not op.remote.capable('bundle2') |
24650
b83a8f512a80
exchange: introduce a '_canusebundle2' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24649
diff
changeset
|
294 |
|
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
295 |
class pushoperation(object): |
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
296 |
"""A object that represent a single push operation |
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
297 |
|
28456
d9d51da7a850
pushoperation: fix language issues in docstring
Nathan Goldbaum <ngoldbau@illinois.edu>
parents:
28182
diff
changeset
|
298 |
Its purpose is to carry push related state and very common operations. |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
299 |
|
28456
d9d51da7a850
pushoperation: fix language issues in docstring
Nathan Goldbaum <ngoldbau@illinois.edu>
parents:
28182
diff
changeset
|
300 |
A new pushoperation should be created at the beginning of each push and |
d9d51da7a850
pushoperation: fix language issues in docstring
Nathan Goldbaum <ngoldbau@illinois.edu>
parents:
28182
diff
changeset
|
301 |
discarded afterward. |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
302 |
""" |
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
303 |
|
22623
cd7e17aa6040
push: pass list of bookmark to `exchange.push`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22622
diff
changeset
|
304 |
def __init__(self, repo, remote, force=False, revs=None, newbranch=False, |
cd7e17aa6040
push: pass list of bookmark to `exchange.push`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22622
diff
changeset
|
305 |
bookmarks=()): |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
306 |
# repo we push from |
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
307 |
self.repo = repo |
20347
3ec5f833348e
push: ease access to current ui object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20346
diff
changeset
|
308 |
self.ui = repo.ui |
20348
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
309 |
# repo we push to |
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
310 |
self.remote = remote |
20349
89f90457979e
push: move `force` argument into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20348
diff
changeset
|
311 |
# force option provided |
89f90457979e
push: move `force` argument into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20348
diff
changeset
|
312 |
self.force = force |
20350
8c85d968ee65
push: move `revs` argument into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20349
diff
changeset
|
313 |
# revs to be pushed (None is "all") |
8c85d968ee65
push: move `revs` argument into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20349
diff
changeset
|
314 |
self.revs = revs |
22623
cd7e17aa6040
push: pass list of bookmark to `exchange.push`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22622
diff
changeset
|
315 |
# bookmark explicitly pushed |
cd7e17aa6040
push: pass list of bookmark to `exchange.push`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22622
diff
changeset
|
316 |
self.bookmarks = bookmarks |
20351
c05ad450df23
push: move `newbranch` argument into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20350
diff
changeset
|
317 |
# allow push of new branch |
c05ad450df23
push: move `newbranch` argument into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20350
diff
changeset
|
318 |
self.newbranch = newbranch |
20436
2f2e8d1c4856
push: move local lock logic in pushoperation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20435
diff
changeset
|
319 |
# did a local lock get acquired? |
2f2e8d1c4856
push: move local lock logic in pushoperation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20435
diff
changeset
|
320 |
self.locallocked = None |
21901
8612c4ab7f54
push: add a ``pushop.stepsdone`` attribute
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21899
diff
changeset
|
321 |
# step already performed |
8612c4ab7f54
push: add a ``pushop.stepsdone`` attribute
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21899
diff
changeset
|
322 |
# (used to check what steps have been already performed through bundle2) |
8612c4ab7f54
push: add a ``pushop.stepsdone`` attribute
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21899
diff
changeset
|
323 |
self.stepsdone = set() |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
324 |
# Integer version of the changegroup push result |
20439
0d3ccf285ff2
push: move push return value in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20438
diff
changeset
|
325 |
# - None means nothing to push |
0d3ccf285ff2
push: move push return value in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20438
diff
changeset
|
326 |
# - 0 means HTTP error |
0d3ccf285ff2
push: move push return value in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20438
diff
changeset
|
327 |
# - 1 means we pushed and remote head count is unchanged *or* |
0d3ccf285ff2
push: move push return value in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20438
diff
changeset
|
328 |
# we have outgoing changesets but refused to push |
0d3ccf285ff2
push: move push return value in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20438
diff
changeset
|
329 |
# - other values as described by addchangegroup() |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
330 |
self.cgresult = None |
22624
eef31f9a4c0f
push: add `pushoperation.bkresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22623
diff
changeset
|
331 |
# Boolean value for the bookmark push |
eef31f9a4c0f
push: add `pushoperation.bkresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22623
diff
changeset
|
332 |
self.bkresult = None |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
333 |
# discover.outgoing object (contains common and outgoing data) |
20440
400da8bc7786
push: move outgoing object in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20439
diff
changeset
|
334 |
self.outgoing = None |
20462
0031ef5df586
push: move `remoteheads` into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20441
diff
changeset
|
335 |
# all remote heads before the push |
0031ef5df586
push: move `remoteheads` into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20441
diff
changeset
|
336 |
self.remoteheads = None |
20464
d032417db243
push: move `incoming` into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20463
diff
changeset
|
337 |
# testable as a boolean indicating if any nodes are missing locally. |
d032417db243
push: move `incoming` into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20463
diff
changeset
|
338 |
self.incoming = None |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
339 |
# phases changes that must be pushed along side the changesets |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
340 |
self.outdatedphases = None |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
341 |
# phases changes that must be pushed if changeset push fails |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
342 |
self.fallbackoutdatedphases = None |
22034
5f57bc77657c
push: move the list of obsmarker to push into the push operation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22033
diff
changeset
|
343 |
# outgoing obsmarkers |
22035
24bb01f42e82
push: introduce a discovery step for obsmarker
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22034
diff
changeset
|
344 |
self.outobsmarkers = set() |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
345 |
# outgoing bookmarks |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
346 |
self.outbookmarks = [] |
23437
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
347 |
# transaction manager |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
348 |
self.trmanager = None |
25485
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
349 |
# map { pushkey partid -> callback handling failure} |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
350 |
# used to handle exception from mandatory pushkey part failure |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
351 |
self.pkfailcb = {} |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
352 |
|
22014
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
353 |
@util.propertycache |
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
354 |
def futureheads(self): |
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
355 |
"""future remote heads if the changeset push succeeds""" |
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
356 |
return self.outgoing.missingheads |
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
357 |
|
22015
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
358 |
@util.propertycache |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
359 |
def fallbackheads(self): |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
360 |
"""future remote heads if the changeset push fails""" |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
361 |
if self.revs is None: |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
362 |
# not target to push, all common are relevant |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
363 |
return self.outgoing.commonheads |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
364 |
unfi = self.repo.unfiltered() |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
365 |
# I want cheads = heads(::missingheads and ::commonheads) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
366 |
# (missingheads is revs with secret changeset filtered out) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
367 |
# |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
368 |
# This can be expressed as: |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
369 |
# cheads = ( (missingheads and ::commonheads) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
370 |
# + (commonheads and ::missingheads))" |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
371 |
# ) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
372 |
# |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
373 |
# while trying to push we already computed the following: |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
374 |
# common = (::commonheads) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
375 |
# missing = ((commonheads::missingheads) - commonheads) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
376 |
# |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
377 |
# We can pick: |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
378 |
# * missingheads part of common (::commonheads) |
26184
327d09f0b5d4
exchange: allow fallbackheads to use lazy set behavior
Durham Goode <durham@fb.com>
parents:
25896
diff
changeset
|
379 |
common = self.outgoing.common |
22015
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
380 |
nm = self.repo.changelog.nodemap |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
381 |
cheads = [node for node in self.revs if nm[node] in common] |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
382 |
# and |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
383 |
# * commonheads parents on missing |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
384 |
revset = unfi.set('%ln and parents(roots(%ln))', |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
385 |
self.outgoing.commonheads, |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
386 |
self.outgoing.missing) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
387 |
cheads.extend(c.node() for c in revset) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
388 |
return cheads |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
389 |
|
22016
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
390 |
@property |
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
391 |
def commonheads(self): |
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
392 |
"""set of all common heads after changeset bundle push""" |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
393 |
if self.cgresult: |
22016
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
394 |
return self.futureheads |
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
395 |
else: |
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
396 |
return self.fallbackheads |
22015
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
397 |
|
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
398 |
# mapping of message used when pushing bookmark |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
399 |
bookmsgmap = {'update': (_("updating bookmark %s\n"), |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
400 |
_('updating bookmark %s failed!\n')), |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
401 |
'export': (_("exporting bookmark %s\n"), |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
402 |
_('exporting bookmark %s failed!\n')), |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
403 |
'delete': (_("deleting remote bookmark %s\n"), |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
404 |
_('deleting remote bookmark %s failed!\n')), |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
405 |
} |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
406 |
|
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
407 |
|
26729
16e69e6b357b
exchange: add oparg to push so that extensions can wrap pushop
Sean Farley <sean@farley.io>
parents:
26700
diff
changeset
|
408 |
def push(repo, remote, force=False, revs=None, newbranch=False, bookmarks=(), |
16e69e6b357b
exchange: add oparg to push so that extensions can wrap pushop
Sean Farley <sean@farley.io>
parents:
26700
diff
changeset
|
409 |
opargs=None): |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
410 |
'''Push outgoing changesets (limited by revs) from a local |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
411 |
repository to remote. Return an integer: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
412 |
- None means nothing to push |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
413 |
- 0 means HTTP error |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
414 |
- 1 means we pushed and remote head count is unchanged *or* |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
415 |
we have outgoing changesets but refused to push |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
416 |
- other values as described by addchangegroup() |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
417 |
''' |
26729
16e69e6b357b
exchange: add oparg to push so that extensions can wrap pushop
Sean Farley <sean@farley.io>
parents:
26700
diff
changeset
|
418 |
if opargs is None: |
16e69e6b357b
exchange: add oparg to push so that extensions can wrap pushop
Sean Farley <sean@farley.io>
parents:
26700
diff
changeset
|
419 |
opargs = {} |
16e69e6b357b
exchange: add oparg to push so that extensions can wrap pushop
Sean Farley <sean@farley.io>
parents:
26700
diff
changeset
|
420 |
pushop = pushoperation(repo, remote, force, revs, newbranch, bookmarks, |
16e69e6b357b
exchange: add oparg to push so that extensions can wrap pushop
Sean Farley <sean@farley.io>
parents:
26700
diff
changeset
|
421 |
**opargs) |
20348
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
422 |
if pushop.remote.local(): |
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
423 |
missing = (set(pushop.repo.requirements) |
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
424 |
- pushop.remote.local().supported) |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
425 |
if missing: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
426 |
msg = _("required features are not" |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
427 |
" supported in the destination:" |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
428 |
" %s") % (', '.join(sorted(missing))) |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26566
diff
changeset
|
429 |
raise error.Abort(msg) |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
430 |
|
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
431 |
# there are two ways to push to remote repo: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
432 |
# |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
433 |
# addchangegroup assumes local user can lock remote |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
434 |
# repo (local filesystem, old ssh servers). |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
435 |
# |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
436 |
# unbundle assumes local user cannot lock remote repo (new ssh |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
437 |
# servers, http servers). |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
438 |
|
20348
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
439 |
if not pushop.remote.canpush(): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26566
diff
changeset
|
440 |
raise error.Abort(_("destination does not support push")) |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
441 |
# get local lock as we might write phase data |
24754
5dc5cd7abbf5
push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24752
diff
changeset
|
442 |
localwlock = locallock = None |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
443 |
try: |
24754
5dc5cd7abbf5
push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24752
diff
changeset
|
444 |
# bundle2 push may receive a reply bundle touching bookmarks or other |
5dc5cd7abbf5
push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24752
diff
changeset
|
445 |
# things requiring the wlock. Take it now to ensure proper ordering. |
5dc5cd7abbf5
push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24752
diff
changeset
|
446 |
maypushback = pushop.ui.configbool('experimental', 'bundle2.pushback') |
29696
2db085d5f5a2
bundle2: rename the _canusebundle2 method to _forcebundle1
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29389
diff
changeset
|
447 |
if (not _forcebundle1(pushop)) and maypushback: |
24754
5dc5cd7abbf5
push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24752
diff
changeset
|
448 |
localwlock = pushop.repo.wlock() |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
449 |
locallock = pushop.repo.lock() |
20436
2f2e8d1c4856
push: move local lock logic in pushoperation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20435
diff
changeset
|
450 |
pushop.locallocked = True |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25640
diff
changeset
|
451 |
except IOError as err: |
20436
2f2e8d1c4856
push: move local lock logic in pushoperation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20435
diff
changeset
|
452 |
pushop.locallocked = False |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
453 |
if err.errno != errno.EACCES: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
454 |
raise |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
455 |
# source repo cannot be locked. |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
456 |
# We do not abort the push, but just disable the local phase |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
457 |
# synchronisation. |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
458 |
msg = 'cannot lock source repository: %s\n' % err |
20347
3ec5f833348e
push: ease access to current ui object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20346
diff
changeset
|
459 |
pushop.ui.debug(msg) |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
460 |
try: |
23437
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
461 |
if pushop.locallocked: |
26672
90df14eb3d0e
exchange: use pushop.repo instead of repo
Sean Farley <sean@farley.io>
parents:
26648
diff
changeset
|
462 |
pushop.trmanager = transactionmanager(pushop.repo, |
23437
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
463 |
'push-response', |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
464 |
pushop.remote.url()) |
20924
e10000369b47
push: pass a `pushoperation` object to localrepo.checkpush
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20901
diff
changeset
|
465 |
pushop.repo.checkpush(pushop) |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
466 |
lock = None |
20348
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
467 |
unbundle = pushop.remote.capable('unbundle') |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
468 |
if not unbundle: |
20348
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
469 |
lock = pushop.remote.lock() |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
470 |
try: |
20466
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
471 |
_pushdiscovery(pushop) |
29696
2db085d5f5a2
bundle2: rename the _canusebundle2 method to _forcebundle1
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29389
diff
changeset
|
472 |
if not _forcebundle1(pushop): |
21903
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
473 |
_pushbundle2(pushop) |
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
474 |
_pushchangeset(pushop) |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
475 |
_pushsyncphase(pushop) |
20433
6af248474224
push: feed pushoperation object to _pushobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20432
diff
changeset
|
476 |
_pushobsolete(pushop) |
22224
f713de1d3916
push: update bookmarks within the remote lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22069
diff
changeset
|
477 |
_pushbookmark(pushop) |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
478 |
finally: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
479 |
if lock is not None: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
480 |
lock.release() |
23437
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
481 |
if pushop.trmanager: |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
482 |
pushop.trmanager.close() |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
483 |
finally: |
23437
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
484 |
if pushop.trmanager: |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
485 |
pushop.trmanager.release() |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
486 |
if locallock is not None: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
487 |
locallock.release() |
24754
5dc5cd7abbf5
push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24752
diff
changeset
|
488 |
if localwlock is not None: |
5dc5cd7abbf5
push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24752
diff
changeset
|
489 |
localwlock.release() |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
490 |
|
22616
cda85cfc8252
push: `exchange.push` now returns the `pushoperation` object
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22615
diff
changeset
|
491 |
return pushop |
20352
58300f61b139
push: move bookmarks exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20351
diff
changeset
|
492 |
|
22018
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
493 |
# list of steps to perform discovery before push |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
494 |
pushdiscoveryorder = [] |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
495 |
|
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
496 |
# Mapping between step name and function |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
497 |
# |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
498 |
# This exists to help extensions wrap steps if necessary |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
499 |
pushdiscoverymapping = {} |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
500 |
|
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
501 |
def pushdiscovery(stepname): |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
502 |
"""decorator for function performing discovery before push |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
503 |
|
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
504 |
The function is added to the step -> function mapping and appended to the |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
505 |
list of steps. Beware that decorated function will be added in order (this |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
506 |
may matter). |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
507 |
|
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
508 |
You can only use this decorator for a new step, if you want to wrap a step |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
509 |
from an extension, change the pushdiscovery dictionary directly.""" |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
510 |
def dec(func): |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
511 |
assert stepname not in pushdiscoverymapping |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
512 |
pushdiscoverymapping[stepname] = func |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
513 |
pushdiscoveryorder.append(stepname) |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
514 |
return func |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
515 |
return dec |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
516 |
|
20466
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
517 |
def _pushdiscovery(pushop): |
22018
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
518 |
"""Run all discovery steps""" |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
519 |
for stepname in pushdiscoveryorder: |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
520 |
step = pushdiscoverymapping[stepname] |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
521 |
step(pushop) |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
522 |
|
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
523 |
@pushdiscovery('changeset') |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
524 |
def _pushdiscoverychangeset(pushop): |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
525 |
"""discover the changeset that need to be pushed""" |
20466
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
526 |
fci = discovery.findcommonincoming |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
527 |
commoninc = fci(pushop.repo, pushop.remote, force=pushop.force) |
20466
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
528 |
common, inc, remoteheads = commoninc |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
529 |
fco = discovery.findcommonoutgoing |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
530 |
outgoing = fco(pushop.repo, pushop.remote, onlyheads=pushop.revs, |
20466
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
531 |
commoninc=commoninc, force=pushop.force) |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
532 |
pushop.outgoing = outgoing |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
533 |
pushop.remoteheads = remoteheads |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
534 |
pushop.incoming = inc |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
535 |
|
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
536 |
@pushdiscovery('phase') |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
537 |
def _pushdiscoveryphase(pushop): |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
538 |
"""discover the phase that needs to be pushed |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
539 |
|
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
540 |
(computed for both success and failure case for changesets push)""" |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
541 |
outgoing = pushop.outgoing |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
542 |
unfi = pushop.repo.unfiltered() |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
543 |
remotephases = pushop.remote.listkeys('phases') |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
544 |
publishing = remotephases.get('publishing', False) |
25337
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
545 |
if (pushop.ui.configbool('ui', '_usedassubrepo', False) |
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
546 |
and remotephases # server supports phases |
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
547 |
and not pushop.outgoing.missing # no changesets to be pushed |
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
548 |
and publishing): |
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
549 |
# When: |
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
550 |
# - this is a subrepo push |
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
551 |
# - and remote support phase |
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
552 |
# - and no changeset are to be pushed |
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
553 |
# - and remote is publishing |
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
554 |
# We may be in issue 3871 case! |
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
555 |
# We drop the possible phase synchronisation done by |
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
556 |
# courtesy to publish changesets possibly locally draft |
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
557 |
# on the remote. |
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
558 |
remotephases = {'publishing': 'True'} |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
559 |
ana = phases.analyzeremotephases(pushop.repo, |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
560 |
pushop.fallbackheads, |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
561 |
remotephases) |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
562 |
pheads, droots = ana |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
563 |
extracond = '' |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
564 |
if not publishing: |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
565 |
extracond = ' and public()' |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
566 |
revset = 'heads((%%ln::%%ln) %s)' % extracond |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
567 |
# Get the list of all revs draft on remote by public here. |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
568 |
# XXX Beware that revset break if droots is not strictly |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
569 |
# XXX root we may want to ensure it is but it is costly |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
570 |
fallback = list(unfi.set(revset, droots, pushop.fallbackheads)) |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
571 |
if not outgoing.missing: |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
572 |
future = fallback |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
573 |
else: |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
574 |
# adds changeset we are going to push as draft |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
575 |
# |
23139
e53f6b72a0e4
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23082
diff
changeset
|
576 |
# should not be necessary for publishing server, but because of an |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
577 |
# issue fixed in xxxxx we have to do it anyway. |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
578 |
fdroots = list(unfi.set('roots(%ln + %ln::)', |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
579 |
outgoing.missing, droots)) |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
580 |
fdroots = [f.node() for f in fdroots] |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
581 |
future = list(unfi.set(revset, fdroots, pushop.futureheads)) |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
582 |
pushop.outdatedphases = future |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
583 |
pushop.fallbackoutdatedphases = fallback |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
584 |
|
22035
24bb01f42e82
push: introduce a discovery step for obsmarker
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22034
diff
changeset
|
585 |
@pushdiscovery('obsmarker') |
24bb01f42e82
push: introduce a discovery step for obsmarker
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22034
diff
changeset
|
586 |
def _pushdiscoveryobsmarkers(pushop): |
22953
b1d694d3975e
obsolete: add exchange option
Durham Goode <durham@fb.com>
parents:
22937
diff
changeset
|
587 |
if (obsolete.isenabled(pushop.repo, obsolete.exchangeopt) |
22269
03cc81a28228
push: check if local and remote support evolution during discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22244
diff
changeset
|
588 |
and pushop.repo.obsstore |
03cc81a28228
push: check if local and remote support evolution during discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22244
diff
changeset
|
589 |
and 'obsolete' in pushop.remote.listkeys('namespaces')): |
22350
6d113cc7a31a
push: only push obsmarkers relevant to the "pushed subset"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22347
diff
changeset
|
590 |
repo = pushop.repo |
6d113cc7a31a
push: only push obsmarkers relevant to the "pushed subset"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22347
diff
changeset
|
591 |
# very naive computation, that can be quite expensive on big repo. |
6d113cc7a31a
push: only push obsmarkers relevant to the "pushed subset"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22347
diff
changeset
|
592 |
# However: evolution is currently slow on them anyway. |
6d113cc7a31a
push: only push obsmarkers relevant to the "pushed subset"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22347
diff
changeset
|
593 |
nodes = (c.node() for c in repo.set('::%ln', pushop.futureheads)) |
6d113cc7a31a
push: only push obsmarkers relevant to the "pushed subset"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22347
diff
changeset
|
594 |
pushop.outobsmarkers = pushop.repo.obsstore.relevantmarkers(nodes) |
22035
24bb01f42e82
push: introduce a discovery step for obsmarker
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22034
diff
changeset
|
595 |
|
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
596 |
@pushdiscovery('bookmarks') |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
597 |
def _pushdiscoverybookmarks(pushop): |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
598 |
ui = pushop.ui |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
599 |
repo = pushop.repo.unfiltered() |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
600 |
remote = pushop.remote |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
601 |
ui.debug("checking for updated bookmarks\n") |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
602 |
ancestors = () |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
603 |
if pushop.revs: |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
604 |
revnums = map(repo.changelog.rev, pushop.revs) |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
605 |
ancestors = repo.changelog.ancestors(revnums, inclusive=True) |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
606 |
remotebookmark = remote.listkeys('bookmarks') |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
607 |
|
28182
e4fe4e903e97
bookmarks: add 'hg push -B .' for pushing the active bookmark (issue4917)
liscju <piotr.listkiewicz@gmail.com>
parents:
27953
diff
changeset
|
608 |
explicit = set([repo._bookmarks.expandname(bookmark) |
e4fe4e903e97
bookmarks: add 'hg push -B .' for pushing the active bookmark (issue4917)
liscju <piotr.listkiewicz@gmail.com>
parents:
27953
diff
changeset
|
609 |
for bookmark in pushop.bookmarks]) |
22651
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
610 |
|
22622
ce6b9edee725
exchange: import bookmarks as bookmod
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22616
diff
changeset
|
611 |
comp = bookmod.compare(repo, repo._bookmarks, remotebookmark, srchex=hex) |
23081
e62c330a044f
bookmarks: explicitly track identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23047
diff
changeset
|
612 |
addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = comp |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
613 |
for b, scid, dcid in advsrc: |
22651
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
614 |
if b in explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
615 |
explicit.remove(b) |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
616 |
if not ancestors or repo[scid].rev() in ancestors: |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
617 |
pushop.outbookmarks.append((b, dcid, scid)) |
22651
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
618 |
# search added bookmark |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
619 |
for b, scid, dcid in addsrc: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
620 |
if b in explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
621 |
explicit.remove(b) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
622 |
pushop.outbookmarks.append((b, '', scid)) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
623 |
# search for overwritten bookmark |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
624 |
for b, scid, dcid in advdst + diverge + differ: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
625 |
if b in explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
626 |
explicit.remove(b) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
627 |
pushop.outbookmarks.append((b, dcid, scid)) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
628 |
# search for bookmark to delete |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
629 |
for b, scid, dcid in adddst: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
630 |
if b in explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
631 |
explicit.remove(b) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
632 |
# treat as "deleted locally" |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
633 |
pushop.outbookmarks.append((b, dcid, '')) |
23082
0fc4686de1d7
exchange: don't report failure from identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23081
diff
changeset
|
634 |
# identical bookmarks shouldn't get reported |
0fc4686de1d7
exchange: don't report failure from identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23081
diff
changeset
|
635 |
for b, scid, dcid in same: |
0fc4686de1d7
exchange: don't report failure from identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23081
diff
changeset
|
636 |
if b in explicit: |
0fc4686de1d7
exchange: don't report failure from identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23081
diff
changeset
|
637 |
explicit.remove(b) |
22651
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
638 |
|
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
639 |
if explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
640 |
explicit = sorted(explicit) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
641 |
# we should probably list all of them |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
642 |
ui.warn(_('bookmark %s does not exist on the local ' |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
643 |
'or remote repository!\n') % explicit[0]) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
644 |
pushop.bkresult = 2 |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
645 |
|
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
646 |
pushop.outbookmarks.sort() |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
647 |
|
20465
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
648 |
def _pushcheckoutgoing(pushop): |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
649 |
outgoing = pushop.outgoing |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
650 |
unfi = pushop.repo.unfiltered() |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
651 |
if not outgoing.missing: |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
652 |
# nothing to push |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
653 |
scmutil.nochangesfound(unfi.ui, unfi, outgoing.excluded) |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
654 |
return False |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
655 |
# something to push |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
656 |
if not pushop.force: |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
657 |
# if repo.obsstore == False --> no obsolete |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
658 |
# then, save the iteration |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
659 |
if unfi.obsstore: |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
660 |
# this message are here for 80 char limit reason |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
661 |
mso = _("push includes obsolete changeset: %s!") |
22628
2805d23e1f88
exchange: remove a broken i18n abuse
Matt Mackall <mpm@selenic.com>
parents:
22625
diff
changeset
|
662 |
mst = {"unstable": _("push includes unstable changeset: %s!"), |
2805d23e1f88
exchange: remove a broken i18n abuse
Matt Mackall <mpm@selenic.com>
parents:
22625
diff
changeset
|
663 |
"bumped": _("push includes bumped changeset: %s!"), |
2805d23e1f88
exchange: remove a broken i18n abuse
Matt Mackall <mpm@selenic.com>
parents:
22625
diff
changeset
|
664 |
"divergent": _("push includes divergent changeset: %s!")} |
20465
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
665 |
# If we are to push if there is at least one |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
666 |
# obsolete or unstable changeset in missing, at |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
667 |
# least one of the missinghead will be obsolete or |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
668 |
# unstable. So checking heads only is ok |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
669 |
for node in outgoing.missingheads: |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
670 |
ctx = unfi[node] |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
671 |
if ctx.obsolete(): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26566
diff
changeset
|
672 |
raise error.Abort(mso % ctx) |
20465
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
673 |
elif ctx.troubled(): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26566
diff
changeset
|
674 |
raise error.Abort(mst[ctx.troubles()[0]] % ctx) |
25836
dede675dc0c1
bookmarks: mark internal-only config option
Matt Mackall <mpm@selenic.com>
parents:
25668
diff
changeset
|
675 |
|
26935
c4a7bbc78c74
exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents:
26855
diff
changeset
|
676 |
discovery.checkheads(pushop) |
20465
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
677 |
return True |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
678 |
|
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
679 |
# List of names of steps to perform for an outgoing bundle2, order matters. |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
680 |
b2partsgenorder = [] |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
681 |
|
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
682 |
# Mapping between step name and function |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
683 |
# |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
684 |
# This exists to help extensions wrap steps if necessary |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
685 |
b2partsgenmapping = {} |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
686 |
|
24731
88a36edefea5
bundle2: add an 'idx' argument to the 'b2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24697
diff
changeset
|
687 |
def b2partsgenerator(stepname, idx=None): |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
688 |
"""decorator for function generating bundle2 part |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
689 |
|
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
690 |
The function is added to the step -> function mapping and appended to the |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
691 |
list of steps. Beware that decorated functions will be added in order |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
692 |
(this may matter). |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
693 |
|
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
694 |
You can only use this decorator for new steps, if you want to wrap a step |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
695 |
from an extension, attack the b2partsgenmapping dictionary directly.""" |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
696 |
def dec(func): |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
697 |
assert stepname not in b2partsgenmapping |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
698 |
b2partsgenmapping[stepname] = func |
24731
88a36edefea5
bundle2: add an 'idx' argument to the 'b2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24697
diff
changeset
|
699 |
if idx is None: |
88a36edefea5
bundle2: add an 'idx' argument to the 'b2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24697
diff
changeset
|
700 |
b2partsgenorder.append(stepname) |
88a36edefea5
bundle2: add an 'idx' argument to the 'b2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24697
diff
changeset
|
701 |
else: |
88a36edefea5
bundle2: add an 'idx' argument to the 'b2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24697
diff
changeset
|
702 |
b2partsgenorder.insert(idx, stepname) |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
703 |
return func |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
704 |
return dec |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
705 |
|
26428
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
706 |
def _pushb2ctxcheckheads(pushop, bundler): |
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
707 |
"""Generate race condition checking parts |
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
708 |
|
26781
1aee2ab0f902
spelling: trivial spell checking
Mads Kiilerich <madski@unity3d.com>
parents:
26779
diff
changeset
|
709 |
Exists as an independent function to aid extensions |
26428
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
710 |
""" |
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
711 |
if not pushop.force: |
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
712 |
bundler.newpart('check:heads', data=iter(pushop.remoteheads)) |
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
713 |
|
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
714 |
@b2partsgenerator('changeset') |
21899
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
715 |
def _pushb2ctx(pushop, bundler): |
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
716 |
"""handle changegroup push through bundle2 |
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
717 |
|
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
718 |
addchangegroup result is stored in the ``pushop.cgresult`` attribute. |
21899
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
719 |
""" |
21902
7a7def851ba0
push: use `stepsdone` to control changegroup push through bundle10 or bundle20
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21901
diff
changeset
|
720 |
if 'changesets' in pushop.stepsdone: |
7a7def851ba0
push: use `stepsdone` to control changegroup push through bundle10 or bundle20
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21901
diff
changeset
|
721 |
return |
7a7def851ba0
push: use `stepsdone` to control changegroup push through bundle10 or bundle20
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21901
diff
changeset
|
722 |
pushop.stepsdone.add('changesets') |
21899
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
723 |
# Send known heads to the server for race detection. |
21903
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
724 |
if not _pushcheckoutgoing(pushop): |
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
725 |
return |
28876
79b8f052ee51
localrepo: refactor prepushoutgoinghook to take a pushop
Mads Kiilerich <madski@unity3d.com>
parents:
28668
diff
changeset
|
726 |
pushop.repo.prepushoutgoinghooks(pushop) |
26428
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
727 |
|
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
728 |
_pushb2ctxcheckheads(pushop, bundler) |
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
729 |
|
23180
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
730 |
b2caps = bundle2.bundle2caps(pushop.remote) |
28668
07f1fbf1f758
exchange: make _pushb2ctx() look more like _getbundlechangegrouppart()
Martin von Zweigbergk <martinvonz@google.com>
parents:
28667
diff
changeset
|
731 |
version = '01' |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
732 |
cgversions = b2caps.get('changegroup') |
28668
07f1fbf1f758
exchange: make _pushb2ctx() look more like _getbundlechangegrouppart()
Martin von Zweigbergk <martinvonz@google.com>
parents:
28667
diff
changeset
|
733 |
if cgversions: # 3.1 and 3.2 ship with an empty value |
27751
a40e2f7fe49d
changegroup: hide packermap behind methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
27738
diff
changeset
|
734 |
cgversions = [v for v in cgversions |
27953
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27938
diff
changeset
|
735 |
if v in changegroup.supportedoutgoingversions( |
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27938
diff
changeset
|
736 |
pushop.repo)] |
23180
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
737 |
if not cgversions: |
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
738 |
raise ValueError(_('no common changegroup version')) |
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
739 |
version = max(cgversions) |
28668
07f1fbf1f758
exchange: make _pushb2ctx() look more like _getbundlechangegrouppart()
Martin von Zweigbergk <martinvonz@google.com>
parents:
28667
diff
changeset
|
740 |
cg = changegroup.getlocalchangegroupraw(pushop.repo, 'push', |
07f1fbf1f758
exchange: make _pushb2ctx() look more like _getbundlechangegrouppart()
Martin von Zweigbergk <martinvonz@google.com>
parents:
28667
diff
changeset
|
741 |
pushop.outgoing, |
07f1fbf1f758
exchange: make _pushb2ctx() look more like _getbundlechangegrouppart()
Martin von Zweigbergk <martinvonz@google.com>
parents:
28667
diff
changeset
|
742 |
version=version) |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
743 |
cgpart = bundler.newpart('changegroup', data=cg) |
28668
07f1fbf1f758
exchange: make _pushb2ctx() look more like _getbundlechangegrouppart()
Martin von Zweigbergk <martinvonz@google.com>
parents:
28667
diff
changeset
|
744 |
if cgversions: |
23180
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
745 |
cgpart.addparam('version', version) |
27938
cabac7dfc621
exchange: set 'treemanifest' param on pushed changegroups too
Martin von Zweigbergk <martinvonz@google.com>
parents:
27883
diff
changeset
|
746 |
if 'treemanifest' in pushop.repo.requirements: |
cabac7dfc621
exchange: set 'treemanifest' param on pushed changegroups too
Martin von Zweigbergk <martinvonz@google.com>
parents:
27883
diff
changeset
|
747 |
cgpart.addparam('treemanifest', '1') |
21899
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
748 |
def handlereply(op): |
23139
e53f6b72a0e4
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23082
diff
changeset
|
749 |
"""extract addchangegroup returns from server reply""" |
21899
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
750 |
cgreplies = op.records.getreplies(cgpart.id) |
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
751 |
assert len(cgreplies['changegroup']) == 1 |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
752 |
pushop.cgresult = cgreplies['changegroup'][0]['return'] |
21899
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
753 |
return handlereply |
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
754 |
|
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
755 |
@b2partsgenerator('phase') |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
756 |
def _pushb2phases(pushop, bundler): |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
757 |
"""handle phase push through bundle2""" |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
758 |
if 'phases' in pushop.stepsdone: |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
759 |
return |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
760 |
b2caps = bundle2.bundle2caps(pushop.remote) |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
761 |
if not 'pushkey' in b2caps: |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
762 |
return |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
763 |
pushop.stepsdone.add('phases') |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
764 |
part2node = [] |
25502
bd41c19383db
phases: abort the whole push if phases fail to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25501
diff
changeset
|
765 |
|
bd41c19383db
phases: abort the whole push if phases fail to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25501
diff
changeset
|
766 |
def handlefailure(pushop, exc): |
bd41c19383db
phases: abort the whole push if phases fail to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25501
diff
changeset
|
767 |
targetid = int(exc.partid) |
bd41c19383db
phases: abort the whole push if phases fail to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25501
diff
changeset
|
768 |
for partid, node in part2node: |
bd41c19383db
phases: abort the whole push if phases fail to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25501
diff
changeset
|
769 |
if partid == targetid: |
bd41c19383db
phases: abort the whole push if phases fail to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25501
diff
changeset
|
770 |
raise error.Abort(_('updating %s to public failed') % node) |
bd41c19383db
phases: abort the whole push if phases fail to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25501
diff
changeset
|
771 |
|
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
772 |
enc = pushkey.encode |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
773 |
for newremotehead in pushop.outdatedphases: |
25502
bd41c19383db
phases: abort the whole push if phases fail to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25501
diff
changeset
|
774 |
part = bundler.newpart('pushkey') |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
775 |
part.addparam('namespace', enc('phases')) |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
776 |
part.addparam('key', enc(newremotehead.hex())) |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
777 |
part.addparam('old', enc(str(phases.draft))) |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
778 |
part.addparam('new', enc(str(phases.public))) |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
779 |
part2node.append((part.id, newremotehead)) |
25502
bd41c19383db
phases: abort the whole push if phases fail to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25501
diff
changeset
|
780 |
pushop.pkfailcb[part.id] = handlefailure |
bd41c19383db
phases: abort the whole push if phases fail to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25501
diff
changeset
|
781 |
|
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
782 |
def handlereply(op): |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
783 |
for partid, node in part2node: |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
784 |
partrep = op.records.getreplies(partid) |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
785 |
results = partrep['pushkey'] |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
786 |
assert len(results) <= 1 |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
787 |
msg = None |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
788 |
if not results: |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
789 |
msg = _('server ignored update of %s to public!\n') % node |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
790 |
elif not int(results[0]['return']): |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
791 |
msg = _('updating %s to public failed!\n') % node |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
792 |
if msg is not None: |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
793 |
pushop.ui.warn(msg) |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
794 |
return handlereply |
21904
5fbccbcc07ea
bundle2-push: introduce a list of part generating functions
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21903
diff
changeset
|
795 |
|
22347
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
796 |
@b2partsgenerator('obsmarkers') |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
797 |
def _pushb2obsmarkers(pushop, bundler): |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
798 |
if 'obsmarkers' in pushop.stepsdone: |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
799 |
return |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
800 |
remoteversions = bundle2.obsmarkersversion(bundler.capabilities) |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
801 |
if obsolete.commonversion(remoteversions) is None: |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
802 |
return |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
803 |
pushop.stepsdone.add('obsmarkers') |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
804 |
if pushop.outobsmarkers: |
25118
e632a2429982
obsolete: sort obsmarkers during exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24878
diff
changeset
|
805 |
markers = sorted(pushop.outobsmarkers) |
e632a2429982
obsolete: sort obsmarkers during exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24878
diff
changeset
|
806 |
buildobsmarkerspart(bundler, markers) |
22347
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
807 |
|
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
808 |
@b2partsgenerator('bookmarks') |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
809 |
def _pushb2bookmarks(pushop, bundler): |
25895
c30b739c322f
exchange: s/phase/bookmark/ in _pushb2bookmarks()
Martin von Zweigbergk <martinvonz@google.com>
parents:
25836
diff
changeset
|
810 |
"""handle bookmark push through bundle2""" |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
811 |
if 'bookmarks' in pushop.stepsdone: |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
812 |
return |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
813 |
b2caps = bundle2.bundle2caps(pushop.remote) |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
814 |
if 'pushkey' not in b2caps: |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
815 |
return |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
816 |
pushop.stepsdone.add('bookmarks') |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
817 |
part2book = [] |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
818 |
enc = pushkey.encode |
25501
a99fee62611d
bookmarks: abort the whole push if bookmarks fails to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25485
diff
changeset
|
819 |
|
a99fee62611d
bookmarks: abort the whole push if bookmarks fails to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25485
diff
changeset
|
820 |
def handlefailure(pushop, exc): |
a99fee62611d
bookmarks: abort the whole push if bookmarks fails to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25485
diff
changeset
|
821 |
targetid = int(exc.partid) |
a99fee62611d
bookmarks: abort the whole push if bookmarks fails to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25485
diff
changeset
|
822 |
for partid, book, action in part2book: |
a99fee62611d
bookmarks: abort the whole push if bookmarks fails to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25485
diff
changeset
|
823 |
if partid == targetid: |
a99fee62611d
bookmarks: abort the whole push if bookmarks fails to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25485
diff
changeset
|
824 |
raise error.Abort(bookmsgmap[action][1].rstrip() % book) |
a99fee62611d
bookmarks: abort the whole push if bookmarks fails to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25485
diff
changeset
|
825 |
# we should not be called for part we did not generated |
a99fee62611d
bookmarks: abort the whole push if bookmarks fails to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25485
diff
changeset
|
826 |
assert False |
a99fee62611d
bookmarks: abort the whole push if bookmarks fails to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25485
diff
changeset
|
827 |
|
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
828 |
for book, old, new in pushop.outbookmarks: |
25501
a99fee62611d
bookmarks: abort the whole push if bookmarks fails to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25485
diff
changeset
|
829 |
part = bundler.newpart('pushkey') |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
830 |
part.addparam('namespace', enc('bookmarks')) |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
831 |
part.addparam('key', enc(book)) |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
832 |
part.addparam('old', enc(old)) |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
833 |
part.addparam('new', enc(new)) |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
834 |
action = 'update' |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
835 |
if not old: |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
836 |
action = 'export' |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
837 |
elif not new: |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
838 |
action = 'delete' |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
839 |
part2book.append((part.id, book, action)) |
25501
a99fee62611d
bookmarks: abort the whole push if bookmarks fails to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25485
diff
changeset
|
840 |
pushop.pkfailcb[part.id] = handlefailure |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
841 |
|
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
842 |
def handlereply(op): |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
843 |
ui = pushop.ui |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
844 |
for partid, book, action in part2book: |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
845 |
partrep = op.records.getreplies(partid) |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
846 |
results = partrep['pushkey'] |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
847 |
assert len(results) <= 1 |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
848 |
if not results: |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
849 |
pushop.ui.warn(_('server ignored bookmark %s update\n') % book) |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
850 |
else: |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
851 |
ret = int(results[0]['return']) |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
852 |
if ret: |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
853 |
ui.status(bookmsgmap[action][0] % book) |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
854 |
else: |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
855 |
ui.warn(bookmsgmap[action][1] % book) |
22649
1d7a2422b90c
push: set bkresult when pushing bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22645
diff
changeset
|
856 |
if pushop.bkresult is not None: |
1d7a2422b90c
push: set bkresult when pushing bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22645
diff
changeset
|
857 |
pushop.bkresult = 1 |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
858 |
return handlereply |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
859 |
|
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
860 |
|
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
861 |
def _pushbundle2(pushop): |
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
862 |
"""push data to the remote using bundle2 |
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
863 |
|
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
864 |
The only currently supported type of data is changegroup but this will |
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
865 |
evolve in the future.""" |
21644
17755dd8c509
bundle2: introduce a bundle2caps function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21643
diff
changeset
|
866 |
bundler = bundle2.bundle20(pushop.ui, bundle2.bundle2caps(pushop.remote)) |
23439
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
867 |
pushback = (pushop.trmanager |
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
868 |
and pushop.ui.configbool('experimental', 'bundle2.pushback')) |
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
869 |
|
21142
15039ce3e4a3
bundle2: include client capabilities in the pushed bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21141
diff
changeset
|
870 |
# create reply capability |
23439
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
871 |
capsblob = bundle2.encodecaps(bundle2.getrepocaps(pushop.repo, |
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
872 |
allowpushback=pushback)) |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
873 |
bundler.newpart('replycaps', data=capsblob) |
21904
5fbccbcc07ea
bundle2-push: introduce a list of part generating functions
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21903
diff
changeset
|
874 |
replyhandlers = [] |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
875 |
for partgenname in b2partsgenorder: |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
876 |
partgen = b2partsgenmapping[partgenname] |
21904
5fbccbcc07ea
bundle2-push: introduce a list of part generating functions
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21903
diff
changeset
|
877 |
ret = partgen(pushop, bundler) |
21941
dab31290c7eb
bundle2: only use callable return as reply handler
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21906
diff
changeset
|
878 |
if callable(ret): |
dab31290c7eb
bundle2: only use callable return as reply handler
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21906
diff
changeset
|
879 |
replyhandlers.append(ret) |
21904
5fbccbcc07ea
bundle2-push: introduce a list of part generating functions
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21903
diff
changeset
|
880 |
# do not push if nothing to push |
21903
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
881 |
if bundler.nbparts <= 1: |
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
882 |
return |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
883 |
stream = util.chunkbuffer(bundler.getchunks()) |
21182
08c84fd99aac
bundle2: catch UnknownPartError during local push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21181
diff
changeset
|
884 |
try: |
25485
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
885 |
try: |
29659
b8f9cdca8807
exchange: correctly specify url to unbundle (issue5145)
Augie Fackler <augie@google.com>
parents:
29389
diff
changeset
|
886 |
reply = pushop.remote.unbundle( |
b8f9cdca8807
exchange: correctly specify url to unbundle (issue5145)
Augie Fackler <augie@google.com>
parents:
29389
diff
changeset
|
887 |
stream, ['force'], pushop.remote.url()) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25640
diff
changeset
|
888 |
except error.BundleValueError as exc: |
29389
98e8313dcd9e
i18n: translate abort messages
liscju <piotr.listkiewicz@gmail.com>
parents:
29376
diff
changeset
|
889 |
raise error.Abort(_('missing support for %s') % exc) |
25485
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
890 |
try: |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
891 |
trgetter = None |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
892 |
if pushback: |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
893 |
trgetter = pushop.trmanager.transaction |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
894 |
op = bundle2.processbundle(pushop.repo, reply, trgetter) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25640
diff
changeset
|
895 |
except error.BundleValueError as exc: |
29389
98e8313dcd9e
i18n: translate abort messages
liscju <piotr.listkiewicz@gmail.com>
parents:
29376
diff
changeset
|
896 |
raise error.Abort(_('missing support for %s') % exc) |
26829
58f1645f72c3
bundle2: attribute remote failures to remote (issue4788)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26781
diff
changeset
|
897 |
except bundle2.AbortFromPart as exc: |
58f1645f72c3
bundle2: attribute remote failures to remote (issue4788)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26781
diff
changeset
|
898 |
pushop.ui.status(_('remote: %s\n') % exc) |
58f1645f72c3
bundle2: attribute remote failures to remote (issue4788)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26781
diff
changeset
|
899 |
raise error.Abort(_('push failed on remote'), hint=exc.hint) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25640
diff
changeset
|
900 |
except error.PushkeyFailed as exc: |
25485
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
901 |
partid = int(exc.partid) |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
902 |
if partid not in pushop.pkfailcb: |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
903 |
raise |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
904 |
pushop.pkfailcb[partid](pushop, exc) |
21904
5fbccbcc07ea
bundle2-push: introduce a list of part generating functions
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21903
diff
changeset
|
905 |
for rephand in replyhandlers: |
5fbccbcc07ea
bundle2-push: introduce a list of part generating functions
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21903
diff
changeset
|
906 |
rephand(op) |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
907 |
|
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
908 |
def _pushchangeset(pushop): |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
909 |
"""Make the actual push of changeset bundle to remote repo""" |
21902
7a7def851ba0
push: use `stepsdone` to control changegroup push through bundle10 or bundle20
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21901
diff
changeset
|
910 |
if 'changesets' in pushop.stepsdone: |
7a7def851ba0
push: use `stepsdone` to control changegroup push through bundle10 or bundle20
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21901
diff
changeset
|
911 |
return |
7a7def851ba0
push: use `stepsdone` to control changegroup push through bundle10 or bundle20
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21901
diff
changeset
|
912 |
pushop.stepsdone.add('changesets') |
21903
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
913 |
if not _pushcheckoutgoing(pushop): |
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
914 |
return |
28876
79b8f052ee51
localrepo: refactor prepushoutgoinghook to take a pushop
Mads Kiilerich <madski@unity3d.com>
parents:
28668
diff
changeset
|
915 |
pushop.repo.prepushoutgoinghooks(pushop) |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
916 |
outgoing = pushop.outgoing |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
917 |
unbundle = pushop.remote.capable('unbundle') |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
918 |
# TODO: get bundlecaps from remote |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
919 |
bundlecaps = None |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
920 |
# create a changegroup from local |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
921 |
if pushop.revs is None and not (outgoing.excluded |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
922 |
or pushop.repo.changelog.filteredrevs): |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
923 |
# push everything, |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
924 |
# use the fast path, no race possible on push |
22390
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22354
diff
changeset
|
925 |
bundler = changegroup.cg1packer(pushop.repo, bundlecaps) |
20925
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20924
diff
changeset
|
926 |
cg = changegroup.getsubset(pushop.repo, |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20924
diff
changeset
|
927 |
outgoing, |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20924
diff
changeset
|
928 |
bundler, |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20924
diff
changeset
|
929 |
'push', |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20924
diff
changeset
|
930 |
fastpath=True) |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
931 |
else: |
22390
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22354
diff
changeset
|
932 |
cg = changegroup.getlocalchangegroup(pushop.repo, 'push', outgoing, |
20928
91b47139d0cb
localrepo: move the getlocalbundle method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20925
diff
changeset
|
933 |
bundlecaps) |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
934 |
|
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
935 |
# apply changegroup to remote |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
936 |
if unbundle: |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
937 |
# local repo finds heads on server, finds out what |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
938 |
# revs it must push. once revs transferred, if server |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
939 |
# finds it has different heads (someone else won |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
940 |
# commit/push race), server aborts. |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
941 |
if pushop.force: |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
942 |
remoteheads = ['force'] |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
943 |
else: |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
944 |
remoteheads = pushop.remoteheads |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
945 |
# ssh: return remote's addchangegroup() |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
946 |
# http: return remote's addchangegroup() or 0 for error |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
947 |
pushop.cgresult = pushop.remote.unbundle(cg, remoteheads, |
21761
b2dc026a9bd2
push: restore contents of HG_URL for hooks (issue4268)
Matt Mackall <mpm@selenic.com>
parents:
21259
diff
changeset
|
948 |
pushop.repo.url()) |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
949 |
else: |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
950 |
# we return an integer indicating remote head count |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
951 |
# change |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
952 |
pushop.cgresult = pushop.remote.addchangegroup(cg, 'push', |
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
953 |
pushop.repo.url()) |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
954 |
|
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
955 |
def _pushsyncphase(pushop): |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
956 |
"""synchronise phase information locally and remotely""" |
20468
7d0bbb6dd730
push: extract new common set computation from phase synchronisation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20467
diff
changeset
|
957 |
cheads = pushop.commonheads |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
958 |
# even when we don't push, exchanging phase data is useful |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
959 |
remotephases = pushop.remote.listkeys('phases') |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
960 |
if (pushop.ui.configbool('ui', '_usedassubrepo', False) |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
961 |
and remotephases # server supports phases |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
962 |
and pushop.cgresult is None # nothing was pushed |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
963 |
and remotephases.get('publishing', False)): |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
964 |
# When: |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
965 |
# - this is a subrepo push |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
966 |
# - and remote support phase |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
967 |
# - and no changeset was pushed |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
968 |
# - and remote is publishing |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
969 |
# We may be in issue 3871 case! |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
970 |
# We drop the possible phase synchronisation done by |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
971 |
# courtesy to publish changesets possibly locally draft |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
972 |
# on the remote. |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
973 |
remotephases = {'publishing': 'True'} |
21012
c827a0028e6f
exchange: restore truncated comment
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21005
diff
changeset
|
974 |
if not remotephases: # old server or public only reply from non-publishing |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
975 |
_localphasemove(pushop, cheads) |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
976 |
# don't push any phase data as there is nothing to push |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
977 |
else: |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
978 |
ana = phases.analyzeremotephases(pushop.repo, cheads, |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
979 |
remotephases) |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
980 |
pheads, droots = ana |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
981 |
### Apply remote phase on local |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
982 |
if remotephases.get('publishing', False): |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
983 |
_localphasemove(pushop, cheads) |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
984 |
else: # publish = False |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
985 |
_localphasemove(pushop, pheads) |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
986 |
_localphasemove(pushop, cheads, phases.draft) |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
987 |
### Apply local phase on remote |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
988 |
|
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
989 |
if pushop.cgresult: |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
990 |
if 'phases' in pushop.stepsdone: |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
991 |
# phases already pushed though bundle2 |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
992 |
return |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
993 |
outdated = pushop.outdatedphases |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
994 |
else: |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
995 |
outdated = pushop.fallbackoutdatedphases |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
996 |
|
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
997 |
pushop.stepsdone.add('phases') |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
998 |
|
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
999 |
# filter heads already turned public by the push |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
1000 |
outdated = [c for c in outdated if c.node() not in pheads] |
23376
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
1001 |
# fallback to independent pushkey command |
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
1002 |
for newremotehead in outdated: |
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
1003 |
r = pushop.remote.pushkey('phases', |
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
1004 |
newremotehead.hex(), |
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
1005 |
str(phases.draft), |
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
1006 |
str(phases.public)) |
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
1007 |
if not r: |
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
1008 |
pushop.ui.warn(_('updating %s to public failed!\n') |
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
1009 |
% newremotehead) |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1010 |
|
20438
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1011 |
def _localphasemove(pushop, nodes, phase=phases.public): |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1012 |
"""move <nodes> to <phase> in the local source repo""" |
23437
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
1013 |
if pushop.trmanager: |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
1014 |
phases.advanceboundary(pushop.repo, |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
1015 |
pushop.trmanager.transaction(), |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
1016 |
phase, |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
1017 |
nodes) |
20438
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1018 |
else: |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1019 |
# repo is not locked, do not change any phases! |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1020 |
# Informs the user that phases should have been moved when |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1021 |
# applicable. |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1022 |
actualmoves = [n for n in nodes if phase < pushop.repo[n].phase()] |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1023 |
phasestr = phases.phasenames[phase] |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1024 |
if actualmoves: |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1025 |
pushop.ui.status(_('cannot lock source repo, skipping ' |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1026 |
'local %s phase update\n') % phasestr) |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1027 |
|
20433
6af248474224
push: feed pushoperation object to _pushobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20432
diff
changeset
|
1028 |
def _pushobsolete(pushop): |
20434
e009e59e4566
push: drop now outdated comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20433
diff
changeset
|
1029 |
"""utility function to push obsolete markers to a remote""" |
22036
f1528ef123f4
push: use stepsdone for obsmarkers push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22035
diff
changeset
|
1030 |
if 'obsmarkers' in pushop.stepsdone: |
f1528ef123f4
push: use stepsdone for obsmarkers push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22035
diff
changeset
|
1031 |
return |
20433
6af248474224
push: feed pushoperation object to _pushobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20432
diff
changeset
|
1032 |
repo = pushop.repo |
6af248474224
push: feed pushoperation object to _pushobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20432
diff
changeset
|
1033 |
remote = pushop.remote |
22036
f1528ef123f4
push: use stepsdone for obsmarkers push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22035
diff
changeset
|
1034 |
pushop.stepsdone.add('obsmarkers') |
22350
6d113cc7a31a
push: only push obsmarkers relevant to the "pushed subset"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22347
diff
changeset
|
1035 |
if pushop.outobsmarkers: |
25559
521c1a3139c9
push: only say we are trying to push obsmarkers when we actually try
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25516
diff
changeset
|
1036 |
pushop.ui.debug('try to push obsolete markers to remote\n') |
20432
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1037 |
rslts = [] |
25118
e632a2429982
obsolete: sort obsmarkers during exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24878
diff
changeset
|
1038 |
remotedata = obsolete._pushkeyescape(sorted(pushop.outobsmarkers)) |
20432
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1039 |
for key in sorted(remotedata, reverse=True): |
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1040 |
# reverse sort to ensure we end with dump0 |
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1041 |
data = remotedata[key] |
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1042 |
rslts.append(remote.pushkey('obsolete', key, '', data)) |
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1043 |
if [r for r in rslts if not r]: |
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1044 |
msg = _('failed to push some obsolete markers!\n') |
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1045 |
repo.ui.warn(msg) |
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1046 |
|
20431
bebf8b8479f3
push: feed pushoperation object to _pushbookmark function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20352
diff
changeset
|
1047 |
def _pushbookmark(pushop): |
20352
58300f61b139
push: move bookmarks exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20351
diff
changeset
|
1048 |
"""Update bookmark position on remote""" |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
1049 |
if pushop.cgresult == 0 or 'bookmarks' in pushop.stepsdone: |
22228
a3dc2d385490
pushbookmark: do not attempt to update bookmarks if the push failed (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22227
diff
changeset
|
1050 |
return |
22240
d092f4b68fb6
push: use stepsdone to control bookmark push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22239
diff
changeset
|
1051 |
pushop.stepsdone.add('bookmarks') |
20431
bebf8b8479f3
push: feed pushoperation object to _pushbookmark function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20352
diff
changeset
|
1052 |
ui = pushop.ui |
bebf8b8479f3
push: feed pushoperation object to _pushbookmark function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20352
diff
changeset
|
1053 |
remote = pushop.remote |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1054 |
|
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
1055 |
for b, old, new in pushop.outbookmarks: |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1056 |
action = 'update' |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1057 |
if not old: |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1058 |
action = 'export' |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1059 |
elif not new: |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1060 |
action = 'delete' |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
1061 |
if remote.pushkey('bookmarks', b, old, new): |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1062 |
ui.status(bookmsgmap[action][0] % b) |
20352
58300f61b139
push: move bookmarks exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20351
diff
changeset
|
1063 |
else: |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1064 |
ui.warn(bookmsgmap[action][1] % b) |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1065 |
# discovery can have set the value form invalid entry |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1066 |
if pushop.bkresult is not None: |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1067 |
pushop.bkresult = 1 |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1068 |
|
20472
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1069 |
class pulloperation(object): |
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1070 |
"""A object that represent a single pull operation |
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1071 |
|
23219
61cd79ac4b99
exchange: swap "push" for "pull" in pulloperation docstring
Mike Edgar <adgar@google.com>
parents:
23218
diff
changeset
|
1072 |
It purpose is to carry pull related state and very common operation. |
20472
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1073 |
|
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
1074 |
A new should be created at the beginning of each pull and discarded |
20472
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1075 |
afterward. |
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1076 |
""" |
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1077 |
|
25446
b5311068077e
pull: prevent race condition in bookmark update when using -B (issue4689)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25445
diff
changeset
|
1078 |
def __init__(self, repo, remote, heads=None, force=False, bookmarks=(), |
26448
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1079 |
remotebookmarks=None, streamclonerequested=None): |
20596
004a1744088d
exchange: fix docs for pulloperation
Siddharth Agarwal <sid0@fb.com>
parents:
20489
diff
changeset
|
1080 |
# repo we pull into |
20472
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1081 |
self.repo = repo |
20596
004a1744088d
exchange: fix docs for pulloperation
Siddharth Agarwal <sid0@fb.com>
parents:
20489
diff
changeset
|
1082 |
# repo we pull from |
20473
1516daaca632
pull: move `remote` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20472
diff
changeset
|
1083 |
self.remote = remote |
20474
c9bceafc61be
pull: move `heads` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20473
diff
changeset
|
1084 |
# revision we try to pull (None is "all") |
c9bceafc61be
pull: move `heads` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20473
diff
changeset
|
1085 |
self.heads = heads |
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1086 |
# bookmark pulled explicitly |
29376
113d0b23321a
bookmarks: add 'hg pull -B .' for pulling the active bookmark (issue5258)
liscju <piotr.listkiewicz@gmail.com>
parents:
29341
diff
changeset
|
1087 |
self.explicitbookmarks = [repo._bookmarks.expandname(bookmark) |
113d0b23321a
bookmarks: add 'hg pull -B .' for pulling the active bookmark (issue5258)
liscju <piotr.listkiewicz@gmail.com>
parents:
29341
diff
changeset
|
1088 |
for bookmark in bookmarks] |
20475
b79b405583af
pull: move `force` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20474
diff
changeset
|
1089 |
# do we force pull? |
b79b405583af
pull: move `force` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20474
diff
changeset
|
1090 |
self.force = force |
26448
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1091 |
# whether a streaming clone was requested |
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1092 |
self.streamclonerequested = streamclonerequested |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1093 |
# transaction manager |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1094 |
self.trmanager = None |
20487
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1095 |
# set of common changeset between local and remote before pull |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1096 |
self.common = None |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1097 |
# set of pulled head |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1098 |
self.rheads = None |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
1099 |
# list of missing changeset to fetch remotely |
20488
76e66654f74e
pull: move `fetch` subset into the object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20487
diff
changeset
|
1100 |
self.fetch = None |
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1101 |
# remote bookmarks data |
25446
b5311068077e
pull: prevent race condition in bookmark update when using -B (issue4689)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25445
diff
changeset
|
1102 |
self.remotebookmarks = remotebookmarks |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
1103 |
# result of changegroup pulling (used as return code by pull) |
20898
f295b2ac3579
pull: move return code in the pull operation object
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20878
diff
changeset
|
1104 |
self.cgresult = None |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1105 |
# list of step already done |
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1106 |
self.stepsdone = set() |
26689
2c9f15366982
exchange: record that we attempted to fetch a clone bundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26688
diff
changeset
|
1107 |
# Whether we attempted a clone from pre-generated bundles. |
2c9f15366982
exchange: record that we attempted to fetch a clone bundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26688
diff
changeset
|
1108 |
self.clonebundleattempted = False |
20487
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1109 |
|
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1110 |
@util.propertycache |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1111 |
def pulledsubset(self): |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1112 |
"""heads of the set of changeset target by the pull""" |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1113 |
# compute target subset |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1114 |
if self.heads is None: |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1115 |
# We pulled every thing possible |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1116 |
# sync on everything common |
20878
09e7118715eb
pull: prevent duplicated entry in `op.pulledsubset`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20596
diff
changeset
|
1117 |
c = set(self.common) |
09e7118715eb
pull: prevent duplicated entry in `op.pulledsubset`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20596
diff
changeset
|
1118 |
ret = list(self.common) |
09e7118715eb
pull: prevent duplicated entry in `op.pulledsubset`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20596
diff
changeset
|
1119 |
for n in self.rheads: |
09e7118715eb
pull: prevent duplicated entry in `op.pulledsubset`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20596
diff
changeset
|
1120 |
if n not in c: |
09e7118715eb
pull: prevent duplicated entry in `op.pulledsubset`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20596
diff
changeset
|
1121 |
ret.append(n) |
09e7118715eb
pull: prevent duplicated entry in `op.pulledsubset`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20596
diff
changeset
|
1122 |
return ret |
20487
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1123 |
else: |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1124 |
# We pulled a specific subset |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1125 |
# sync on this subset |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1126 |
return self.heads |
20477
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
1127 |
|
26464
9a7fc6d48898
exchange: expose bundle2 capabilities on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26462
diff
changeset
|
1128 |
@util.propertycache |
26465
eda32ee9962f
exchange: expose bundle2 availability on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26464
diff
changeset
|
1129 |
def canusebundle2(self): |
29696
2db085d5f5a2
bundle2: rename the _canusebundle2 method to _forcebundle1
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29389
diff
changeset
|
1130 |
return not _forcebundle1(self) |
26465
eda32ee9962f
exchange: expose bundle2 availability on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26464
diff
changeset
|
1131 |
|
eda32ee9962f
exchange: expose bundle2 availability on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26464
diff
changeset
|
1132 |
@util.propertycache |
26464
9a7fc6d48898
exchange: expose bundle2 capabilities on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26462
diff
changeset
|
1133 |
def remotebundle2caps(self): |
9a7fc6d48898
exchange: expose bundle2 capabilities on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26462
diff
changeset
|
1134 |
return bundle2.bundle2caps(self.remote) |
9a7fc6d48898
exchange: expose bundle2 capabilities on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26462
diff
changeset
|
1135 |
|
20477
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
1136 |
def gettransaction(self): |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1137 |
# deprecated; talk to trmanager directly |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1138 |
return self.trmanager.transaction() |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1139 |
|
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1140 |
class transactionmanager(object): |
23543
4dd8a6a1240d
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23439
diff
changeset
|
1141 |
"""An object to manage the life cycle of a transaction |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1142 |
|
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1143 |
It creates the transaction on demand and calls the appropriate hooks when |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1144 |
closing the transaction.""" |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1145 |
def __init__(self, repo, source, url): |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1146 |
self.repo = repo |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1147 |
self.source = source |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1148 |
self.url = url |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1149 |
self._tr = None |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1150 |
|
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1151 |
def transaction(self): |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1152 |
"""Return an open transaction object, constructing if necessary""" |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1153 |
if not self._tr: |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1154 |
trname = '%s\n%s' % (self.source, util.hidepassword(self.url)) |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1155 |
self._tr = self.repo.transaction(trname) |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1156 |
self._tr.hookargs['source'] = self.source |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1157 |
self._tr.hookargs['url'] = self.url |
20477
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
1158 |
return self._tr |
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
1159 |
|
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1160 |
def close(self): |
20477
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
1161 |
"""close transaction if created""" |
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
1162 |
if self._tr is not None: |
23222
6b7e60fb0b38
exchange: use the postclose API on transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23219
diff
changeset
|
1163 |
self._tr.close() |
20477
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
1164 |
|
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1165 |
def release(self): |
20477
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
1166 |
"""release transaction if created""" |
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
1167 |
if self._tr is not None: |
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
1168 |
self._tr.release() |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1169 |
|
26448
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1170 |
def pull(repo, remote, heads=None, force=False, bookmarks=(), opargs=None, |
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1171 |
streamclonerequested=None): |
26440
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1172 |
"""Fetch repository data from a remote. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1173 |
|
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1174 |
This is the main function used to retrieve data from a remote repository. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1175 |
|
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1176 |
``repo`` is the local repository to clone into. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1177 |
``remote`` is a peer instance. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1178 |
``heads`` is an iterable of revisions we want to pull. ``None`` (the |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1179 |
default) means to pull everything from the remote. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1180 |
``bookmarks`` is an iterable of bookmarks requesting to be pulled. By |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1181 |
default, all remote bookmarks are pulled. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1182 |
``opargs`` are additional keyword arguments to pass to ``pulloperation`` |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1183 |
initialization. |
26448
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1184 |
``streamclonerequested`` is a boolean indicating whether a "streaming |
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1185 |
clone" is requested. A "streaming clone" is essentially a raw file copy |
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1186 |
of revlogs from the server. This only works when the local repository is |
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1187 |
empty. The default value of ``None`` means to respect the server |
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1188 |
configuration for preferring stream clones. |
26440
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1189 |
|
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1190 |
Returns the ``pulloperation`` created for this pull. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1191 |
""" |
25445
1457c1f28c92
pull: allow a generic way to pass parameters to the pull operation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25444
diff
changeset
|
1192 |
if opargs is None: |
1457c1f28c92
pull: allow a generic way to pass parameters to the pull operation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25444
diff
changeset
|
1193 |
opargs = {} |
1457c1f28c92
pull: allow a generic way to pass parameters to the pull operation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25444
diff
changeset
|
1194 |
pullop = pulloperation(repo, remote, heads, force, bookmarks=bookmarks, |
26448
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1195 |
streamclonerequested=streamclonerequested, **opargs) |
20473
1516daaca632
pull: move `remote` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20472
diff
changeset
|
1196 |
if pullop.remote.local(): |
1516daaca632
pull: move `remote` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20472
diff
changeset
|
1197 |
missing = set(pullop.remote.requirements) - pullop.repo.supported |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1198 |
if missing: |
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1199 |
msg = _("required features are not" |
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1200 |
" supported in the destination:" |
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1201 |
" %s") % (', '.join(sorted(missing))) |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26566
diff
changeset
|
1202 |
raise error.Abort(msg) |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1203 |
|
20472
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1204 |
lock = pullop.repo.lock() |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1205 |
try: |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1206 |
pullop.trmanager = transactionmanager(repo, 'pull', remote.url()) |
26462
3b0ec09192ae
streamclone: rename and document maybeperformstreamclone()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26458
diff
changeset
|
1207 |
streamclone.maybeperformlegacystreamclone(pullop) |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1208 |
# This should ideally be in _pullbundle2(). However, it needs to run |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1209 |
# before discovery to avoid extra work. |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1210 |
_maybeapplyclonebundle(pullop) |
20900
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1211 |
_pulldiscovery(pullop) |
26465
eda32ee9962f
exchange: expose bundle2 availability on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26464
diff
changeset
|
1212 |
if pullop.canusebundle2: |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1213 |
_pullbundle2(pullop) |
22653
d94f5bec9c8e
pull: perform the todostep inside functions handling old way of pulling
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22651
diff
changeset
|
1214 |
_pullchangeset(pullop) |
d94f5bec9c8e
pull: perform the todostep inside functions handling old way of pulling
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22651
diff
changeset
|
1215 |
_pullphase(pullop) |
22655
f48ac29c2a9e
pull: retrieve bookmarks before obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22654
diff
changeset
|
1216 |
_pullbookmarks(pullop) |
22653
d94f5bec9c8e
pull: perform the todostep inside functions handling old way of pulling
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22651
diff
changeset
|
1217 |
_pullobsolete(pullop) |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1218 |
pullop.trmanager.close() |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1219 |
finally: |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1220 |
pullop.trmanager.release() |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1221 |
lock.release() |
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1222 |
|
22693
68439b154063
exchange: have `pull` return the pulloperation object
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22666
diff
changeset
|
1223 |
return pullop |
20476
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1224 |
|
22936
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1225 |
# list of steps to perform discovery before pull |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1226 |
pulldiscoveryorder = [] |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1227 |
|
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1228 |
# Mapping between step name and function |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1229 |
# |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1230 |
# This exists to help extensions wrap steps if necessary |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1231 |
pulldiscoverymapping = {} |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1232 |
|
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1233 |
def pulldiscovery(stepname): |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1234 |
"""decorator for function performing discovery before pull |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1235 |
|
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1236 |
The function is added to the step -> function mapping and appended to the |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1237 |
list of steps. Beware that decorated function will be added in order (this |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1238 |
may matter). |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1239 |
|
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1240 |
You can only use this decorator for a new step, if you want to wrap a step |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1241 |
from an extension, change the pulldiscovery dictionary directly.""" |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1242 |
def dec(func): |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1243 |
assert stepname not in pulldiscoverymapping |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1244 |
pulldiscoverymapping[stepname] = func |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1245 |
pulldiscoveryorder.append(stepname) |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1246 |
return func |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1247 |
return dec |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1248 |
|
20900
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1249 |
def _pulldiscovery(pullop): |
22936
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1250 |
"""Run all discovery steps""" |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1251 |
for stepname in pulldiscoveryorder: |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1252 |
step = pulldiscoverymapping[stepname] |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1253 |
step(pullop) |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1254 |
|
25369
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1255 |
@pulldiscovery('b1:bookmarks') |
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1256 |
def _pullbookmarkbundle1(pullop): |
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1257 |
"""fetch bookmark data in bundle1 case |
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1258 |
|
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1259 |
If not using bundle2, we have to fetch bookmarks before changeset |
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1260 |
discovery to reduce the chance and impact of race conditions.""" |
25443
443d3decbdde
pull: skip pulling remote bookmarks with bundle1 if a value already exist
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25423
diff
changeset
|
1261 |
if pullop.remotebookmarks is not None: |
443d3decbdde
pull: skip pulling remote bookmarks with bundle1 if a value already exist
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25423
diff
changeset
|
1262 |
return |
26465
eda32ee9962f
exchange: expose bundle2 availability on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26464
diff
changeset
|
1263 |
if pullop.canusebundle2 and 'listkeys' in pullop.remotebundle2caps: |
25479
f00a63a43c4b
bundle2: pull bookmark the old way if no bundle2 listkeys support (issue4701)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25446
diff
changeset
|
1264 |
# all known bundle2 servers now support listkeys, but lets be nice with |
f00a63a43c4b
bundle2: pull bookmark the old way if no bundle2 listkeys support (issue4701)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25446
diff
changeset
|
1265 |
# new implementation. |
f00a63a43c4b
bundle2: pull bookmark the old way if no bundle2 listkeys support (issue4701)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25446
diff
changeset
|
1266 |
return |
f00a63a43c4b
bundle2: pull bookmark the old way if no bundle2 listkeys support (issue4701)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25446
diff
changeset
|
1267 |
pullop.remotebookmarks = pullop.remote.listkeys('bookmarks') |
25369
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1268 |
|
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1269 |
|
22936
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1270 |
@pulldiscovery('changegroup') |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1271 |
def _pulldiscoverychangegroup(pullop): |
20900
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1272 |
"""discovery phase for the pull |
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1273 |
|
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1274 |
Current handle changeset discovery only, will change handle all discovery |
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1275 |
at some point.""" |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1276 |
tmp = discovery.findcommonincoming(pullop.repo, |
20900
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1277 |
pullop.remote, |
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1278 |
heads=pullop.heads, |
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1279 |
force=pullop.force) |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1280 |
common, fetch, rheads = tmp |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1281 |
nm = pullop.repo.unfiltered().changelog.nodemap |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1282 |
if fetch and rheads: |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1283 |
# If a remote heads in filtered locally, lets drop it from the unknown |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1284 |
# remote heads and put in back in common. |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1285 |
# |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1286 |
# This is a hackish solution to catch most of "common but locally |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1287 |
# hidden situation". We do not performs discovery on unfiltered |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1288 |
# repository because it end up doing a pathological amount of round |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1289 |
# trip for w huge amount of changeset we do not care about. |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1290 |
# |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1291 |
# If a set of such "common but filtered" changeset exist on the server |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1292 |
# but are not including a remote heads, we'll not be able to detect it, |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1293 |
scommon = set(common) |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1294 |
filteredrheads = [] |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1295 |
for n in rheads: |
23975
3b7088a5c64c
discovery: properly exclude locally known but filtered heads
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23890
diff
changeset
|
1296 |
if n in nm: |
3b7088a5c64c
discovery: properly exclude locally known but filtered heads
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23890
diff
changeset
|
1297 |
if n not in scommon: |
3b7088a5c64c
discovery: properly exclude locally known but filtered heads
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23890
diff
changeset
|
1298 |
common.append(n) |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1299 |
else: |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1300 |
filteredrheads.append(n) |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1301 |
if not filteredrheads: |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1302 |
fetch = [] |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1303 |
rheads = filteredrheads |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1304 |
pullop.common = common |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1305 |
pullop.fetch = fetch |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1306 |
pullop.rheads = rheads |
20900
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1307 |
|
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1308 |
def _pullbundle2(pullop): |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1309 |
"""pull data using bundle2 |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1310 |
|
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1311 |
For now, the only supported data are changegroup.""" |
21645
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
1312 |
kwargs = {'bundlecaps': caps20to10(pullop.repo)} |
26471
41dd7b2c7e15
exchange: add "streaming all changes" to bundle2 pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26465
diff
changeset
|
1313 |
|
41dd7b2c7e15
exchange: add "streaming all changes" to bundle2 pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26465
diff
changeset
|
1314 |
streaming, streamreqs = streamclone.canperformstreamclone(pullop) |
41dd7b2c7e15
exchange: add "streaming all changes" to bundle2 pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26465
diff
changeset
|
1315 |
|
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1316 |
# pulling changegroup |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1317 |
pullop.stepsdone.add('changegroup') |
21259
ab5040cd5749
bundle2: fix bundle2 pulling all revs on empty pulls
Durham Goode <durham@fb.com>
parents:
21258
diff
changeset
|
1318 |
|
ab5040cd5749
bundle2: fix bundle2 pulling all revs on empty pulls
Durham Goode <durham@fb.com>
parents:
21258
diff
changeset
|
1319 |
kwargs['common'] = pullop.common |
ab5040cd5749
bundle2: fix bundle2 pulling all revs on empty pulls
Durham Goode <durham@fb.com>
parents:
21258
diff
changeset
|
1320 |
kwargs['heads'] = pullop.heads or pullop.rheads |
22352
dc371d1f0de1
pull: use the "cg" argument when pulling a bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22350
diff
changeset
|
1321 |
kwargs['cg'] = pullop.fetch |
26464
9a7fc6d48898
exchange: expose bundle2 capabilities on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26462
diff
changeset
|
1322 |
if 'listkeys' in pullop.remotebundle2caps: |
29064
9dc27a334fb1
bundle2: properly request phases during getbundle
Mike Hommey <mh@glandium.org>
parents:
28883
diff
changeset
|
1323 |
kwargs['listkeys'] = ['phases'] |
25444
1d1fd5d44f57
pull: skip pulling remote bookmarks with bundle2 if a value already exists
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25443
diff
changeset
|
1324 |
if pullop.remotebookmarks is None: |
1d1fd5d44f57
pull: skip pulling remote bookmarks with bundle2 if a value already exists
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25443
diff
changeset
|
1325 |
# make sure to always includes bookmark data when migrating |
1d1fd5d44f57
pull: skip pulling remote bookmarks with bundle2 if a value already exists
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25443
diff
changeset
|
1326 |
# `hg incoming --bundle` to using this function. |
1d1fd5d44f57
pull: skip pulling remote bookmarks with bundle2 if a value already exists
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25443
diff
changeset
|
1327 |
kwargs['listkeys'].append('bookmarks') |
26690
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1328 |
|
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1329 |
# If this is a full pull / clone and the server supports the clone bundles |
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1330 |
# feature, tell the server whether we attempted a clone bundle. The |
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1331 |
# presence of this flag indicates the client supports clone bundles. This |
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1332 |
# will enable the server to treat clients that support clone bundles |
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1333 |
# differently from those that don't. |
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1334 |
if (pullop.remote.capable('clonebundles') |
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1335 |
and pullop.heads is None and list(pullop.common) == [nullid]): |
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1336 |
kwargs['cbattempted'] = pullop.clonebundleattempted |
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1337 |
|
26471
41dd7b2c7e15
exchange: add "streaming all changes" to bundle2 pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26465
diff
changeset
|
1338 |
if streaming: |
41dd7b2c7e15
exchange: add "streaming all changes" to bundle2 pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26465
diff
changeset
|
1339 |
pullop.repo.ui.status(_('streaming all changes\n')) |
41dd7b2c7e15
exchange: add "streaming all changes" to bundle2 pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26465
diff
changeset
|
1340 |
elif not pullop.fetch: |
21258
71931b789424
exchange: fix bad indentation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21257
diff
changeset
|
1341 |
pullop.repo.ui.status(_("no changes found\n")) |
71931b789424
exchange: fix bad indentation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21257
diff
changeset
|
1342 |
pullop.cgresult = 0 |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1343 |
else: |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1344 |
if pullop.heads is None and list(pullop.common) == [nullid]: |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1345 |
pullop.repo.ui.status(_("requesting all changes\n")) |
22953
b1d694d3975e
obsolete: add exchange option
Durham Goode <durham@fb.com>
parents:
22937
diff
changeset
|
1346 |
if obsolete.isenabled(pullop.repo, obsolete.exchangeopt): |
26464
9a7fc6d48898
exchange: expose bundle2 capabilities on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26462
diff
changeset
|
1347 |
remoteversions = bundle2.obsmarkersversion(pullop.remotebundle2caps) |
22354
a89add6c6b2f
bundle2: pull obsmarkers relevant to the pulled set through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22353
diff
changeset
|
1348 |
if obsolete.commonversion(remoteversions) is not None: |
a89add6c6b2f
bundle2: pull obsmarkers relevant to the pulled set through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22353
diff
changeset
|
1349 |
kwargs['obsmarkers'] = True |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1350 |
pullop.stepsdone.add('obsmarkers') |
21159
024f38f6d5f6
bundle2: allow extensions to extend the getbundle request
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21158
diff
changeset
|
1351 |
_pullbundle2extraprepare(pullop, kwargs) |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1352 |
bundle = pullop.remote.getbundle('pull', **kwargs) |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1353 |
try: |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1354 |
op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25640
diff
changeset
|
1355 |
except error.BundleValueError as exc: |
29389
98e8313dcd9e
i18n: translate abort messages
liscju <piotr.listkiewicz@gmail.com>
parents:
29376
diff
changeset
|
1356 |
raise error.Abort(_('missing support for %s') % exc) |
21259
ab5040cd5749
bundle2: fix bundle2 pulling all revs on empty pulls
Durham Goode <durham@fb.com>
parents:
21258
diff
changeset
|
1357 |
|
ab5040cd5749
bundle2: fix bundle2 pulling all revs on empty pulls
Durham Goode <durham@fb.com>
parents:
21258
diff
changeset
|
1358 |
if pullop.fetch: |
23890
7817059917d0
pullbundle2: extract addchangegroup result combining into its own function
Eric Sumner <ericsumner@fb.com>
parents:
23848
diff
changeset
|
1359 |
results = [cg['return'] for cg in op.records['changegroup']] |
7817059917d0
pullbundle2: extract addchangegroup result combining into its own function
Eric Sumner <ericsumner@fb.com>
parents:
23848
diff
changeset
|
1360 |
pullop.cgresult = changegroup.combineresults(results) |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1361 |
|
21658
0696ca0a685b
pull: when remote supports it, pull phase data alongside changesets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21657
diff
changeset
|
1362 |
# processing phases change |
0696ca0a685b
pull: when remote supports it, pull phase data alongside changesets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21657
diff
changeset
|
1363 |
for namespace, value in op.records['listkeys']: |
0696ca0a685b
pull: when remote supports it, pull phase data alongside changesets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21657
diff
changeset
|
1364 |
if namespace == 'phases': |
0696ca0a685b
pull: when remote supports it, pull phase data alongside changesets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21657
diff
changeset
|
1365 |
_pullapplyphases(pullop, value) |
0696ca0a685b
pull: when remote supports it, pull phase data alongside changesets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21657
diff
changeset
|
1366 |
|
22656
c9276945eba3
pull: retrieve bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22655
diff
changeset
|
1367 |
# processing bookmark update |
c9276945eba3
pull: retrieve bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22655
diff
changeset
|
1368 |
for namespace, value in op.records['listkeys']: |
c9276945eba3
pull: retrieve bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22655
diff
changeset
|
1369 |
if namespace == 'bookmarks': |
c9276945eba3
pull: retrieve bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22655
diff
changeset
|
1370 |
pullop.remotebookmarks = value |
25444
1d1fd5d44f57
pull: skip pulling remote bookmarks with bundle2 if a value already exists
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25443
diff
changeset
|
1371 |
|
1d1fd5d44f57
pull: skip pulling remote bookmarks with bundle2 if a value already exists
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25443
diff
changeset
|
1372 |
# bookmark data were either already there or pulled in the bundle |
1d1fd5d44f57
pull: skip pulling remote bookmarks with bundle2 if a value already exists
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25443
diff
changeset
|
1373 |
if pullop.remotebookmarks is not None: |
1d1fd5d44f57
pull: skip pulling remote bookmarks with bundle2 if a value already exists
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25443
diff
changeset
|
1374 |
_pullbookmarks(pullop) |
22656
c9276945eba3
pull: retrieve bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22655
diff
changeset
|
1375 |
|
21159
024f38f6d5f6
bundle2: allow extensions to extend the getbundle request
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21158
diff
changeset
|
1376 |
def _pullbundle2extraprepare(pullop, kwargs): |
024f38f6d5f6
bundle2: allow extensions to extend the getbundle request
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21158
diff
changeset
|
1377 |
"""hook function so that extensions can extend the getbundle call""" |
024f38f6d5f6
bundle2: allow extensions to extend the getbundle request
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21158
diff
changeset
|
1378 |
pass |
024f38f6d5f6
bundle2: allow extensions to extend the getbundle request
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21158
diff
changeset
|
1379 |
|
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1380 |
def _pullchangeset(pullop): |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1381 |
"""pull changeset from unbundle into the local repo""" |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1382 |
# We delay the open of the transaction as late as possible so we |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1383 |
# don't open transaction for nothing or you break future useful |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1384 |
# rollback call |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1385 |
if 'changegroup' in pullop.stepsdone: |
22653
d94f5bec9c8e
pull: perform the todostep inside functions handling old way of pulling
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22651
diff
changeset
|
1386 |
return |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1387 |
pullop.stepsdone.add('changegroup') |
20899
d62319f91cb7
pull: move the cgresult logic in _pullchangeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20898
diff
changeset
|
1388 |
if not pullop.fetch: |
23217
2f12ac53b528
exchange: fix indentation in _pullchangeset
Mike Edgar <adgar@google.com>
parents:
23208
diff
changeset
|
1389 |
pullop.repo.ui.status(_("no changes found\n")) |
2f12ac53b528
exchange: fix indentation in _pullchangeset
Mike Edgar <adgar@google.com>
parents:
23208
diff
changeset
|
1390 |
pullop.cgresult = 0 |
2f12ac53b528
exchange: fix indentation in _pullchangeset
Mike Edgar <adgar@google.com>
parents:
23208
diff
changeset
|
1391 |
return |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1392 |
pullop.gettransaction() |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1393 |
if pullop.heads is None and list(pullop.common) == [nullid]: |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1394 |
pullop.repo.ui.status(_("requesting all changes\n")) |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1395 |
elif pullop.heads is None and pullop.remote.capable('changegroupsubset'): |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1396 |
# issue1320, avoid a race if remote changed after discovery |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1397 |
pullop.heads = pullop.rheads |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1398 |
|
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1399 |
if pullop.remote.capable('getbundle'): |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1400 |
# TODO: get bundlecaps from remote |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1401 |
cg = pullop.remote.getbundle('pull', common=pullop.common, |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1402 |
heads=pullop.heads or pullop.rheads) |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1403 |
elif pullop.heads is None: |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1404 |
cg = pullop.remote.changegroup(pullop.fetch, 'pull') |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1405 |
elif not pullop.remote.capable('changegroupsubset'): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26566
diff
changeset
|
1406 |
raise error.Abort(_("partial pull cannot be done because " |
21554
7bcf4adadd2d
exchange: fix indentation level
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21259
diff
changeset
|
1407 |
"other repository doesn't support " |
7bcf4adadd2d
exchange: fix indentation level
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21259
diff
changeset
|
1408 |
"changegroupsubset.")) |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1409 |
else: |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1410 |
cg = pullop.remote.changegroupsubset(pullop.fetch, pullop.heads, 'pull') |
26700
dbc3d945ba36
exchange: use cg?unpacker.apply() instead of changegroup.addchangegroup()
Augie Fackler <augie@google.com>
parents:
26690
diff
changeset
|
1411 |
pullop.cgresult = cg.apply(pullop.repo, 'pull', pullop.remote.url()) |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1412 |
|
20486
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1413 |
def _pullphase(pullop): |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1414 |
# Get remote phases data from remote |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1415 |
if 'phases' in pullop.stepsdone: |
22653
d94f5bec9c8e
pull: perform the todostep inside functions handling old way of pulling
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22651
diff
changeset
|
1416 |
return |
21654
ddf9a00c1239
pull: split remote phases retrieval from actual application
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21645
diff
changeset
|
1417 |
remotephases = pullop.remote.listkeys('phases') |
ddf9a00c1239
pull: split remote phases retrieval from actual application
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21645
diff
changeset
|
1418 |
_pullapplyphases(pullop, remotephases) |
ddf9a00c1239
pull: split remote phases retrieval from actual application
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21645
diff
changeset
|
1419 |
|
ddf9a00c1239
pull: split remote phases retrieval from actual application
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21645
diff
changeset
|
1420 |
def _pullapplyphases(pullop, remotephases): |
ddf9a00c1239
pull: split remote phases retrieval from actual application
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21645
diff
changeset
|
1421 |
"""apply phase movement from observed remote state""" |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1422 |
if 'phases' in pullop.stepsdone: |
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1423 |
return |
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1424 |
pullop.stepsdone.add('phases') |
20486
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1425 |
publishing = bool(remotephases.get('publishing', False)) |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1426 |
if remotephases and not publishing: |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1427 |
# remote is new and unpublishing |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1428 |
pheads, _dr = phases.analyzeremotephases(pullop.repo, |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1429 |
pullop.pulledsubset, |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1430 |
remotephases) |
22068
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1431 |
dheads = pullop.pulledsubset |
20486
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1432 |
else: |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1433 |
# Remote is old or publishing all common changesets |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1434 |
# should be seen as public |
22068
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1435 |
pheads = pullop.pulledsubset |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1436 |
dheads = [] |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1437 |
unfi = pullop.repo.unfiltered() |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1438 |
phase = unfi._phasecache.phase |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1439 |
rev = unfi.changelog.nodemap.get |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1440 |
public = phases.public |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1441 |
draft = phases.draft |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1442 |
|
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1443 |
# exclude changesets already public locally and update the others |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1444 |
pheads = [pn for pn in pheads if phase(unfi, rev(pn)) > public] |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1445 |
if pheads: |
22069
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22068
diff
changeset
|
1446 |
tr = pullop.gettransaction() |
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22068
diff
changeset
|
1447 |
phases.advanceboundary(pullop.repo, tr, public, pheads) |
22068
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1448 |
|
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1449 |
# exclude changesets already draft locally and update the others |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1450 |
dheads = [pn for pn in dheads if phase(unfi, rev(pn)) > draft] |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1451 |
if dheads: |
22069
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22068
diff
changeset
|
1452 |
tr = pullop.gettransaction() |
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22068
diff
changeset
|
1453 |
phases.advanceboundary(pullop.repo, tr, draft, dheads) |
20486
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1454 |
|
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1455 |
def _pullbookmarks(pullop): |
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1456 |
"""process the remote bookmark information to update the local one""" |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1457 |
if 'bookmarks' in pullop.stepsdone: |
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1458 |
return |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1459 |
pullop.stepsdone.add('bookmarks') |
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1460 |
repo = pullop.repo |
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1461 |
remotebookmarks = pullop.remotebookmarks |
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1462 |
bookmod.updatefromremote(repo.ui, repo, remotebookmarks, |
22658
a8f0d8e4c80a
pull: gather explicit bookmark pulls with bookmark updates
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22656
diff
changeset
|
1463 |
pullop.remote.url(), |
22666
0f8120c1ecf5
pull: perform bookmark updates in the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22658
diff
changeset
|
1464 |
pullop.gettransaction, |
22658
a8f0d8e4c80a
pull: gather explicit bookmark pulls with bookmark updates
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22656
diff
changeset
|
1465 |
explicit=pullop.explicitbookmarks) |
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1466 |
|
20478
80628d4069be
push: feed pulloperation object to _pullobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20477
diff
changeset
|
1467 |
def _pullobsolete(pullop): |
20476
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1468 |
"""utility function to pull obsolete markers from a remote |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1469 |
|
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1470 |
The `gettransaction` is function that return the pull transaction, creating |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1471 |
one if necessary. We return the transaction to inform the calling code that |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1472 |
a new transaction have been created (when applicable). |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1473 |
|
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1474 |
Exists mostly to allow overriding for experimentation purpose""" |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1475 |
if 'obsmarkers' in pullop.stepsdone: |
22653
d94f5bec9c8e
pull: perform the todostep inside functions handling old way of pulling
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22651
diff
changeset
|
1476 |
return |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1477 |
pullop.stepsdone.add('obsmarkers') |
20476
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1478 |
tr = None |
22953
b1d694d3975e
obsolete: add exchange option
Durham Goode <durham@fb.com>
parents:
22937
diff
changeset
|
1479 |
if obsolete.isenabled(pullop.repo, obsolete.exchangeopt): |
20478
80628d4069be
push: feed pulloperation object to _pullobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20477
diff
changeset
|
1480 |
pullop.repo.ui.debug('fetching remote obsolete markers\n') |
80628d4069be
push: feed pulloperation object to _pullobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20477
diff
changeset
|
1481 |
remoteobs = pullop.remote.listkeys('obsolete') |
20476
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1482 |
if 'dump0' in remoteobs: |
20478
80628d4069be
push: feed pulloperation object to _pullobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20477
diff
changeset
|
1483 |
tr = pullop.gettransaction() |
27558
b5b54825de6b
pull: make a single call to obsstore.add (issue5006)
Matt Mackall <mpm@selenic.com>
parents:
27523
diff
changeset
|
1484 |
markers = [] |
20476
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1485 |
for key in sorted(remoteobs, reverse=True): |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1486 |
if key.startswith('dump'): |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1487 |
data = base85.b85decode(remoteobs[key]) |
27558
b5b54825de6b
pull: make a single call to obsstore.add (issue5006)
Matt Mackall <mpm@selenic.com>
parents:
27523
diff
changeset
|
1488 |
version, newmarks = obsolete._readmarkers(data) |
b5b54825de6b
pull: make a single call to obsstore.add (issue5006)
Matt Mackall <mpm@selenic.com>
parents:
27523
diff
changeset
|
1489 |
markers += newmarks |
b5b54825de6b
pull: make a single call to obsstore.add (issue5006)
Matt Mackall <mpm@selenic.com>
parents:
27523
diff
changeset
|
1490 |
if markers: |
b5b54825de6b
pull: make a single call to obsstore.add (issue5006)
Matt Mackall <mpm@selenic.com>
parents:
27523
diff
changeset
|
1491 |
pullop.repo.obsstore.add(tr, markers) |
20478
80628d4069be
push: feed pulloperation object to _pullobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20477
diff
changeset
|
1492 |
pullop.repo.invalidatevolatilesets() |
20476
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1493 |
return tr |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1494 |
|
21645
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
1495 |
def caps20to10(repo): |
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
1496 |
"""return a set with appropriate options to use bundle20 during getbundle""" |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
1497 |
caps = set(['HG20']) |
22342
262c5cc126c1
bundle2: introduce a `getrepocaps` to retrieve the bundle2 caps of a repo
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22341
diff
changeset
|
1498 |
capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo)) |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
1499 |
caps.add('bundle2=' + urlreq.quote(capsblob)) |
21645
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
1500 |
return caps |
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
1501 |
|
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1502 |
# List of names of steps to perform for a bundle2 for getbundle, order matters. |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1503 |
getbundle2partsorder = [] |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1504 |
|
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1505 |
# Mapping between step name and function |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1506 |
# |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1507 |
# This exists to help extensions wrap steps if necessary |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1508 |
getbundle2partsmapping = {} |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1509 |
|
24732
8f70b529cb0c
bundle2: add an 'idx' argument to the 'getbundle2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24731
diff
changeset
|
1510 |
def getbundle2partsgenerator(stepname, idx=None): |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1511 |
"""decorator for function generating bundle2 part for getbundle |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1512 |
|
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1513 |
The function is added to the step -> function mapping and appended to the |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1514 |
list of steps. Beware that decorated functions will be added in order |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1515 |
(this may matter). |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1516 |
|
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1517 |
You can only use this decorator for new steps, if you want to wrap a step |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1518 |
from an extension, attack the getbundle2partsmapping dictionary directly.""" |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1519 |
def dec(func): |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1520 |
assert stepname not in getbundle2partsmapping |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1521 |
getbundle2partsmapping[stepname] = func |
24732
8f70b529cb0c
bundle2: add an 'idx' argument to the 'getbundle2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24731
diff
changeset
|
1522 |
if idx is None: |
8f70b529cb0c
bundle2: add an 'idx' argument to the 'getbundle2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24731
diff
changeset
|
1523 |
getbundle2partsorder.append(stepname) |
8f70b529cb0c
bundle2: add an 'idx' argument to the 'getbundle2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24731
diff
changeset
|
1524 |
else: |
8f70b529cb0c
bundle2: add an 'idx' argument to the 'getbundle2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24731
diff
changeset
|
1525 |
getbundle2partsorder.insert(idx, stepname) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1526 |
return func |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1527 |
return dec |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1528 |
|
27244
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
1529 |
def bundle2requested(bundlecaps): |
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
1530 |
if bundlecaps is not None: |
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
1531 |
return any(cap.startswith('HG2') for cap in bundlecaps) |
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
1532 |
return False |
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
1533 |
|
21157
60ad2ea5b106
getbundle: pass arbitrary arguments all along the call chain
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21156
diff
changeset
|
1534 |
def getbundle(repo, source, heads=None, common=None, bundlecaps=None, |
60ad2ea5b106
getbundle: pass arbitrary arguments all along the call chain
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21156
diff
changeset
|
1535 |
**kwargs): |
20954
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1536 |
"""return a full bundle (with potentially multiple kind of parts) |
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1537 |
|
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
1538 |
Could be a bundle HG10 or a bundle HG20 depending on bundlecaps |
20954
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1539 |
passed. For now, the bundle can contain only changegroup, but this will |
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1540 |
changes when more part type will be available for bundle2. |
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1541 |
|
22390
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22354
diff
changeset
|
1542 |
This is different from changegroup.getchangegroup that only returns an HG10 |
20954
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1543 |
changegroup bundle. They may eventually get reunited in the future when we |
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1544 |
have a clearer idea of the API we what to query different data. |
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1545 |
|
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1546 |
The implementation is at a very early stage and will get massive rework |
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1547 |
when the API of bundle is refined. |
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1548 |
""" |
27244
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
1549 |
usebundle2 = bundle2requested(bundlecaps) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1550 |
# bundle10 case |
24649
2d15c59a001b
bundle2: detect bundle2 stream/request on /HG2./ instead of /HG2Y/
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24641
diff
changeset
|
1551 |
if not usebundle2: |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1552 |
if bundlecaps and not kwargs.get('cg', True): |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1553 |
raise ValueError(_('request for bundle10 must include changegroup')) |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1554 |
|
21656
36200dc6b3bd
getbundle: raise error if extra arguments are provided for bundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21654
diff
changeset
|
1555 |
if kwargs: |
36200dc6b3bd
getbundle: raise error if extra arguments are provided for bundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21654
diff
changeset
|
1556 |
raise ValueError(_('unsupported getbundle arguments: %s') |
36200dc6b3bd
getbundle: raise error if extra arguments are provided for bundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21654
diff
changeset
|
1557 |
% ', '.join(sorted(kwargs.keys()))) |
29819
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
1558 |
outgoing = _computeoutgoing(repo, heads, common) |
29818
d4e026341e16
getchangegroup: take an 'outgoing' object as argument (API)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29791
diff
changeset
|
1559 |
return changegroup.getchangegroup(repo, source, outgoing, |
d4e026341e16
getchangegroup: take an 'outgoing' object as argument (API)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29791
diff
changeset
|
1560 |
bundlecaps=bundlecaps) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1561 |
|
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1562 |
# bundle20 case |
21143
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
1563 |
b2caps = {} |
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
1564 |
for bcaps in bundlecaps: |
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
1565 |
if bcaps.startswith('bundle2='): |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
1566 |
blob = urlreq.unquote(bcaps[len('bundle2='):]) |
21143
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
1567 |
b2caps.update(bundle2.decodecaps(blob)) |
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
1568 |
bundler = bundle2.bundle20(repo.ui, b2caps) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1569 |
|
23218
0e78ea8e592a
exchange: prepare kwargs for bundle2 part generation exactly once
Mike Edgar <adgar@google.com>
parents:
23217
diff
changeset
|
1570 |
kwargs['heads'] = heads |
0e78ea8e592a
exchange: prepare kwargs for bundle2 part generation exactly once
Mike Edgar <adgar@google.com>
parents:
23217
diff
changeset
|
1571 |
kwargs['common'] = common |
0e78ea8e592a
exchange: prepare kwargs for bundle2 part generation exactly once
Mike Edgar <adgar@google.com>
parents:
23217
diff
changeset
|
1572 |
|
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1573 |
for name in getbundle2partsorder: |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1574 |
func = getbundle2partsmapping[name] |
22543
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
1575 |
func(bundler, repo, source, bundlecaps=bundlecaps, b2caps=b2caps, |
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
1576 |
**kwargs) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1577 |
|
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1578 |
return util.chunkbuffer(bundler.getchunks()) |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1579 |
|
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1580 |
@getbundle2partsgenerator('changegroup') |
22543
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
1581 |
def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None, |
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
1582 |
b2caps=None, heads=None, common=None, **kwargs): |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1583 |
"""add a changegroup part to the requested bundle""" |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1584 |
cg = None |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1585 |
if kwargs.get('cg', True): |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1586 |
# build changegroup bundle here. |
28667
e7bf227e33a5
exchange: get rid of "getcgkwargs" variable
Martin von Zweigbergk <martinvonz@google.com>
parents:
28456
diff
changeset
|
1587 |
version = '01' |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
1588 |
cgversions = b2caps.get('changegroup') |
25503
1b7853a1f04e
getbundle: have a single getchangegroupraw call site
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25502
diff
changeset
|
1589 |
if cgversions: # 3.1 and 3.2 ship with an empty value |
27751
a40e2f7fe49d
changegroup: hide packermap behind methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
27738
diff
changeset
|
1590 |
cgversions = [v for v in cgversions |
27953
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27938
diff
changeset
|
1591 |
if v in changegroup.supportedoutgoingversions(repo)] |
23179
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1592 |
if not cgversions: |
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1593 |
raise ValueError(_('no common changegroup version')) |
28667
e7bf227e33a5
exchange: get rid of "getcgkwargs" variable
Martin von Zweigbergk <martinvonz@google.com>
parents:
28456
diff
changeset
|
1594 |
version = max(cgversions) |
29819
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
1595 |
outgoing = _computeoutgoing(repo, heads, common) |
25504
60f4e7022ffe
exchange: expand usage of getchangegroupraw
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25503
diff
changeset
|
1596 |
cg = changegroup.getlocalchangegroupraw(repo, source, outgoing, |
60f4e7022ffe
exchange: expand usage of getchangegroupraw
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25503
diff
changeset
|
1597 |
bundlecaps=bundlecaps, |
28667
e7bf227e33a5
exchange: get rid of "getcgkwargs" variable
Martin von Zweigbergk <martinvonz@google.com>
parents:
28456
diff
changeset
|
1598 |
version=version) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1599 |
|
21259
ab5040cd5749
bundle2: fix bundle2 pulling all revs on empty pulls
Durham Goode <durham@fb.com>
parents:
21258
diff
changeset
|
1600 |
if cg: |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
1601 |
part = bundler.newpart('changegroup', data=cg) |
28667
e7bf227e33a5
exchange: get rid of "getcgkwargs" variable
Martin von Zweigbergk <martinvonz@google.com>
parents:
28456
diff
changeset
|
1602 |
if cgversions: |
23179
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1603 |
part.addparam('version', version) |
25516
1e37bd83dc66
getbundle: add data about the number of changesets bundled
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25504
diff
changeset
|
1604 |
part.addparam('nbchanges', str(len(outgoing.missing)), mandatory=False) |
27734
5c0fd878779c
treemanifests: set bundle2 part parameter indicating treemanifest
Martin von Zweigbergk <martinvonz@google.com>
parents:
27558
diff
changeset
|
1605 |
if 'treemanifest' in repo.requirements: |
5c0fd878779c
treemanifests: set bundle2 part parameter indicating treemanifest
Martin von Zweigbergk <martinvonz@google.com>
parents:
27558
diff
changeset
|
1606 |
part.addparam('treemanifest', '1') |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1607 |
|
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1608 |
@getbundle2partsgenerator('listkeys') |
22543
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
1609 |
def _getbundlelistkeysparts(bundler, repo, source, bundlecaps=None, |
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
1610 |
b2caps=None, **kwargs): |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1611 |
"""add parts containing listkeys namespaces to the requested bundle""" |
21657
0ff44e06275d
getbundle: support of listkeys argument when bundle2 is used
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21656
diff
changeset
|
1612 |
listkeys = kwargs.get('listkeys', ()) |
0ff44e06275d
getbundle: support of listkeys argument when bundle2 is used
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21656
diff
changeset
|
1613 |
for namespace in listkeys: |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
1614 |
part = bundler.newpart('listkeys') |
21657
0ff44e06275d
getbundle: support of listkeys argument when bundle2 is used
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21656
diff
changeset
|
1615 |
part.addparam('namespace', namespace) |
0ff44e06275d
getbundle: support of listkeys argument when bundle2 is used
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21656
diff
changeset
|
1616 |
keys = repo.listkeys(namespace).items() |
0ff44e06275d
getbundle: support of listkeys argument when bundle2 is used
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21656
diff
changeset
|
1617 |
part.data = pushkey.encodekeys(keys) |
20967
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
1618 |
|
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1619 |
@getbundle2partsgenerator('obsmarkers') |
22543
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
1620 |
def _getbundleobsmarkerpart(bundler, repo, source, bundlecaps=None, |
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
1621 |
b2caps=None, heads=None, **kwargs): |
22541
4e1a80c022a4
bundle2: pass b2caps down to functions adding bundle2 parts for getbundle
Mike Hommey <mh@glandium.org>
parents:
22390
diff
changeset
|
1622 |
"""add an obsolescence markers part to the requested bundle""" |
22353
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
1623 |
if kwargs.get('obsmarkers', False): |
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
1624 |
if heads is None: |
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
1625 |
heads = repo.heads() |
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
1626 |
subset = [c.node() for c in repo.set('::%ln', heads)] |
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
1627 |
markers = repo.obsstore.relevantmarkers(subset) |
25118
e632a2429982
obsolete: sort obsmarkers during exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24878
diff
changeset
|
1628 |
markers = sorted(markers) |
22353
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
1629 |
buildobsmarkerspart(bundler, markers) |
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
1630 |
|
25402
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1631 |
@getbundle2partsgenerator('hgtagsfnodes') |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1632 |
def _getbundletagsfnodes(bundler, repo, source, bundlecaps=None, |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1633 |
b2caps=None, heads=None, common=None, |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1634 |
**kwargs): |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1635 |
"""Transfer the .hgtags filenodes mapping. |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1636 |
|
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1637 |
Only values for heads in this bundle will be transferred. |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1638 |
|
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1639 |
The part data consists of pairs of 20 byte changeset node and .hgtags |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1640 |
filenodes raw values. |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1641 |
""" |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1642 |
# Don't send unless: |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1643 |
# - changeset are being exchanged, |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1644 |
# - the client supports it. |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1645 |
if not (kwargs.get('cg', True) and 'hgtagsfnodes' in b2caps): |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1646 |
return |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1647 |
|
29819
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29818
diff
changeset
|
1648 |
outgoing = _computeoutgoing(repo, heads, common) |
25402
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1649 |
|
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1650 |
if not outgoing.missingheads: |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1651 |
return |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1652 |
|
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1653 |
cache = tags.hgtagsfnodescache(repo.unfiltered()) |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1654 |
chunks = [] |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1655 |
|
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1656 |
# .hgtags fnodes are only relevant for head changesets. While we could |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1657 |
# transfer values for all known nodes, there will likely be little to |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1658 |
# no benefit. |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1659 |
# |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1660 |
# We don't bother using a generator to produce output data because |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1661 |
# a) we only have 40 bytes per head and even esoteric numbers of heads |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1662 |
# consume little memory (1M heads is 40MB) b) we don't want to send the |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1663 |
# part if we don't have entries and knowing if we have entries requires |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1664 |
# cache lookups. |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1665 |
for node in outgoing.missingheads: |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1666 |
# Don't compute missing, as this may slow down serving. |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1667 |
fnode = cache.getfnode(node, computemissing=False) |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1668 |
if fnode is not None: |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1669 |
chunks.extend([node, fnode]) |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1670 |
|
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1671 |
if chunks: |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1672 |
bundler.newpart('hgtagsfnodes', data=''.join(chunks)) |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
1673 |
|
20967
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
1674 |
def check_heads(repo, their_heads, context): |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
1675 |
"""check if the heads of a repo have been modified |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
1676 |
|
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
1677 |
Used by peer for unbundling. |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
1678 |
""" |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
1679 |
heads = repo.heads() |
29341
0d83ad967bf8
cleanup: replace uses of util.(md5|sha1|sha256|sha512) with hashlib.\1
Augie Fackler <raf@durin42.com>
parents:
29064
diff
changeset
|
1680 |
heads_hash = hashlib.sha1(''.join(sorted(heads))).digest() |
20967
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
1681 |
if not (their_heads == ['force'] or their_heads == heads or |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
1682 |
their_heads == ['hashed', heads_hash]): |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
1683 |
# someone else committed/pushed/unbundled while we |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
1684 |
# were transferring data |
21184
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21182
diff
changeset
|
1685 |
raise error.PushRaced('repository changed while %s - ' |
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21182
diff
changeset
|
1686 |
'please try again' % context) |
20968
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1687 |
|
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1688 |
def unbundle(repo, cg, heads, source, url): |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1689 |
"""Apply a bundle to a repo. |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1690 |
|
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1691 |
this function makes sure the repo is locked during the application and have |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
1692 |
mechanism to check that no push race occurred between the creation of the |
20968
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1693 |
bundle and its application. |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1694 |
|
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1695 |
If the push was raced as PushRaced exception is raised.""" |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1696 |
r = 0 |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1697 |
# need a transaction when processing a bundle2 stream |
26566
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1698 |
# [wlock, lock, tr] - needs to be an array so nested functions can modify it |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1699 |
lockandtr = [None, None, None] |
24847
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
1700 |
recordout = None |
24878
e530cde6d115
bundle2: disable ouput capture unless we use http (issue4613 issue4615)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24851
diff
changeset
|
1701 |
# quick fix for output mismatch with bundle2 in 3.4 |
e530cde6d115
bundle2: disable ouput capture unless we use http (issue4613 issue4615)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24851
diff
changeset
|
1702 |
captureoutput = repo.ui.configbool('experimental', 'bundle2-output-capture', |
e530cde6d115
bundle2: disable ouput capture unless we use http (issue4613 issue4615)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24851
diff
changeset
|
1703 |
False) |
25423
525fbf24b51b
bundle2: stop capturing output for ssh again
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25404
diff
changeset
|
1704 |
if url.startswith('remote:http:') or url.startswith('remote:https:'): |
24878
e530cde6d115
bundle2: disable ouput capture unless we use http (issue4613 issue4615)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24851
diff
changeset
|
1705 |
captureoutput = True |
20968
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1706 |
try: |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1707 |
check_heads(repo, heads, 'uploading changes') |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1708 |
# push can proceed |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1709 |
if util.safehasattr(cg, 'params'): |
24795
f9aa4cb8f2dd
bundle2: store the salvaged output on the exception object
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24754
diff
changeset
|
1710 |
r = None |
21187
bcfd44abad93
bundle2: gracefully handle hook abort
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
1711 |
try: |
26566
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1712 |
def gettransaction(): |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1713 |
if not lockandtr[2]: |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1714 |
lockandtr[0] = repo.wlock() |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1715 |
lockandtr[1] = repo.lock() |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1716 |
lockandtr[2] = repo.transaction(source) |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1717 |
lockandtr[2].hookargs['source'] = source |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1718 |
lockandtr[2].hookargs['url'] = url |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1719 |
lockandtr[2].hookargs['bundle2'] = '1' |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1720 |
return lockandtr[2] |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1721 |
|
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1722 |
# Do greedy locking by default until we're satisfied with lazy |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1723 |
# locking. |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1724 |
if not repo.ui.configbool('experimental', 'bundle2lazylocking'): |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1725 |
gettransaction() |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1726 |
|
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1727 |
op = bundle2.bundleoperation(repo, gettransaction, |
24878
e530cde6d115
bundle2: disable ouput capture unless we use http (issue4613 issue4615)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24851
diff
changeset
|
1728 |
captureoutput=captureoutput) |
24851
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
1729 |
try: |
25896
6805a4f76cda
exchange: fix dead assignment
Martin von Zweigbergk <martinvonz@google.com>
parents:
25895
diff
changeset
|
1730 |
op = bundle2.processbundle(repo, cg, op=op) |
24851
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
1731 |
finally: |
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
1732 |
r = op.reply |
24878
e530cde6d115
bundle2: disable ouput capture unless we use http (issue4613 issue4615)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24851
diff
changeset
|
1733 |
if captureoutput and r is not None: |
24851
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
1734 |
repo.ui.pushbuffer(error=True, subproc=True) |
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
1735 |
def recordout(output): |
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
1736 |
r.newpart('output', data=output, mandatory=False) |
26566
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1737 |
if lockandtr[2] is not None: |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1738 |
lockandtr[2].close() |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25640
diff
changeset
|
1739 |
except BaseException as exc: |
21187
bcfd44abad93
bundle2: gracefully handle hook abort
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
1740 |
exc.duringunbundle2 = True |
24878
e530cde6d115
bundle2: disable ouput capture unless we use http (issue4613 issue4615)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24851
diff
changeset
|
1741 |
if captureoutput and r is not None: |
24847
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
1742 |
parts = exc._bundle2salvagedoutput = r.salvageoutput() |
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
1743 |
def recordout(output): |
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
1744 |
part = bundle2.bundlepart('output', data=output, |
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
1745 |
mandatory=False) |
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
1746 |
parts.append(part) |
21187
bcfd44abad93
bundle2: gracefully handle hook abort
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
1747 |
raise |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1748 |
else: |
26566
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1749 |
lockandtr[1] = repo.lock() |
26700
dbc3d945ba36
exchange: use cg?unpacker.apply() instead of changegroup.addchangegroup()
Augie Fackler <augie@google.com>
parents:
26690
diff
changeset
|
1750 |
r = cg.apply(repo, source, url) |
20968
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1751 |
finally: |
26566
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
1752 |
lockmod.release(lockandtr[2], lockandtr[1], lockandtr[0]) |
24847
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
1753 |
if recordout is not None: |
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
1754 |
recordout(repo.ui.popbuffer()) |
20968
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1755 |
return r |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1756 |
|
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1757 |
def _maybeapplyclonebundle(pullop): |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1758 |
"""Apply a clone bundle from a remote, if possible.""" |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1759 |
|
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1760 |
repo = pullop.repo |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1761 |
remote = pullop.remote |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1762 |
|
27738
a0e783d26e81
exchange: make clone bundles non-experimental and enabled by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27737
diff
changeset
|
1763 |
if not repo.ui.configbool('ui', 'clonebundles', True): |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1764 |
return |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1765 |
|
26855
9350f00a7b23
exchange: do not attempt clone bundle if local repo is non-empty (issue4932)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26829
diff
changeset
|
1766 |
# Only run if local repo is empty. |
9350f00a7b23
exchange: do not attempt clone bundle if local repo is non-empty (issue4932)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26829
diff
changeset
|
1767 |
if len(repo): |
9350f00a7b23
exchange: do not attempt clone bundle if local repo is non-empty (issue4932)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26829
diff
changeset
|
1768 |
return |
9350f00a7b23
exchange: do not attempt clone bundle if local repo is non-empty (issue4932)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26829
diff
changeset
|
1769 |
|
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1770 |
if pullop.heads: |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1771 |
return |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1772 |
|
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1773 |
if not remote.capable('clonebundles'): |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1774 |
return |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1775 |
|
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1776 |
res = remote._call('clonebundles') |
26689
2c9f15366982
exchange: record that we attempted to fetch a clone bundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26688
diff
changeset
|
1777 |
|
2c9f15366982
exchange: record that we attempted to fetch a clone bundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26688
diff
changeset
|
1778 |
# If we call the wire protocol command, that's good enough to record the |
2c9f15366982
exchange: record that we attempted to fetch a clone bundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26688
diff
changeset
|
1779 |
# attempt. |
2c9f15366982
exchange: record that we attempted to fetch a clone bundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26688
diff
changeset
|
1780 |
pullop.clonebundleattempted = True |
2c9f15366982
exchange: record that we attempted to fetch a clone bundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26688
diff
changeset
|
1781 |
|
26647
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
1782 |
entries = parseclonebundlesmanifest(repo, res) |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1783 |
if not entries: |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1784 |
repo.ui.note(_('no clone bundles available on remote; ' |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1785 |
'falling back to regular clone\n')) |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1786 |
return |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1787 |
|
26644
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1788 |
entries = filterclonebundleentries(repo, entries) |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1789 |
if not entries: |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1790 |
# There is a thundering herd concern here. However, if a server |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1791 |
# operator doesn't advertise bundles appropriate for its clients, |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1792 |
# they deserve what's coming. Furthermore, from a client's |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1793 |
# perspective, no automatic fallback would mean not being able to |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1794 |
# clone! |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1795 |
repo.ui.warn(_('no compatible clone bundles available on server; ' |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1796 |
'falling back to regular clone\n')) |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1797 |
repo.ui.warn(_('(you may want to report this to the server ' |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1798 |
'operator)\n')) |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1799 |
return |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1800 |
|
26648
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1801 |
entries = sortclonebundleentries(repo.ui, entries) |
26644
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1802 |
|
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1803 |
url = entries[0]['URL'] |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1804 |
repo.ui.status(_('applying clone bundle from %s\n') % url) |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1805 |
if trypullbundlefromurl(repo.ui, repo, url): |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1806 |
repo.ui.status(_('finished applying clone bundle\n')) |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1807 |
# Bundle failed. |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1808 |
# |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1809 |
# We abort by default to avoid the thundering herd of |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1810 |
# clients flooding a server that was expecting expensive |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1811 |
# clone load to be offloaded. |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1812 |
elif repo.ui.configbool('ui', 'clonebundlefallback', False): |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1813 |
repo.ui.warn(_('falling back to normal clone\n')) |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1814 |
else: |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1815 |
raise error.Abort(_('error applying bundle'), |
26688
7394536338bb
exchange: provide hint on how to disable clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26687
diff
changeset
|
1816 |
hint=_('if this error persists, consider contacting ' |
7394536338bb
exchange: provide hint on how to disable clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26687
diff
changeset
|
1817 |
'the server operator or disable clone ' |
7394536338bb
exchange: provide hint on how to disable clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26687
diff
changeset
|
1818 |
'bundles via ' |
27738
a0e783d26e81
exchange: make clone bundles non-experimental and enabled by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27737
diff
changeset
|
1819 |
'"--config ui.clonebundles=false"')) |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1820 |
|
26647
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
1821 |
def parseclonebundlesmanifest(repo, s): |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1822 |
"""Parses the raw text of a clone bundles manifest. |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1823 |
|
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1824 |
Returns a list of dicts. The dicts have a ``URL`` key corresponding |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1825 |
to the URL and other keys are the attributes for the entry. |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1826 |
""" |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1827 |
m = [] |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1828 |
for line in s.splitlines(): |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1829 |
fields = line.split() |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1830 |
if not fields: |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1831 |
continue |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1832 |
attrs = {'URL': fields[0]} |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1833 |
for rawattr in fields[1:]: |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1834 |
key, value = rawattr.split('=', 1) |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
1835 |
key = urlreq.unquote(key) |
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
1836 |
value = urlreq.unquote(value) |
26647
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
1837 |
attrs[key] = value |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
1838 |
|
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
1839 |
# Parse BUNDLESPEC into components. This makes client-side |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
1840 |
# preferences easier to specify since you can prefer a single |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
1841 |
# component of the BUNDLESPEC. |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
1842 |
if key == 'BUNDLESPEC': |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
1843 |
try: |
26759
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
1844 |
comp, version, params = parsebundlespec(repo, value, |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
1845 |
externalnames=True) |
26647
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
1846 |
attrs['COMPRESSION'] = comp |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
1847 |
attrs['VERSION'] = version |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
1848 |
except error.InvalidBundleSpecification: |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
1849 |
pass |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
1850 |
except error.UnsupportedBundleSpecification: |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
1851 |
pass |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1852 |
|
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1853 |
m.append(attrs) |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1854 |
|
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1855 |
return m |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1856 |
|
26644
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1857 |
def filterclonebundleentries(repo, entries): |
26687
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
1858 |
"""Remove incompatible clone bundle manifest entries. |
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
1859 |
|
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
1860 |
Accepts a list of entries parsed with ``parseclonebundlesmanifest`` |
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
1861 |
and returns a new list consisting of only the entries that this client |
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
1862 |
should be able to apply. |
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
1863 |
|
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
1864 |
There is no guarantee we'll be able to apply all returned entries because |
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
1865 |
the metadata we use to filter on may be missing or wrong. |
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
1866 |
""" |
26644
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1867 |
newentries = [] |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1868 |
for entry in entries: |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1869 |
spec = entry.get('BUNDLESPEC') |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1870 |
if spec: |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1871 |
try: |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1872 |
parsebundlespec(repo, spec, strict=True) |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1873 |
except error.InvalidBundleSpecification as e: |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1874 |
repo.ui.debug(str(e) + '\n') |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1875 |
continue |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1876 |
except error.UnsupportedBundleSpecification as e: |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1877 |
repo.ui.debug('filtering %s because unsupported bundle ' |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1878 |
'spec: %s\n' % (entry['URL'], str(e))) |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1879 |
continue |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1880 |
|
26645
2faa7671a4b3
clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26644
diff
changeset
|
1881 |
if 'REQUIRESNI' in entry and not sslutil.hassni: |
2faa7671a4b3
clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26644
diff
changeset
|
1882 |
repo.ui.debug('filtering %s because SNI not supported\n' % |
2faa7671a4b3
clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26644
diff
changeset
|
1883 |
entry['URL']) |
2faa7671a4b3
clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26644
diff
changeset
|
1884 |
continue |
2faa7671a4b3
clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26644
diff
changeset
|
1885 |
|
26644
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1886 |
newentries.append(entry) |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1887 |
|
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1888 |
return newentries |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
1889 |
|
26648
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1890 |
def sortclonebundleentries(ui, entries): |
27737
482eb357fe98
exchange: make clonebundleprefers non-experimental
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27734
diff
changeset
|
1891 |
prefers = ui.configlist('ui', 'clonebundleprefers', default=[]) |
26648
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1892 |
if not prefers: |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1893 |
return list(entries) |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1894 |
|
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1895 |
prefers = [p.split('=', 1) for p in prefers] |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1896 |
|
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1897 |
# Our sort function. |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1898 |
def compareentry(a, b): |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1899 |
for prefkey, prefvalue in prefers: |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1900 |
avalue = a.get(prefkey) |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1901 |
bvalue = b.get(prefkey) |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1902 |
|
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1903 |
# Special case for b missing attribute and a matches exactly. |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1904 |
if avalue is not None and bvalue is None and avalue == prefvalue: |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1905 |
return -1 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1906 |
|
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1907 |
# Special case for a missing attribute and b matches exactly. |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1908 |
if bvalue is not None and avalue is None and bvalue == prefvalue: |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1909 |
return 1 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1910 |
|
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1911 |
# We can't compare unless attribute present on both. |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1912 |
if avalue is None or bvalue is None: |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1913 |
continue |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1914 |
|
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1915 |
# Same values should fall back to next attribute. |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1916 |
if avalue == bvalue: |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1917 |
continue |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1918 |
|
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1919 |
# Exact matches come first. |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1920 |
if avalue == prefvalue: |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1921 |
return -1 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1922 |
if bvalue == prefvalue: |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1923 |
return 1 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1924 |
|
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1925 |
# Fall back to next attribute. |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1926 |
continue |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1927 |
|
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1928 |
# If we got here we couldn't sort by attributes and prefers. Fall |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1929 |
# back to index order. |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1930 |
return 0 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1931 |
|
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1932 |
return sorted(entries, cmp=compareentry) |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
1933 |
|
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1934 |
def trypullbundlefromurl(ui, repo, url): |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1935 |
"""Attempt to apply a bundle from a URL.""" |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1936 |
lock = repo.lock() |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1937 |
try: |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1938 |
tr = repo.transaction('bundleurl') |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1939 |
try: |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1940 |
try: |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1941 |
fh = urlmod.open(ui, url) |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1942 |
cg = readbundle(ui, fh, 'stream') |
26643
d2e16419d3f4
clonebundle: support bundle2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26640
diff
changeset
|
1943 |
|
d2e16419d3f4
clonebundle: support bundle2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26640
diff
changeset
|
1944 |
if isinstance(cg, bundle2.unbundle20): |
d2e16419d3f4
clonebundle: support bundle2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26640
diff
changeset
|
1945 |
bundle2.processbundle(repo, cg, lambda: tr) |
26761
8270ee357dd9
exchange: support streaming clone bundles in clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26760
diff
changeset
|
1946 |
elif isinstance(cg, streamclone.streamcloneapplier): |
8270ee357dd9
exchange: support streaming clone bundles in clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26760
diff
changeset
|
1947 |
cg.apply(repo) |
26643
d2e16419d3f4
clonebundle: support bundle2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26640
diff
changeset
|
1948 |
else: |
26700
dbc3d945ba36
exchange: use cg?unpacker.apply() instead of changegroup.addchangegroup()
Augie Fackler <augie@google.com>
parents:
26690
diff
changeset
|
1949 |
cg.apply(repo, 'clonebundles', url) |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1950 |
tr.close() |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1951 |
return True |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
1952 |
except urlerr.httperror as e: |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1953 |
ui.warn(_('HTTP error fetching bundle: %s\n') % str(e)) |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
1954 |
except urlerr.urlerror as e: |
26732
69ac9aebbc55
exchange: don't print error codes after clone bundle failure
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26729
diff
changeset
|
1955 |
ui.warn(_('error fetching bundle: %s\n') % e.reason[1]) |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1956 |
|
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1957 |
return False |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1958 |
finally: |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1959 |
tr.release() |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1960 |
finally: |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
1961 |
lock.release() |