Mercurial > hg
annotate mercurial/exchange.py @ 51679:be6d8ea6d3d2
typing: add a trivial type hint to `mercurial/vfs.py`
Since hg 3dbc7b1ecaba, pytype stopped seeing the return value of `rmtree` as
`None`, and substituted `Any`.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 10 Jul 2024 18:44:55 -0400 |
parents | a0f1378b932e |
children | b8647465b59a 2f8e7e384178 |
rev | line source |
---|---|
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 # |
46819
d4ba4d51f85f
contributor: change mentions of mpm to olivia
Raphaël Gomès <rgomes@octobus.net>
parents:
46780
diff
changeset
|
3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> |
20345
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 |
34322
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
9 import collections |
44545
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
10 import weakref |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
11 |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
12 from .i18n import _ |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
13 from .node import ( |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
14 hex, |
38791
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
15 nullrev, |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
16 ) |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
17 from . import ( |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
18 bookmarks as bookmod, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
19 bundle2, |
45784
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45681
diff
changeset
|
20 bundlecaches, |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
21 changegroup, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
22 discovery, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
23 error, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
24 lock as lockmod, |
35347
a29fe459fc49
remotenames: rename related file and storage dir to logexchange
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35305
diff
changeset
|
25 logexchange, |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
26 narrowspec, |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
27 obsolete, |
43580
e513e87b0476
py3: fix sorting of obsolete markers in obsutil (issue6217)
Denis Laxalde <denis@laxalde.org>
parents:
43278
diff
changeset
|
28 obsutil, |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
29 phases, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
30 pushkey, |
32896
e14484e7f562
py3: use pycompat.strkwargs() to convert kwargs keys to str before passing
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32891
diff
changeset
|
31 pycompat, |
45372
77b8588dd84e
requirements: introduce new requirements related module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45371
diff
changeset
|
32 requirements, |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
33 scmutil, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
34 streamclone, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
35 url as urlmod, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
36 util, |
40492
440f5b65be57
exchange: pass includepats and excludepats as arguments to getbundle()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40352
diff
changeset
|
37 wireprototypes, |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
38 ) |
44060
a61287a95dc3
core: migrate uses of hashlib.sha1 to hashutil.sha1
Augie Fackler <augie@google.com>
parents:
43913
diff
changeset
|
39 from .utils import ( |
a61287a95dc3
core: migrate uses of hashlib.sha1 to hashutil.sha1
Augie Fackler <augie@google.com>
parents:
43913
diff
changeset
|
40 hashutil, |
a61287a95dc3
core: migrate uses of hashlib.sha1 to hashutil.sha1
Augie Fackler <augie@google.com>
parents:
43913
diff
changeset
|
41 stringutil, |
46907
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
42 urlutil, |
44060
a61287a95dc3
core: migrate uses of hashlib.sha1 to hashutil.sha1
Augie Fackler <augie@google.com>
parents:
43913
diff
changeset
|
43 ) |
47226
19d4802cb304
sidedata: add a 'side-data' repository feature and use it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
44 from .interfaces import repository |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
45 |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
46 urlerr = util.urlerr |
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
47 urlreq = util.urlreq |
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
48 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
49 _NARROWACL_SECTION = b'narrowacl' |
38789
9b64b73d702b
exchange: move disabling of rev-branch-cache bundle part out of narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38614
diff
changeset
|
50 |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
51 |
21064
4d9d490d7bbe
bundle2: add a ui argument to readbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21063
diff
changeset
|
52 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
|
53 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
|
54 |
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
|
55 alg = None |
21063
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
56 if not fname: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
57 fname = b"stream" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
58 if not header.startswith(b'HG') and header.startswith(b'\0'): |
21063
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
59 fh = changegroup.headerlessfixup(fh, header) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
60 header = b"HG10" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
61 alg = b'UN' |
21063
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
62 elif vfs: |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
63 fname = vfs.join(fname) |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
64 |
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
|
65 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
|
66 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
67 if magic != b'HG': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
68 raise error.Abort(_(b'%s: not a Mercurial bundle') % fname) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
69 if version == b'10': |
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
|
70 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
|
71 alg = changegroup.readexactly(fh, 2) |
22390
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22354
diff
changeset
|
72 return changegroup.cg1unpacker(fh, alg) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
73 elif version.startswith(b'2'): |
25640
39f0064a3079
bundle2.getunbundler: rename "header" to "magicstring"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25559
diff
changeset
|
74 return bundle2.getunbundler(ui, fh, magicstring=magic + version) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
75 elif version == b'S1': |
26756
9e272a96f764
exchange: support for streaming clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26732
diff
changeset
|
76 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
|
77 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
78 raise error.Abort( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
79 _(b'%s: unknown bundle version %s') % (fname, version) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
80 ) |
21063
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
81 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
82 |
49334
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
83 def _format_params(params): |
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
84 parts = [] |
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
85 for key, value in sorted(params.items()): |
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
86 value = urlreq.quote(value) |
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
87 parts.append(b"%s=%s" % (key, value)) |
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
88 return b';'.join(parts) |
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
89 |
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
90 |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
91 def getbundlespec(ui, fh): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
92 """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
|
93 |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
94 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
|
95 restored. |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
96 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
97 |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
98 def speccompression(alg): |
30440
c3944ab1443a
exchange: obtain compression engines from the registrar
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30332
diff
changeset
|
99 try: |
c3944ab1443a
exchange: obtain compression engines from the registrar
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30332
diff
changeset
|
100 return util.compengines.forbundletype(alg).bundletype()[0] |
c3944ab1443a
exchange: obtain compression engines from the registrar
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30332
diff
changeset
|
101 except KeyError: |
c3944ab1443a
exchange: obtain compression engines from the registrar
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30332
diff
changeset
|
102 return None |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
103 |
49334
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
104 params = {} |
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
105 |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
106 b = readbundle(ui, fh, None) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
107 if isinstance(b, changegroup.cg1unpacker): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
108 alg = b._type |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
109 if alg == b'_truncatedBZ': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
110 alg = b'BZ' |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
111 comp = speccompression(alg) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
112 if not comp: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
113 raise error.Abort(_(b'unknown compression algorithm: %s') % alg) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
114 return b'%s-v1' % comp |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
115 elif isinstance(b, bundle2.unbundle20): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
116 if b'Compression' in b.params: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
117 comp = speccompression(b.params[b'Compression']) |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
118 if not comp: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
119 raise error.Abort( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
120 _(b'unknown compression algorithm: %s') % comp |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
121 ) |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
122 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
123 comp = b'none' |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
124 |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
125 version = None |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
126 for part in b.iterparts(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
127 if part.type == b'changegroup': |
49334
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
128 cgversion = part.params[b'version'] |
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
129 if cgversion in (b'01', b'02'): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
130 version = b'v2' |
49334
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
131 elif cgversion in (b'03',): |
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
132 version = b'v2' |
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
133 params[b'cg.version'] = cgversion |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
134 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
135 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
136 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
137 b'changegroup version %s does not have ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
138 b'a known bundlespec' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
139 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
140 % version, |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
141 hint=_(b'try upgrading your Mercurial client'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
142 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
143 elif part.type == b'stream2' and version is None: |
37168
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
144 # A stream2 part requires to be part of a v2 bundle |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
145 requirements = urlreq.unquote(part.params[b'requirements']) |
37168
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
146 splitted = requirements.split() |
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
147 params = bundle2._formatrequirementsparams(splitted) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
148 return b'none-v2;stream=v2;%s' % params |
50533
f4a540c203d7
stream-clone: support streamv3 on the cli [hg bundle]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50530
diff
changeset
|
149 elif part.type == b'stream3-exp' and version is None: |
f4a540c203d7
stream-clone: support streamv3 on the cli [hg bundle]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50530
diff
changeset
|
150 # A stream3 part requires to be part of a v2 bundle |
f4a540c203d7
stream-clone: support streamv3 on the cli [hg bundle]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50530
diff
changeset
|
151 requirements = urlreq.unquote(part.params[b'requirements']) |
f4a540c203d7
stream-clone: support streamv3 on the cli [hg bundle]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50530
diff
changeset
|
152 splitted = requirements.split() |
f4a540c203d7
stream-clone: support streamv3 on the cli [hg bundle]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50530
diff
changeset
|
153 params = bundle2._formatrequirementsparams(splitted) |
f4a540c203d7
stream-clone: support streamv3 on the cli [hg bundle]
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50530
diff
changeset
|
154 return b'none-v2;stream=v3-exp;%s' % params |
49335
04cdb442a892
bundlespec: handle the presence of obsmarker part
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49334
diff
changeset
|
155 elif part.type == b'obsmarkers': |
04cdb442a892
bundlespec: handle the presence of obsmarker part
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49334
diff
changeset
|
156 params[b'obsolescence'] = b'yes' |
04cdb442a892
bundlespec: handle the presence of obsmarker part
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49334
diff
changeset
|
157 if not part.mandatory: |
04cdb442a892
bundlespec: handle the presence of obsmarker part
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49334
diff
changeset
|
158 params[b'obsolescence-mandatory'] = b'no' |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
159 |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
160 if not version: |
51561
7752cf4f64cc
bundle-spec: properly identify changegroup-less bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
161 params[b'changegroup'] = b'no' |
7752cf4f64cc
bundle-spec: properly identify changegroup-less bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
162 version = b'v2' |
49334
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
163 spec = b'%s-%s' % (comp, version) |
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
164 if params: |
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
165 spec += b';' |
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
166 spec += _format_params(params) |
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
167 return spec |
6d15a8971e30
bundlespec: fix the generation of bundlespec for `cg.version`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48946
diff
changeset
|
168 |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
169 elif isinstance(b, streamclone.streamcloneapplier): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
170 requirements = streamclone.readbundle1header(fh)[2] |
37167
6f467adf9f05
bundle: add the possibility to bundle a stream v2 part
Boris Feld <boris.feld@octobus.net>
parents:
37165
diff
changeset
|
171 formatted = bundle2._formatrequirementsparams(requirements) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
172 return b'none-packed1;%s' % formatted |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
173 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
174 raise error.Abort(_(b'unknown bundle type: %s') % b) |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
175 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
176 |
29808
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
177 def _computeoutgoing(repo, heads, common): |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
178 """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:
29807
diff
changeset
|
179 and a set of heads. |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
180 |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
181 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:
29807
diff
changeset
|
182 the logic. |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
183 |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
184 Returns a discovery.outgoing object. |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
185 """ |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
186 cl = repo.changelog |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
187 if common: |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
188 hasnode = cl.hasnode |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
189 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:
29807
diff
changeset
|
190 else: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46977
diff
changeset
|
191 common = [repo.nullid] |
29808
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
192 if not heads: |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
193 heads = cl.heads() |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
194 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:
29807
diff
changeset
|
195 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
196 |
40767
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
197 def _checkpublish(pushop): |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
198 repo = pushop.repo |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
199 ui = repo.ui |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
200 behavior = ui.config(b'experimental', b'auto-publish') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
201 if pushop.publish or behavior not in (b'warn', b'confirm', b'abort'): |
40767
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
202 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
203 remotephases = listkeys(pushop.remote, b'phases') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
204 if not remotephases.get(b'publishing', False): |
40767
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
205 return |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
206 |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
207 if pushop.revs is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
208 published = repo.filtered(b'served').revs(b'not public()') |
40767
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
209 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
210 published = repo.revs(b'::%ln - public()', pushop.revs) |
47492
f03e9d30258e
exchange: use "served" repo filter to guess what the server will publish
Anton Shestakov <av6@dwimlabs.net>
parents:
47226
diff
changeset
|
211 # we want to use pushop.revs in the revset even if they themselves are |
f03e9d30258e
exchange: use "served" repo filter to guess what the server will publish
Anton Shestakov <av6@dwimlabs.net>
parents:
47226
diff
changeset
|
212 # secret, but we don't want to have anything that the server won't see |
f03e9d30258e
exchange: use "served" repo filter to guess what the server will publish
Anton Shestakov <av6@dwimlabs.net>
parents:
47226
diff
changeset
|
213 # in the result of this expression |
f03e9d30258e
exchange: use "served" repo filter to guess what the server will publish
Anton Shestakov <av6@dwimlabs.net>
parents:
47226
diff
changeset
|
214 published &= repo.filtered(b'served') |
40767
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
215 if published: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
216 if behavior == b'warn': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
217 ui.warn( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
218 _(b'%i changesets about to be published\n') % len(published) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
219 ) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
220 elif behavior == b'confirm': |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
221 if ui.promptchoice( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
222 _(b'push and publish %i changesets (yn)?$$ &Yes $$ &No') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
223 % len(published) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
224 ): |
45877
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45784
diff
changeset
|
225 raise error.CanceledError(_(b'user quit')) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
226 elif behavior == b'abort': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
227 msg = _(b'push would publish %i changesets') % len(published) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
228 hint = _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
229 b"use --publish or adjust 'experimental.auto-publish'" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
230 b" config" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
231 ) |
40767
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
232 raise error.Abort(msg, hint=hint) |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
233 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
234 |
29682
2db085d5f5a2
bundle2: rename the _canusebundle2 method to _forcebundle1
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29389
diff
changeset
|
235 def _forcebundle1(op): |
2db085d5f5a2
bundle2: rename the _canusebundle2 method to _forcebundle1
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29389
diff
changeset
|
236 """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
|
237 |
29683
6786c3f8684d
bundle2: add a devel option controling bundle version used for exchange
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29682
diff
changeset
|
238 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:
29682
diff
changeset
|
239 ui = op.repo.ui |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
30187
diff
changeset
|
240 # The goal is this config is to allow developer to choose the bundle |
29683
6786c3f8684d
bundle2: add a devel option controling bundle version used for exchange
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29682
diff
changeset
|
241 # 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:
29682
diff
changeset
|
242 # 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:
29682
diff
changeset
|
243 # 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:
29682
diff
changeset
|
244 # |
6786c3f8684d
bundle2: add a devel option controling bundle version used for exchange
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29682
diff
changeset
|
245 # developer config: devel.legacy.exchange |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
246 exchange = ui.configlist(b'devel', b'legacy.exchange') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
247 forcebundle1 = b'bundle2' not in exchange and b'bundle1' in exchange |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
248 return forcebundle1 or not op.remote.capable(b'bundle2') |
24650
b83a8f512a80
exchange: introduce a '_canusebundle2' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24649
diff
changeset
|
249 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
250 |
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48935
diff
changeset
|
251 class pushoperation: |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
252 """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
|
253 |
28456
d9d51da7a850
pushoperation: fix language issues in docstring
Nathan Goldbaum <ngoldbau@illinois.edu>
parents:
28182
diff
changeset
|
254 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
|
255 |
28456
d9d51da7a850
pushoperation: fix language issues in docstring
Nathan Goldbaum <ngoldbau@illinois.edu>
parents:
28182
diff
changeset
|
256 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
|
257 discarded afterward. |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
258 """ |
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
259 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
260 def __init__( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
261 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
262 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
263 remote, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
264 force=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
265 revs=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
266 newbranch=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
267 bookmarks=(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
268 publish=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
269 pushvars=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
270 ): |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
271 # repo we push from |
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
272 self.repo = repo |
20347
3ec5f833348e
push: ease access to current ui object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20346
diff
changeset
|
273 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
|
274 # 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
|
275 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
|
276 # force option provided |
89f90457979e
push: move `force` argument into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20348
diff
changeset
|
277 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
|
278 # 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
|
279 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
|
280 # bookmark explicitly pushed |
cd7e17aa6040
push: pass list of bookmark to `exchange.push`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22622
diff
changeset
|
281 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
|
282 # 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
|
283 self.newbranch = newbranch |
21901
8612c4ab7f54
push: add a ``pushop.stepsdone`` attribute
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21899
diff
changeset
|
284 # step already performed |
8612c4ab7f54
push: add a ``pushop.stepsdone`` attribute
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21899
diff
changeset
|
285 # (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
|
286 self.stepsdone = set() |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
287 # 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
|
288 # - 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
|
289 # - 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
|
290 # - 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
|
291 # 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
|
292 # - 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
|
293 self.cgresult = None |
22624
eef31f9a4c0f
push: add `pushoperation.bkresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22623
diff
changeset
|
294 # Boolean value for the bookmark push |
eef31f9a4c0f
push: add `pushoperation.bkresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22623
diff
changeset
|
295 self.bkresult = None |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
296 # 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
|
297 self.outgoing = None |
32709
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
298 # all remote topological heads before the push |
20462
0031ef5df586
push: move `remoteheads` into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20441
diff
changeset
|
299 self.remoteheads = None |
32709
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
300 # Details of the remote branch pre and post push |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
301 # |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
302 # mapping: {'branch': ([remoteheads], |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
303 # [newheads], |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
304 # [unsyncedheads], |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
305 # [discardedheads])} |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
306 # - branch: the branch name |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
307 # - remoteheads: the list of remote heads known locally |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
308 # None if the branch is new |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
309 # - newheads: the new remote heads (known locally) with outgoing pushed |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
310 # - unsyncedheads: the list of remote heads unknown locally. |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
311 # - discardedheads: the list of remote heads made obsolete by the push |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
312 self.pushbranchmap = None |
20464
d032417db243
push: move `incoming` into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20463
diff
changeset
|
313 # 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
|
314 self.incoming = None |
34819
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34818
diff
changeset
|
315 # summary of the remote phase situation |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34818
diff
changeset
|
316 self.remotephases = None |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
317 # 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
|
318 self.outdatedphases = None |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
319 # 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
|
320 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
|
321 # outgoing obsmarkers |
22035
24bb01f42e82
push: introduce a discovery step for obsmarker
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22034
diff
changeset
|
322 self.outobsmarkers = set() |
42924
e0bf41b83cef
exchange: avoid unnecessary conversion of bookmark nodes to hex (API)
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
42914
diff
changeset
|
323 # outgoing bookmarks, list of (bm, oldnode | '', newnode | '') |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
324 self.outbookmarks = [] |
23437
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
325 # transaction manager |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
326 self.trmanager = None |
25485
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
327 # 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
|
328 # 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
|
329 self.pkfailcb = {} |
33885 | 330 # an iterable of pushvars or None |
331 self.pushvars = pushvars | |
40686
9b8d1ad851f8
push: add --publish flag to change phase of pushed changesets
Anton Shestakov <av6@dwimlabs.net>
parents:
40492
diff
changeset
|
332 # publish pushed changesets |
9b8d1ad851f8
push: add --publish flag to change phase of pushed changesets
Anton Shestakov <av6@dwimlabs.net>
parents:
40492
diff
changeset
|
333 self.publish = publish |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
334 |
22014
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
335 @util.propertycache |
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
336 def futureheads(self): |
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
337 """future remote heads if the changeset push succeeds""" |
45144
c93dd9d9f1e6
discovery: change users of `outgoing.missingheads` to `outgoing.ancestorsof`
Manuel Jacob <me@manueljacob.de>
parents:
45117
diff
changeset
|
338 return self.outgoing.ancestorsof |
22014
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
339 |
22015
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
340 @util.propertycache |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
341 def fallbackheads(self): |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
342 """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
|
343 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
|
344 # 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
|
345 return self.outgoing.commonheads |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
346 unfi = self.repo.unfiltered() |
51577
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
347 # I want cheads = heads(::push_heads and ::commonheads) |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
348 # |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
349 # To push, we already computed |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
350 # common = (::commonheads) |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
351 # missing = ((commonheads::push_heads) - commonheads) |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
352 # |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
353 # So we basically search |
22015
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
354 # |
51577
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
355 # almost_heads = heads((parents(missing) + push_heads) & common) |
22015
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
356 # |
51577
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
357 # We use "almost" here as this can return revision that are ancestors |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
358 # of other in the set and we need to explicitly turn it into an |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
359 # antichain later. We can do so using: |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
360 # |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
361 # cheads = heads(almost_heads::almost_heads) |
22015
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
362 # |
51577
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
363 # In pratice the code is a bit more convulted to avoid some extra |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
364 # computation. It aims at doing the same computation as highlighted |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
365 # above however. |
26184
327d09f0b5d4
exchange: allow fallbackheads to use lazy set behavior
Durham Goode <durham@fb.com>
parents:
25896
diff
changeset
|
366 common = self.outgoing.common |
51577
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
367 unfi = self.repo.unfiltered() |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
368 cl = unfi.changelog |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
369 to_rev = cl.index.rev |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
370 to_node = cl.node |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
371 parent_revs = cl.parentrevs |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
372 unselected = [] |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
373 cheads = set() |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
374 # XXX-perf: `self.revs` and `outgoing.missing` could hold revs directly |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
375 for n in self.revs: |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
376 r = to_rev(n) |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
377 if r in common: |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
378 cheads.add(r) |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
379 else: |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
380 unselected.append(r) |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
381 known_non_heads = cl.ancestors(cheads, inclusive=True) |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
382 if unselected: |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
383 missing_revs = {to_rev(n) for n in self.outgoing.missing} |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
384 missing_revs.add(nullrev) |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
385 root_points = set() |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
386 for r in missing_revs: |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
387 p1, p2 = parent_revs(r) |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
388 if p1 not in missing_revs and p1 not in known_non_heads: |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
389 root_points.add(p1) |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
390 if p2 not in missing_revs and p2 not in known_non_heads: |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
391 root_points.add(p2) |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
392 if root_points: |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
393 heads = unfi.revs('heads(%ld::%ld)', root_points, root_points) |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
394 cheads.update(heads) |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
395 # XXX-perf: could this be a set of revision? |
b5d494f7d28a
push: rework the computation of fallbackheads to be correct
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50699
diff
changeset
|
396 return [to_node(r) for r in sorted(cheads)] |
22015
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
397 |
22016
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
398 @property |
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
399 def commonheads(self): |
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
400 """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
|
401 if self.cgresult: |
22016
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
402 return self.futureheads |
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
403 else: |
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
404 return self.fallbackheads |
22015
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
405 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
406 |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
407 # mapping of message used when pushing bookmark |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
408 bookmsgmap = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
409 b'update': ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
410 _(b"updating bookmark %s\n"), |
45910
f0626acf007d
errors: drop trailing "!" for some errors about bookmarks
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
411 _(b'updating bookmark %s failed\n'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
412 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
413 b'export': ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
414 _(b"exporting bookmark %s\n"), |
45910
f0626acf007d
errors: drop trailing "!" for some errors about bookmarks
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
415 _(b'exporting bookmark %s failed\n'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
416 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
417 b'delete': ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
418 _(b"deleting remote bookmark %s\n"), |
45910
f0626acf007d
errors: drop trailing "!" for some errors about bookmarks
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
419 _(b'deleting remote bookmark %s failed\n'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
420 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
421 } |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
422 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
423 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
424 def push( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
425 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
426 remote, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
427 force=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
428 revs=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
429 newbranch=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
430 bookmarks=(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
431 publish=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
432 opargs=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
433 ): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45910
diff
changeset
|
434 """Push outgoing changesets (limited by revs) from a local |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
435 repository to remote. Return an integer: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
436 - None means nothing to push |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
437 - 0 means HTTP error |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
438 - 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
|
439 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
|
440 - other values as described by addchangegroup() |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45910
diff
changeset
|
441 """ |
26729
16e69e6b357b
exchange: add oparg to push so that extensions can wrap pushop
Sean Farley <sean@farley.io>
parents:
26700
diff
changeset
|
442 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
|
443 opargs = {} |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
444 pushop = pushoperation( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
445 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
446 remote, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
447 force, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
448 revs, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
449 newbranch, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
450 bookmarks, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
451 publish, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
452 **pycompat.strkwargs(opargs) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
453 ) |
20348
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
454 if pushop.remote.local(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
455 missing = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
456 set(pushop.repo.requirements) - pushop.remote.local().supported |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
457 ) |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
458 if missing: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
459 msg = _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
460 b"required features are not" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
461 b" supported in the destination:" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
462 b" %s" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
463 ) % (b', '.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
|
464 raise error.Abort(msg) |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
465 |
20348
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
466 if not pushop.remote.canpush(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
467 raise error.Abort(_(b"destination does not support push")) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
468 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
469 if not pushop.remote.capable(b'unbundle'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
470 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
471 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
472 b'cannot push: destination does not support the ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
473 b'unbundle wire protocol command' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
474 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
475 ) |
46713
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
476 for category in sorted(bundle2.read_remote_wanted_sidedata(pushop.remote)): |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
477 # Check that a computer is registered for that category for at least |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
478 # one revlog kind. |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
479 for kind, computers in repo._sidedata_computers.items(): |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
480 if computers.get(category): |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
481 break |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
482 else: |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
483 raise error.Abort( |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
484 _( |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
485 b'cannot push: required sidedata category not supported' |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
486 b" by this client: '%s'" |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
487 ) |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
488 % pycompat.bytestr(category) |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
489 ) |
33791
20d663a104fb
exchange: drop now-unnecessary "local" from lock name variables
Martin von Zweigbergk <martinvonz@google.com>
parents:
33790
diff
changeset
|
490 # get lock as we might write phase data |
20d663a104fb
exchange: drop now-unnecessary "local" from lock name variables
Martin von Zweigbergk <martinvonz@google.com>
parents:
33790
diff
changeset
|
491 wlock = lock = None |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
492 try: |
51634
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
493 try: |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
494 # bundle2 push may receive a reply bundle touching bookmarks |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
495 # requiring the wlock. Take it now to ensure proper ordering. |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
496 maypushback = pushop.ui.configbool( |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
497 b'experimental', |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
498 b'bundle2.pushback', |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
499 ) |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
500 if ( |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
501 (not _forcebundle1(pushop)) |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
502 and maypushback |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
503 and not bookmod.bookmarksinstore(repo) |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
504 ): |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
505 wlock = pushop.repo.wlock() |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
506 lock = pushop.repo.lock() |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
507 pushop.trmanager = transactionmanager( |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
508 pushop.repo, b'push-response', pushop.remote.url() |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
509 ) |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
510 except error.LockUnavailable as err: |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
511 # source repo cannot be locked. |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
512 # We do not abort the push, but just disable the local phase |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
513 # synchronisation. |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
514 msg = b'cannot lock source repository: %s\n' |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
515 msg %= stringutil.forcebytestr(err) |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
516 pushop.ui.debug(msg) |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
517 |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
518 pushop.repo.checkpush(pushop) |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
519 _checkpublish(pushop) |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
520 _pushdiscovery(pushop) |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
521 if not pushop.force: |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
522 _checksubrepostate(pushop) |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
523 if not _forcebundle1(pushop): |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
524 _pushbundle2(pushop) |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
525 _pushchangeset(pushop) |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
526 _pushsyncphase(pushop) |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
527 _pushobsolete(pushop) |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
528 _pushbookmark(pushop) |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
529 if pushop.trmanager is not None: |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
530 pushop.trmanager.close() |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
531 finally: |
3b69324d9535
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51633
diff
changeset
|
532 lockmod.release(pushop.trmanager, lock, wlock) |
33701
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
533 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
534 if repo.ui.configbool(b'experimental', b'remotenames'): |
38614
4d5fb4062f0b
remotenames: synchronise remotenames after push also
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38604
diff
changeset
|
535 logexchange.pullremotenames(repo, remote) |
4d5fb4062f0b
remotenames: synchronise remotenames after push also
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38604
diff
changeset
|
536 |
22616
cda85cfc8252
push: `exchange.push` now returns the `pushoperation` object
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22615
diff
changeset
|
537 return pushop |
20352
58300f61b139
push: move bookmarks exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20351
diff
changeset
|
538 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
539 |
22018
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
540 # 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
|
541 pushdiscoveryorder = [] |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
542 |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
543 # Mapping between step name and function |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
544 # |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
545 # 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
|
546 pushdiscoverymapping = {} |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
547 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
548 |
22018
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
549 def pushdiscovery(stepname): |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
550 """decorator for function performing discovery before push |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
551 |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
552 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
|
553 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
|
554 may matter). |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
555 |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
556 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
|
557 from an extension, change the pushdiscovery dictionary directly.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
558 |
22018
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
559 def dec(func): |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
560 assert stepname not in pushdiscoverymapping |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
561 pushdiscoverymapping[stepname] = func |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
562 pushdiscoveryorder.append(stepname) |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
563 return func |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
564 |
22018
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
565 return dec |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
566 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
567 |
20466
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
568 def _pushdiscovery(pushop): |
22018
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
569 """Run all discovery steps""" |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
570 for stepname in pushdiscoveryorder: |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
571 step = pushdiscoverymapping[stepname] |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
572 step(pushop) |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
573 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
574 |
43913
4b7d5d10c45d
exchange: ensure all outgoing subrepo references are present before pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
43821
diff
changeset
|
575 def _checksubrepostate(pushop): |
4b7d5d10c45d
exchange: ensure all outgoing subrepo references are present before pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
43821
diff
changeset
|
576 """Ensure all outgoing referenced subrepo revisions are present locally""" |
48549
28f0092ec89f
exchange: add fast path for subrepo check on push
Joerg Sonnenberger <joerg@bec.de>
parents:
48526
diff
changeset
|
577 |
28f0092ec89f
exchange: add fast path for subrepo check on push
Joerg Sonnenberger <joerg@bec.de>
parents:
48526
diff
changeset
|
578 repo = pushop.repo |
28f0092ec89f
exchange: add fast path for subrepo check on push
Joerg Sonnenberger <joerg@bec.de>
parents:
48526
diff
changeset
|
579 |
28f0092ec89f
exchange: add fast path for subrepo check on push
Joerg Sonnenberger <joerg@bec.de>
parents:
48526
diff
changeset
|
580 # If the repository does not use subrepos, skip the expensive |
28f0092ec89f
exchange: add fast path for subrepo check on push
Joerg Sonnenberger <joerg@bec.de>
parents:
48526
diff
changeset
|
581 # manifest checks. |
28f0092ec89f
exchange: add fast path for subrepo check on push
Joerg Sonnenberger <joerg@bec.de>
parents:
48526
diff
changeset
|
582 if not len(repo.file(b'.hgsub')) or not len(repo.file(b'.hgsubstate')): |
28f0092ec89f
exchange: add fast path for subrepo check on push
Joerg Sonnenberger <joerg@bec.de>
parents:
48526
diff
changeset
|
583 return |
28f0092ec89f
exchange: add fast path for subrepo check on push
Joerg Sonnenberger <joerg@bec.de>
parents:
48526
diff
changeset
|
584 |
43913
4b7d5d10c45d
exchange: ensure all outgoing subrepo references are present before pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
43821
diff
changeset
|
585 for n in pushop.outgoing.missing: |
48549
28f0092ec89f
exchange: add fast path for subrepo check on push
Joerg Sonnenberger <joerg@bec.de>
parents:
48526
diff
changeset
|
586 ctx = repo[n] |
43913
4b7d5d10c45d
exchange: ensure all outgoing subrepo references are present before pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
43821
diff
changeset
|
587 |
4b7d5d10c45d
exchange: ensure all outgoing subrepo references are present before pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
43821
diff
changeset
|
588 if b'.hgsub' in ctx.manifest() and b'.hgsubstate' in ctx.files(): |
4b7d5d10c45d
exchange: ensure all outgoing subrepo references are present before pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
43821
diff
changeset
|
589 for subpath in sorted(ctx.substate): |
4b7d5d10c45d
exchange: ensure all outgoing subrepo references are present before pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
43821
diff
changeset
|
590 sub = ctx.sub(subpath) |
4b7d5d10c45d
exchange: ensure all outgoing subrepo references are present before pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
43821
diff
changeset
|
591 sub.verify(onpush=True) |
4b7d5d10c45d
exchange: ensure all outgoing subrepo references are present before pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
43821
diff
changeset
|
592 |
4b7d5d10c45d
exchange: ensure all outgoing subrepo references are present before pushing
Matt Harbison <matt_harbison@yahoo.com>
parents:
43821
diff
changeset
|
593 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
594 @pushdiscovery(b'changeset') |
22018
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
595 def _pushdiscoverychangeset(pushop): |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
596 """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
|
597 fci = discovery.findcommonincoming |
35305
483b5dd0f1aa
push: restrict common discovery to the pushed set
Boris Feld <boris.feld@octobus.net>
parents:
35268
diff
changeset
|
598 if pushop.revs: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
599 commoninc = fci( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
600 pushop.repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
601 pushop.remote, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
602 force=pushop.force, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
603 ancestorsof=pushop.revs, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
604 ) |
35305
483b5dd0f1aa
push: restrict common discovery to the pushed set
Boris Feld <boris.feld@octobus.net>
parents:
35268
diff
changeset
|
605 else: |
483b5dd0f1aa
push: restrict common discovery to the pushed set
Boris Feld <boris.feld@octobus.net>
parents:
35268
diff
changeset
|
606 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
|
607 common, inc, remoteheads = commoninc |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
608 fco = discovery.findcommonoutgoing |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
609 outgoing = fco( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
610 pushop.repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
611 pushop.remote, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
612 onlyheads=pushop.revs, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
613 commoninc=commoninc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
614 force=pushop.force, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
615 ) |
20466
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
616 pushop.outgoing = outgoing |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
617 pushop.remoteheads = remoteheads |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
618 pushop.incoming = inc |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
619 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
620 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
621 @pushdiscovery(b'phase') |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
622 def _pushdiscoveryphase(pushop): |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
623 """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
|
624 |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
625 (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
|
626 outgoing = pushop.outgoing |
51586
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
627 repo = pushop.repo |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
628 unfi = repo.unfiltered() |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
629 cl = unfi.changelog |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
630 to_rev = cl.index.rev |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
631 remotephases = listkeys(pushop.remote, b'phases') |
37757
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
632 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
633 if ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
634 pushop.ui.configbool(b'ui', b'_usedassubrepo') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
635 and remotephases # server supports phases |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
636 and not pushop.outgoing.missing # no changesets to be pushed |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
637 and remotephases.get(b'publishing', False) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
638 ): |
25337
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
639 # When: |
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
640 # - 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
|
641 # - 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
|
642 # - 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
|
643 # - and remote is publishing |
34817
a80142b03552
exchange: fix issue3781 reference in the comment
Boris Feld <boris.feld@octobus.net>
parents:
34374
diff
changeset
|
644 # We may be in issue 3781 case! |
25337
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
645 # 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
|
646 # 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
|
647 # on the remote. |
34818
6709b5661d1b
phase: simplify the check for issue3781 shortcut in discovery
Boris Feld <boris.feld@octobus.net>
parents:
34817
diff
changeset
|
648 pushop.outdatedphases = [] |
6709b5661d1b
phase: simplify the check for issue3781 shortcut in discovery
Boris Feld <boris.feld@octobus.net>
parents:
34817
diff
changeset
|
649 pushop.fallbackoutdatedphases = [] |
6709b5661d1b
phase: simplify the check for issue3781 shortcut in discovery
Boris Feld <boris.feld@octobus.net>
parents:
34817
diff
changeset
|
650 return |
34819
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34818
diff
changeset
|
651 |
51586
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
652 fallbackheads_rev = {to_rev(n) for n in pushop.fallbackheads} |
51583
22cc679a7312
phases: move RemotePhasesSummary to revision number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51581
diff
changeset
|
653 pushop.remotephases = phases.RemotePhasesSummary( |
22cc679a7312
phases: move RemotePhasesSummary to revision number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51581
diff
changeset
|
654 pushop.repo, |
22cc679a7312
phases: move RemotePhasesSummary to revision number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51581
diff
changeset
|
655 fallbackheads_rev, |
22cc679a7312
phases: move RemotePhasesSummary to revision number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51581
diff
changeset
|
656 remotephases, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
657 ) |
51586
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
658 droots = set(pushop.remotephases.draft_roots) |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
659 |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
660 fallback_publishing = pushop.remotephases.publishing |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
661 push_publishing = pushop.remotephases.publishing or pushop.publish |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
662 missing_revs = {to_rev(n) for n in outgoing.missing} |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
663 drafts = unfi._phasecache.get_raw_set(unfi, phases.draft) |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
664 |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
665 if fallback_publishing: |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
666 fallback_roots = droots - missing_revs |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
667 revset = b'heads(%ld::%ld)' |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
668 else: |
51586
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
669 fallback_roots = droots - drafts |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
670 fallback_roots -= missing_revs |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
671 # Get the list of all revs draft on remote but public here. |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
672 revset = b'heads((%ld::%ld) and public())' |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
673 if not fallback_roots: |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
674 fallback = fallback_rev = [] |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
675 else: |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
676 fallback_rev = unfi.revs(revset, fallback_roots, fallbackheads_rev) |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
677 fallback = [repo[r] for r in fallback_rev] |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
678 |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
679 if push_publishing: |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
680 published = missing_revs.copy() |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
681 else: |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
682 published = missing_revs - drafts |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
683 if pushop.publish: |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
684 published.update(fallbackheads_rev & drafts) |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
685 elif fallback: |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
686 published.update(fallback_rev) |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
687 |
1cef1412af3e
phases: rework the logic of _pushdiscoveryphase to bound complexity
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51584
diff
changeset
|
688 pushop.outdatedphases = [repo[r] for r in cl.headrevs(published)] |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
689 pushop.fallbackoutdatedphases = fallback |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
690 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
691 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
692 @pushdiscovery(b'obsmarker') |
22035
24bb01f42e82
push: introduce a discovery step for obsmarker
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22034
diff
changeset
|
693 def _pushdiscoveryobsmarkers(pushop): |
37757
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
694 if not obsolete.isenabled(pushop.repo, obsolete.exchangeopt): |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
695 return |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
696 |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
697 if not pushop.repo.obsstore: |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
698 return |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
699 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
700 if b'obsolete' not in listkeys(pushop.remote, b'namespaces'): |
37757
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
701 return |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
702 |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
703 repo = pushop.repo |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
704 # very naive computation, that can be quite expensive on big repo. |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
705 # However: evolution is currently slow on them anyway. |
51661
a0f1378b932e
Backed out changeset f28c52a9f7b4
Raphaël Gomès <rgomes@octobus.net>
parents:
51644
diff
changeset
|
706 nodes = (c.node() for c in repo.set(b'::%ln', pushop.futureheads)) |
a0f1378b932e
Backed out changeset f28c52a9f7b4
Raphaël Gomès <rgomes@octobus.net>
parents:
51644
diff
changeset
|
707 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
|
708 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
709 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
710 @pushdiscovery(b'bookmarks') |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
711 def _pushdiscoverybookmarks(pushop): |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
712 ui = pushop.ui |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
713 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
|
714 remote = pushop.remote |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
715 ui.debug(b"checking for updated bookmarks\n") |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
716 ancestors = () |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
717 if pushop.revs: |
38604
2834ac06d5a9
py3: fix revnums in bookmark discovery to be consumable more than once
Yuya Nishihara <yuya@tcha.org>
parents:
38000
diff
changeset
|
718 revnums = pycompat.maplist(repo.changelog.rev, pushop.revs) |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
719 ancestors = repo.changelog.ancestors(revnums, inclusive=True) |
37757
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
720 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
721 remotebookmark = bookmod.unhexlifybookmarks(listkeys(remote, b'bookmarks')) |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
722 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
723 explicit = { |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
724 repo._bookmarks.expandname(bookmark) for bookmark in pushop.bookmarks |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
725 } |
22651
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
726 |
30583
8f8211903b83
bookmarks: make bookmarks.comparebookmarks accept binary nodes (API)
Stanislau Hlebik <stash@fb.com>
parents:
30582
diff
changeset
|
727 comp = bookmod.comparebookmarks(repo, repo._bookmarks, remotebookmark) |
36938
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
728 return _processcompared(pushop, ancestors, explicit, remotebookmark, comp) |
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
729 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
730 |
36938
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
731 def _processcompared(pushop, pushed, explicit, remotebms, comp): |
42914
08fce968d00b
doc: fix up confusing doc comment
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
42820
diff
changeset
|
732 """take decision on bookmarks to push to the remote repo |
36938
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
733 |
42914
08fce968d00b
doc: fix up confusing doc comment
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
42820
diff
changeset
|
734 Exists to help extensions alter this behavior. |
36938
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
735 """ |
23081
e62c330a044f
bookmarks: explicitly track identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23047
diff
changeset
|
736 addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = comp |
30583
8f8211903b83
bookmarks: make bookmarks.comparebookmarks accept binary nodes (API)
Stanislau Hlebik <stash@fb.com>
parents:
30582
diff
changeset
|
737 |
36938
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
738 repo = pushop.repo |
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
739 |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
740 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
|
741 if b in explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
742 explicit.remove(b) |
36938
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
743 if not pushed or repo[scid].rev() in pushed: |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
744 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
|
745 # search added bookmark |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
746 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
|
747 if b in explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
748 explicit.remove(b) |
44372
8407031f195f
bookmarks: prevent pushes of divergent bookmarks (foo@remote)
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44282
diff
changeset
|
749 if bookmod.isdivergent(b): |
8407031f195f
bookmarks: prevent pushes of divergent bookmarks (foo@remote)
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44282
diff
changeset
|
750 pushop.ui.warn(_(b'cannot push divergent bookmark %s!\n') % b) |
8407031f195f
bookmarks: prevent pushes of divergent bookmarks (foo@remote)
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44282
diff
changeset
|
751 pushop.bkresult = 2 |
51636
553eb132366f
bookmark: fix remote bookmark deletion when the push is raced
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51634
diff
changeset
|
752 elif pushed and repo[scid].rev() not in pushed: |
553eb132366f
bookmark: fix remote bookmark deletion when the push is raced
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51634
diff
changeset
|
753 # in case of race or secret |
553eb132366f
bookmark: fix remote bookmark deletion when the push is raced
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51634
diff
changeset
|
754 msg = _(b'cannot push bookmark X without its revision: %s!\n') |
553eb132366f
bookmark: fix remote bookmark deletion when the push is raced
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51634
diff
changeset
|
755 pushop.ui.warn(msg % b) |
553eb132366f
bookmark: fix remote bookmark deletion when the push is raced
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51634
diff
changeset
|
756 pushop.bkresult = 2 |
44372
8407031f195f
bookmarks: prevent pushes of divergent bookmarks (foo@remote)
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44282
diff
changeset
|
757 else: |
8407031f195f
bookmarks: prevent pushes of divergent bookmarks (foo@remote)
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44282
diff
changeset
|
758 pushop.outbookmarks.append((b, b'', scid)) |
22651
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
759 # search for overwritten bookmark |
30583
8f8211903b83
bookmarks: make bookmarks.comparebookmarks accept binary nodes (API)
Stanislau Hlebik <stash@fb.com>
parents:
30582
diff
changeset
|
760 for b, scid, dcid in list(advdst) + list(diverge) + list(differ): |
22651
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
761 if b in explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
762 explicit.remove(b) |
51636
553eb132366f
bookmark: fix remote bookmark deletion when the push is raced
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51634
diff
changeset
|
763 if not pushed or repo[scid].rev() in pushed: |
553eb132366f
bookmark: fix remote bookmark deletion when the push is raced
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51634
diff
changeset
|
764 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
|
765 # search for bookmark to delete |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
766 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
|
767 if b in explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
768 explicit.remove(b) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
769 # treat as "deleted locally" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
770 pushop.outbookmarks.append((b, dcid, b'')) |
23082
0fc4686de1d7
exchange: don't report failure from identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23081
diff
changeset
|
771 # 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
|
772 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
|
773 if b in explicit: |
0fc4686de1d7
exchange: don't report failure from identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23081
diff
changeset
|
774 explicit.remove(b) |
22651
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
775 |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
776 if explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
777 explicit = sorted(explicit) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
778 # we should probably list all of them |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
779 pushop.ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
780 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
781 b'bookmark %s does not exist on the local ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
782 b'or remote repository!\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
783 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
784 % explicit[0] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
785 ) |
22651
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
786 pushop.bkresult = 2 |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
787 |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
788 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
|
789 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
790 |
20465
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
791 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
|
792 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
|
793 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
|
794 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
|
795 # 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
|
796 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
|
797 return False |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
798 # 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
|
799 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
|
800 # 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
|
801 # 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
|
802 if unfi.obsstore: |
45214
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
803 # this message are here for 80 char limit reason |
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
804 mso = _(b"push includes obsolete changeset: %s!") |
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
805 mspd = _(b"push includes phase-divergent changeset: %s!") |
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
806 mscd = _(b"push includes content-divergent changeset: %s!") |
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
807 mst = { |
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
808 b"orphan": _(b"push includes orphan changeset: %s!"), |
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
809 b"phase-divergent": mspd, |
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
810 b"content-divergent": mscd, |
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
811 } |
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
812 # If we are to push if there is at least one |
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
813 # obsolete or unstable changeset in missing, at |
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
814 # least one of the missinghead will be obsolete or |
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
815 # unstable. So checking heads only is ok |
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
816 for node in outgoing.ancestorsof: |
20465
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
817 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
|
818 if ctx.obsolete(): |
45214
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
819 raise error.Abort(mso % ctx) |
33730
52c5ff856b49
context: rename troubled into isunstable
Boris Feld <boris.feld@octobus.net>
parents:
33726
diff
changeset
|
820 elif ctx.isunstable(): |
45214
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
821 # TODO print more than one instability in the abort |
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
822 # message |
6063c1857d0a
exchange: backout changeset c26335fa4225
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45156
diff
changeset
|
823 raise error.Abort(mst[ctx.instabilities()[0]] % ctx) |
25836
dede675dc0c1
bookmarks: mark internal-only config option
Matt Mackall <mpm@selenic.com>
parents:
25668
diff
changeset
|
824 |
26935
c4a7bbc78c74
exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents:
26855
diff
changeset
|
825 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
|
826 return True |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
827 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
828 |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
829 # 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
|
830 b2partsgenorder = [] |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
831 |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
832 # Mapping between step name and function |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
833 # |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
834 # 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
|
835 b2partsgenmapping = {} |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
836 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
837 |
24731
88a36edefea5
bundle2: add an 'idx' argument to the 'b2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24697
diff
changeset
|
838 def b2partsgenerator(stepname, idx=None): |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
839 """decorator for function generating bundle2 part |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
840 |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
841 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
|
842 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
|
843 (this may matter). |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
844 |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
845 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
|
846 from an extension, attack the b2partsgenmapping dictionary directly.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
847 |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
848 def dec(func): |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
849 assert stepname not in b2partsgenmapping |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
850 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
|
851 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
|
852 b2partsgenorder.append(stepname) |
88a36edefea5
bundle2: add an 'idx' argument to the 'b2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24697
diff
changeset
|
853 else: |
88a36edefea5
bundle2: add an 'idx' argument to the 'b2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24697
diff
changeset
|
854 b2partsgenorder.insert(idx, stepname) |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
855 return func |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
856 |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
857 return dec |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
858 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
859 |
26428
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
860 def _pushb2ctxcheckheads(pushop, bundler): |
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
861 """Generate race condition checking parts |
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
862 |
26781
1aee2ab0f902
spelling: trivial spell checking
Mads Kiilerich <madski@unity3d.com>
parents:
26779
diff
changeset
|
863 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
|
864 """ |
32709
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
865 # * 'force' do not check for push race, |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
866 # * if we don't push anything, there are nothing to check. |
45144
c93dd9d9f1e6
discovery: change users of `outgoing.missingheads` to `outgoing.ancestorsof`
Manuel Jacob <me@manueljacob.de>
parents:
45117
diff
changeset
|
867 if not pushop.force and pushop.outgoing.ancestorsof: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
868 allowunrelated = b'related' in bundler.capabilities.get( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
869 b'checkheads', () |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
870 ) |
33138
78fc540c53e1
pushrace: avoid crash on bare push when using concurrent push mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33043
diff
changeset
|
871 emptyremote = pushop.pushbranchmap is None |
78fc540c53e1
pushrace: avoid crash on bare push when using concurrent push mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
33043
diff
changeset
|
872 if not allowunrelated or emptyremote: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
873 bundler.newpart(b'check:heads', data=iter(pushop.remoteheads)) |
32709
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
874 else: |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
875 affected = set() |
48913
f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
876 for branch, heads in pushop.pushbranchmap.items(): |
32709
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
877 remoteheads, newheads, unsyncedheads, discardedheads = heads |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
878 if remoteheads is not None: |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
879 remote = set(remoteheads) |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
880 affected |= set(discardedheads) & remote |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
881 affected |= remote - set(newheads) |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
882 if affected: |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
883 data = iter(sorted(affected)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
884 bundler.newpart(b'check:updated-heads', data=data) |
26428
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
885 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
886 |
34821
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
887 def _pushing(pushop): |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
888 """return True if we are pushing anything""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
889 return bool( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
890 pushop.outgoing.missing |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
891 or pushop.outdatedphases |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
892 or pushop.outobsmarkers |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
893 or pushop.outbookmarks |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
894 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
895 |
34821
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
896 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
897 @b2partsgenerator(b'check-bookmarks') |
35259
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
898 def _pushb2checkbookmarks(pushop, bundler): |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
899 """insert bookmark move checking""" |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
900 if not _pushing(pushop) or pushop.force: |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
901 return |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
902 b2caps = bundle2.bundle2caps(pushop.remote) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
903 hasbookmarkcheck = b'bookmarks' in b2caps |
35259
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
904 if not (pushop.outbookmarks and hasbookmarkcheck): |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
905 return |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
906 data = [] |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
907 for book, old, new in pushop.outbookmarks: |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
908 data.append((book, old)) |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
909 checkdata = bookmod.binaryencode(pushop.repo, data) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
910 bundler.newpart(b'check:bookmarks', data=checkdata) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
911 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
912 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
913 @b2partsgenerator(b'check-phases') |
34821
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
914 def _pushb2checkphases(pushop, bundler): |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
915 """insert phase move checking""" |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
916 if not _pushing(pushop) or pushop.force: |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
917 return |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
918 b2caps = bundle2.bundle2caps(pushop.remote) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
919 hasphaseheads = b'heads' in b2caps.get(b'phases', ()) |
34821
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
920 if pushop.remotephases is not None and hasphaseheads: |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
921 # check that the remote phase has not changed |
45117
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45062
diff
changeset
|
922 checks = {p: [] for p in phases.allphases} |
51583
22cc679a7312
phases: move RemotePhasesSummary to revision number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51581
diff
changeset
|
923 to_node = pushop.repo.unfiltered().changelog.node |
22cc679a7312
phases: move RemotePhasesSummary to revision number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51581
diff
changeset
|
924 checks[phases.public].extend( |
22cc679a7312
phases: move RemotePhasesSummary to revision number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51581
diff
changeset
|
925 to_node(r) for r in pushop.remotephases.public_heads |
22cc679a7312
phases: move RemotePhasesSummary to revision number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51581
diff
changeset
|
926 ) |
22cc679a7312
phases: move RemotePhasesSummary to revision number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51581
diff
changeset
|
927 checks[phases.draft].extend( |
22cc679a7312
phases: move RemotePhasesSummary to revision number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51581
diff
changeset
|
928 to_node(r) for r in pushop.remotephases.draft_roots |
22cc679a7312
phases: move RemotePhasesSummary to revision number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51581
diff
changeset
|
929 ) |
48935
2cce2fa5bcf7
py3: replace pycompat.itervalues(x) with x.values()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48913
diff
changeset
|
930 if any(checks.values()): |
45117
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45062
diff
changeset
|
931 for phase in checks: |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45062
diff
changeset
|
932 checks[phase].sort() |
34821
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
933 checkdata = phases.binaryencode(checks) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
934 bundler.newpart(b'check:phases', data=checkdata) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
935 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
936 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
937 @b2partsgenerator(b'changeset') |
21899
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
938 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
|
939 """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
|
940 |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
941 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
|
942 """ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
943 if b'changesets' in pushop.stepsdone: |
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
|
944 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
945 pushop.stepsdone.add(b'changesets') |
21899
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
946 # 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
|
947 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
|
948 return |
28876
79b8f052ee51
localrepo: refactor prepushoutgoinghook to take a pushop
Mads Kiilerich <madski@unity3d.com>
parents:
28668
diff
changeset
|
949 pushop.repo.prepushoutgoinghooks(pushop) |
26428
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
950 |
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
951 _pushb2ctxcheckheads(pushop, bundler) |
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
952 |
23180
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
953 b2caps = bundle2.bundle2caps(pushop.remote) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
954 version = b'01' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
955 cgversions = b2caps.get(b'changegroup') |
28668
07f1fbf1f758
exchange: make _pushb2ctx() look more like _getbundlechangegrouppart()
Martin von Zweigbergk <martinvonz@google.com>
parents:
28667
diff
changeset
|
956 if cgversions: # 3.1 and 3.2 ship with an empty value |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
957 cgversions = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
958 v |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
959 for v in cgversions |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
960 if v in changegroup.supportedoutgoingversions(pushop.repo) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
961 ] |
23180
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
962 if not cgversions: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
963 raise error.Abort(_(b'no common changegroup version')) |
23180
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
964 version = max(cgversions) |
46713
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
965 |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
966 remote_sidedata = bundle2.read_remote_wanted_sidedata(pushop.remote) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
967 cgstream = changegroup.makestream( |
46713
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
968 pushop.repo, |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
969 pushop.outgoing, |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
970 version, |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
971 b'push', |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
972 bundlecaps=b2caps, |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
973 remote_sidedata=remote_sidedata, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
974 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
975 cgpart = bundler.newpart(b'changegroup', data=cgstream) |
28668
07f1fbf1f758
exchange: make _pushb2ctx() look more like _getbundlechangegrouppart()
Martin von Zweigbergk <martinvonz@google.com>
parents:
28667
diff
changeset
|
976 if cgversions: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
977 cgpart.addparam(b'version', version) |
45552
10284ce3d5ed
scmutil: introduce function to check whether repo uses treemanifest or not
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45372
diff
changeset
|
978 if scmutil.istreemanifest(pushop.repo): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
979 cgpart.addparam(b'treemanifest', b'1') |
47226
19d4802cb304
sidedata: add a 'side-data' repository feature and use it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
980 if repository.REPO_FEATURE_SIDE_DATA in pushop.repo.features: |
43131
c17a63eb5d4c
sidedata: apply basic but tight security around exchange
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
981 cgpart.addparam(b'exp-sidedata', b'1') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
982 |
21899
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
983 def handlereply(op): |
23139
e53f6b72a0e4
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23082
diff
changeset
|
984 """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
|
985 cgreplies = op.records.getreplies(cgpart.id) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
986 assert len(cgreplies[b'changegroup']) == 1 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
987 pushop.cgresult = cgreplies[b'changegroup'][0][b'return'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
988 |
21899
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
989 return handlereply |
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
990 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
991 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
992 @b2partsgenerator(b'phase') |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
993 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
|
994 """handle phase push through bundle2""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
995 if b'phases' in pushop.stepsdone: |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
996 return |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
997 b2caps = bundle2.bundle2caps(pushop.remote) |
34836
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
998 ui = pushop.repo.ui |
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
999 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1000 legacyphase = b'phases' in ui.configlist(b'devel', b'legacy.exchange') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1001 haspushkey = b'pushkey' in b2caps |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1002 hasphaseheads = b'heads' in b2caps.get(b'phases', ()) |
34836
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
1003 |
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
1004 if hasphaseheads and not legacyphase: |
34910
498697fe41f2
exchange: propagate the subfunctions return
Boris Feld <boris.feld@octobus.net>
parents:
34836
diff
changeset
|
1005 return _pushb2phaseheads(pushop, bundler) |
34836
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
1006 elif haspushkey: |
34910
498697fe41f2
exchange: propagate the subfunctions return
Boris Feld <boris.feld@octobus.net>
parents:
34836
diff
changeset
|
1007 return _pushb2phasespushkey(pushop, bundler) |
34822
c1e7ce11db9b
phase: isolate logic to update remote phrase through bundle2 pushkey
Boris Feld <boris.feld@octobus.net>
parents:
34821
diff
changeset
|
1008 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1009 |
34836
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
1010 def _pushb2phaseheads(pushop, bundler): |
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
1011 """push phase information through a bundle2 - binary part""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1012 pushop.stepsdone.add(b'phases') |
34836
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
1013 if pushop.outdatedphases: |
45117
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45062
diff
changeset
|
1014 updates = {p: [] for p in phases.allphases} |
34836
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
1015 updates[0].extend(h.node() for h in pushop.outdatedphases) |
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
1016 phasedata = phases.binaryencode(updates) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1017 bundler.newpart(b'phase-heads', data=phasedata) |
34836
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
1018 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1019 |
34822
c1e7ce11db9b
phase: isolate logic to update remote phrase through bundle2 pushkey
Boris Feld <boris.feld@octobus.net>
parents:
34821
diff
changeset
|
1020 def _pushb2phasespushkey(pushop, bundler): |
c1e7ce11db9b
phase: isolate logic to update remote phrase through bundle2 pushkey
Boris Feld <boris.feld@octobus.net>
parents:
34821
diff
changeset
|
1021 """push phase information through a bundle2 - pushkey part""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1022 pushop.stepsdone.add(b'phases') |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
1023 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
|
1024 |
bd41c19383db
phases: abort the whole push if phases fail to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25501
diff
changeset
|
1025 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
|
1026 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
|
1027 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
|
1028 if partid == targetid: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1029 raise error.Abort(_(b'updating %s to public failed') % node) |
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
|
1030 |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
1031 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
|
1032 for newremotehead in pushop.outdatedphases: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1033 part = bundler.newpart(b'pushkey') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1034 part.addparam(b'namespace', enc(b'phases')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1035 part.addparam(b'key', enc(newremotehead.hex())) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1036 part.addparam(b'old', enc(b'%d' % phases.draft)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1037 part.addparam(b'new', enc(b'%d' % phases.public)) |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
1038 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
|
1039 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
|
1040 |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
1041 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
|
1042 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
|
1043 partrep = op.records.getreplies(partid) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1044 results = partrep[b'pushkey'] |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
1045 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
|
1046 msg = None |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
1047 if not results: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1048 msg = _(b'server ignored update of %s to public!\n') % node |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1049 elif not int(results[0][b'return']): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1050 msg = _(b'updating %s to public failed!\n') % node |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
1051 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
|
1052 pushop.ui.warn(msg) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1053 |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
1054 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
|
1055 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1056 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1057 @b2partsgenerator(b'obsmarkers') |
22347
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
1058 def _pushb2obsmarkers(pushop, bundler): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1059 if b'obsmarkers' in pushop.stepsdone: |
22347
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
1060 return |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
1061 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
|
1062 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
|
1063 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1064 pushop.stepsdone.add(b'obsmarkers') |
22347
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
1065 if pushop.outobsmarkers: |
43580
e513e87b0476
py3: fix sorting of obsolete markers in obsutil (issue6217)
Denis Laxalde <denis@laxalde.org>
parents:
43278
diff
changeset
|
1066 markers = obsutil.sortedmarkers(pushop.outobsmarkers) |
32515
e70d6dbde713
bundle2: move function building obsmarker-part in the bundle2 module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32291
diff
changeset
|
1067 bundle2.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
|
1068 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1069 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1070 @b2partsgenerator(b'bookmarks') |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1071 def _pushb2bookmarks(pushop, bundler): |
25895
c30b739c322f
exchange: s/phase/bookmark/ in _pushb2bookmarks()
Martin von Zweigbergk <martinvonz@google.com>
parents:
25836
diff
changeset
|
1072 """handle bookmark push through bundle2""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1073 if b'bookmarks' in pushop.stepsdone: |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1074 return |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1075 b2caps = bundle2.bundle2caps(pushop.remote) |
35264
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1076 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1077 legacy = pushop.repo.ui.configlist(b'devel', b'legacy.exchange') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1078 legacybooks = b'bookmarks' in legacy |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1079 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1080 if not legacybooks and b'bookmarks' in b2caps: |
35264
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1081 return _pushb2bookmarkspart(pushop, bundler) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1082 elif b'pushkey' in b2caps: |
35262
3fd5f05a5b87
push: move bundle2-pushkey based bookmarks exchange in its own function
Boris Feld <boris.feld@octobus.net>
parents:
35259
diff
changeset
|
1083 return _pushb2bookmarkspushkey(pushop, bundler) |
3fd5f05a5b87
push: move bundle2-pushkey based bookmarks exchange in its own function
Boris Feld <boris.feld@octobus.net>
parents:
35259
diff
changeset
|
1084 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1085 |
35264
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1086 def _bmaction(old, new): |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1087 """small utility for bookmark pushing""" |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1088 if not old: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1089 return b'export' |
35264
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1090 elif not new: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1091 return b'delete' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1092 return b'update' |
35264
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1093 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1094 |
42811
3332bde53714
exchange: abort on pushing bookmarks pointing to secret changesets (issue6159)
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42326
diff
changeset
|
1095 def _abortonsecretctx(pushop, node, b): |
3332bde53714
exchange: abort on pushing bookmarks pointing to secret changesets (issue6159)
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42326
diff
changeset
|
1096 """abort if a given bookmark points to a secret changeset""" |
3332bde53714
exchange: abort on pushing bookmarks pointing to secret changesets (issue6159)
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42326
diff
changeset
|
1097 if node and pushop.repo[node].phase() == phases.secret: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1098 raise error.Abort( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1099 _(b'cannot push bookmark %s as it points to a secret changeset') % b |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1100 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1101 |
42811
3332bde53714
exchange: abort on pushing bookmarks pointing to secret changesets (issue6159)
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42326
diff
changeset
|
1102 |
35264
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1103 def _pushb2bookmarkspart(pushop, bundler): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1104 pushop.stepsdone.add(b'bookmarks') |
35264
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1105 if not pushop.outbookmarks: |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1106 return |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1107 |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1108 allactions = [] |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1109 data = [] |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1110 for book, old, new in pushop.outbookmarks: |
42811
3332bde53714
exchange: abort on pushing bookmarks pointing to secret changesets (issue6159)
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42326
diff
changeset
|
1111 _abortonsecretctx(pushop, new, book) |
35264
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1112 data.append((book, new)) |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1113 allactions.append((book, _bmaction(old, new))) |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
1114 checkdata = bookmod.binaryencode(pushop.repo, data) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1115 bundler.newpart(b'bookmarks', data=checkdata) |
35264
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1116 |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1117 def handlereply(op): |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1118 ui = pushop.ui |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1119 # if success |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1120 for book, action in allactions: |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1121 ui.status(bookmsgmap[action][0] % book) |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1122 |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1123 return handlereply |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1124 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1125 |
35262
3fd5f05a5b87
push: move bundle2-pushkey based bookmarks exchange in its own function
Boris Feld <boris.feld@octobus.net>
parents:
35259
diff
changeset
|
1126 def _pushb2bookmarkspushkey(pushop, bundler): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1127 pushop.stepsdone.add(b'bookmarks') |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1128 part2book = [] |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1129 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
|
1130 |
a99fee62611d
bookmarks: abort the whole push if bookmarks fails to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25485
diff
changeset
|
1131 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
|
1132 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
|
1133 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
|
1134 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
|
1135 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
|
1136 # 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
|
1137 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
|
1138 |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1139 for book, old, new in pushop.outbookmarks: |
42811
3332bde53714
exchange: abort on pushing bookmarks pointing to secret changesets (issue6159)
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
42326
diff
changeset
|
1140 _abortonsecretctx(pushop, new, book) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1141 part = bundler.newpart(b'pushkey') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1142 part.addparam(b'namespace', enc(b'bookmarks')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1143 part.addparam(b'key', enc(book)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1144 part.addparam(b'old', enc(hex(old))) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1145 part.addparam(b'new', enc(hex(new))) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1146 action = b'update' |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1147 if not old: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1148 action = b'export' |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1149 elif not new: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1150 action = b'delete' |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1151 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
|
1152 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
|
1153 |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1154 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
|
1155 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
|
1156 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
|
1157 partrep = op.records.getreplies(partid) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1158 results = partrep[b'pushkey'] |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1159 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
|
1160 if not results: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1161 pushop.ui.warn(_(b'server ignored bookmark %s update\n') % book) |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1162 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1163 ret = int(results[0][b'return']) |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1164 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
|
1165 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
|
1166 else: |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1167 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
|
1168 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
|
1169 pushop.bkresult = 1 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1170 |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1171 return handlereply |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1172 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1173 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1174 @b2partsgenerator(b'pushvars', idx=0) |
33693
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33689
diff
changeset
|
1175 def _getbundlesendvars(pushop, bundler): |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33689
diff
changeset
|
1176 '''send shellvars via bundle2''' |
33885 | 1177 pushvars = pushop.pushvars |
1178 if pushvars: | |
1179 shellvars = {} | |
1180 for raw in pushvars: | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1181 if b'=' not in raw: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1182 msg = ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1183 b"unable to parse variable '%s', should follow " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1184 b"'KEY=VALUE' or 'KEY=' format" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1185 ) |
33885 | 1186 raise error.Abort(msg % raw) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1187 k, v = raw.split(b'=', 1) |
33885 | 1188 shellvars[k] = v |
1189 | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1190 part = bundler.newpart(b'pushvars') |
33693
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33689
diff
changeset
|
1191 |
48913
f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
1192 for key, value in shellvars.items(): |
33693
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33689
diff
changeset
|
1193 part.addparam(key, value, mandatory=False) |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1194 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1195 |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1196 def _pushbundle2(pushop): |
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1197 """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
|
1198 |
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1199 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
|
1200 evolve in the future.""" |
21644
17755dd8c509
bundle2: introduce a bundle2caps function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21643
diff
changeset
|
1201 bundler = bundle2.bundle20(pushop.ui, bundle2.bundle2caps(pushop.remote)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1202 pushback = pushop.trmanager and pushop.ui.configbool( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1203 b'experimental', b'bundle2.pushback' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1204 ) |
23439
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
1205 |
21142
15039ce3e4a3
bundle2: include client capabilities in the pushed bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21141
diff
changeset
|
1206 # create reply capability |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1207 capsblob = bundle2.encodecaps( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1208 bundle2.getrepocaps(pushop.repo, allowpushback=pushback, role=b'client') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1209 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1210 bundler.newpart(b'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
|
1211 replyhandlers = [] |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
1212 for partgenname in b2partsgenorder: |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
1213 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
|
1214 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
|
1215 if callable(ret): |
dab31290c7eb
bundle2: only use callable return as reply handler
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21906
diff
changeset
|
1216 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
|
1217 # 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
|
1218 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
|
1219 return |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1220 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
|
1221 try: |
25485
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
1222 try: |
37646
72e26319f3b8
wireproto: use command executor for unbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
1223 with pushop.remote.commandexecutor() as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1224 reply = e.callcommand( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1225 b'unbundle', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1226 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1227 b'bundle': stream, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1228 b'heads': [b'force'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1229 b'url': pushop.remote.url(), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1230 }, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1231 ).result() |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25640
diff
changeset
|
1232 except error.BundleValueError as exc: |
46977
3f87d2af0bd6
errors: raise RemoteError in some places in exchange.py
Martin von Zweigbergk <martinvonz@google.com>
parents:
46907
diff
changeset
|
1233 raise error.RemoteError(_(b'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
|
1234 try: |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
1235 trgetter = None |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
1236 if pushback: |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
1237 trgetter = pushop.trmanager.transaction |
49765
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
1238 op = bundle2.processbundle( |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
1239 pushop.repo, |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
1240 reply, |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
1241 trgetter, |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
1242 remote=pushop.remote, |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
1243 ) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25640
diff
changeset
|
1244 except error.BundleValueError as exc: |
46977
3f87d2af0bd6
errors: raise RemoteError in some places in exchange.py
Martin von Zweigbergk <martinvonz@google.com>
parents:
46907
diff
changeset
|
1245 raise error.RemoteError(_(b'missing support for %s') % exc) |
26829
58f1645f72c3
bundle2: attribute remote failures to remote (issue4788)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26781
diff
changeset
|
1246 except bundle2.AbortFromPart as exc: |
46478
db9e33beb0fb
bundle2: print "error:abort" message to stderr instead of stdout
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
1247 pushop.ui.error(_(b'remote: %s\n') % exc) |
30908
4c8dcb491974
bundle2: keep hint close to the primary message when remote abort
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30685
diff
changeset
|
1248 if exc.hint is not None: |
46478
db9e33beb0fb
bundle2: print "error:abort" message to stderr instead of stdout
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
1249 pushop.ui.error(_(b'remote: %s\n') % (b'(%s)' % exc.hint)) |
46977
3f87d2af0bd6
errors: raise RemoteError in some places in exchange.py
Martin von Zweigbergk <martinvonz@google.com>
parents:
46907
diff
changeset
|
1250 raise error.RemoteError(_(b'push failed on remote')) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25640
diff
changeset
|
1251 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
|
1252 partid = int(exc.partid) |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
1253 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
|
1254 raise |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
1255 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
|
1256 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
|
1257 rephand(op) |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1258 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1259 |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1260 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
|
1261 """Make the actual push of changeset bundle to remote repo""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1262 if b'changesets' in pushop.stepsdone: |
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
|
1263 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1264 pushop.stepsdone.add(b'changesets') |
21903
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
1265 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
|
1266 return |
33701
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1267 |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1268 # Should have verified this in push(). |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1269 assert pushop.remote.capable(b'unbundle') |
33701
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1270 |
28876
79b8f052ee51
localrepo: refactor prepushoutgoinghook to take a pushop
Mads Kiilerich <madski@unity3d.com>
parents:
28668
diff
changeset
|
1271 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
|
1272 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
|
1273 # 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
|
1274 bundlecaps = None |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1275 # create a changegroup from local |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1276 if pushop.revs is None and not ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1277 outgoing.excluded or pushop.repo.changelog.filteredrevs |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1278 ): |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1279 # push everything, |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1280 # use the fast path, no race possible on push |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1281 cg = changegroup.makechangegroup( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1282 pushop.repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1283 outgoing, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1284 b'01', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1285 b'push', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1286 fastpath=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1287 bundlecaps=bundlecaps, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1288 ) |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1289 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1290 cg = changegroup.makechangegroup( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1291 pushop.repo, outgoing, b'01', b'push', bundlecaps=bundlecaps |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1292 ) |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1293 |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1294 # apply changegroup to remote |
33701
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1295 # local repo finds heads on server, finds out what |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1296 # revs it must push. once revs transferred, if server |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1297 # finds it has different heads (someone else won |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1298 # commit/push race), server aborts. |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1299 if pushop.force: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1300 remoteheads = [b'force'] |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1301 else: |
33701
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1302 remoteheads = pushop.remoteheads |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1303 # ssh: return remote's addchangegroup() |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1304 # http: return remote's addchangegroup() or 0 for error |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1305 pushop.cgresult = pushop.remote.unbundle(cg, remoteheads, pushop.repo.url()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1306 |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1307 |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1308 def _pushsyncphase(pushop): |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
1309 """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
|
1310 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
|
1311 # even when we don't push, exchanging phase data is useful |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1312 remotephases = listkeys(pushop.remote, b'phases') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1313 if ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1314 pushop.ui.configbool(b'ui', b'_usedassubrepo') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1315 and remotephases # server supports phases |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1316 and pushop.cgresult is None # nothing was pushed |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1317 and remotephases.get(b'publishing', False) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1318 ): |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1319 # When: |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1320 # - 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
|
1321 # - 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
|
1322 # - 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
|
1323 # - 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
|
1324 # 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
|
1325 # 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
|
1326 # 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
|
1327 # on the remote. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1328 remotephases = {b'publishing': b'True'} |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1329 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
|
1330 _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
|
1331 # 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
|
1332 else: |
51581
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
1333 unfi = pushop.repo.unfiltered() |
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
1334 to_rev = unfi.changelog.index.rev |
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
1335 to_node = unfi.changelog.node |
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
1336 cheads_revs = [to_rev(n) for n in cheads] |
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
1337 pheads_revs, _dr = phases.analyze_remote_phases( |
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
1338 pushop.repo, |
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
1339 cheads_revs, |
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
1340 remotephases, |
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
1341 ) |
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
1342 pheads = [to_node(r) for r in pheads_revs] |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1343 ### Apply remote phase on local |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1344 if remotephases.get(b'publishing', False): |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1345 _localphasemove(pushop, cheads) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1346 else: # publish = False |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1347 _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
|
1348 _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
|
1349 ### 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
|
1350 |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
1351 if pushop.cgresult: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1352 if b'phases' in pushop.stepsdone: |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
1353 # 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
|
1354 return |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
1355 outdated = pushop.outdatedphases |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
1356 else: |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
1357 outdated = pushop.fallbackoutdatedphases |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
1358 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1359 pushop.stepsdone.add(b'phases') |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
1360 |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
1361 # 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
|
1362 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
|
1363 # 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
|
1364 for newremotehead in outdated: |
37647
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1365 with pushop.remote.commandexecutor() as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1366 r = e.callcommand( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1367 b'pushkey', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1368 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1369 b'namespace': b'phases', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1370 b'key': newremotehead.hex(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1371 b'old': b'%d' % phases.draft, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1372 b'new': b'%d' % phases.public, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1373 }, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1374 ).result() |
37647
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1375 |
23376
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
1376 if not r: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1377 pushop.ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1378 _(b'updating %s to public failed!\n') % newremotehead |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1379 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1380 |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1381 |
20438
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1382 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
|
1383 """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
|
1384 if pushop.trmanager: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1385 phases.advanceboundary( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1386 pushop.repo, pushop.trmanager.transaction(), phase, nodes |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1387 ) |
20438
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1388 else: |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1389 # 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
|
1390 # 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
|
1391 # applicable. |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1392 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
|
1393 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
|
1394 if actualmoves: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1395 pushop.ui.status( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1396 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1397 b'cannot lock source repo, skipping ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1398 b'local %s phase update\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1399 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1400 % phasestr |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1401 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1402 |
20438
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1403 |
20433
6af248474224
push: feed pushoperation object to _pushobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20432
diff
changeset
|
1404 def _pushobsolete(pushop): |
20434
e009e59e4566
push: drop now outdated comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20433
diff
changeset
|
1405 """utility function to push obsolete markers to a remote""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1406 if b'obsmarkers' in pushop.stepsdone: |
22036
f1528ef123f4
push: use stepsdone for obsmarkers push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22035
diff
changeset
|
1407 return |
20433
6af248474224
push: feed pushoperation object to _pushobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20432
diff
changeset
|
1408 repo = pushop.repo |
6af248474224
push: feed pushoperation object to _pushobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20432
diff
changeset
|
1409 remote = pushop.remote |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1410 pushop.stepsdone.add(b'obsmarkers') |
22350
6d113cc7a31a
push: only push obsmarkers relevant to the "pushed subset"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22347
diff
changeset
|
1411 if pushop.outobsmarkers: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1412 pushop.ui.debug(b'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
|
1413 rslts = [] |
43580
e513e87b0476
py3: fix sorting of obsolete markers in obsutil (issue6217)
Denis Laxalde <denis@laxalde.org>
parents:
43278
diff
changeset
|
1414 markers = obsutil.sortedmarkers(pushop.outobsmarkers) |
43278
2c70dd03b743
py3: fix sorting of obsolete markers during push
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
43277
diff
changeset
|
1415 remotedata = obsolete._pushkeyescape(markers) |
20432
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1416 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
|
1417 # 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
|
1418 data = remotedata[key] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1419 rslts.append(remote.pushkey(b'obsolete', key, b'', data)) |
20432
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1420 if [r for r in rslts if not r]: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1421 msg = _(b'failed to push some obsolete markers!\n') |
20432
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1422 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
|
1423 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1424 |
20431
bebf8b8479f3
push: feed pushoperation object to _pushbookmark function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20352
diff
changeset
|
1425 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
|
1426 """Update bookmark position on remote""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1427 if pushop.cgresult == 0 or b'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
|
1428 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1429 pushop.stepsdone.add(b'bookmarks') |
20431
bebf8b8479f3
push: feed pushoperation object to _pushbookmark function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20352
diff
changeset
|
1430 ui = pushop.ui |
bebf8b8479f3
push: feed pushoperation object to _pushbookmark function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20352
diff
changeset
|
1431 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
|
1432 |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
1433 for b, old, new in pushop.outbookmarks: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1434 action = b'update' |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1435 if not old: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1436 action = b'export' |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1437 elif not new: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1438 action = b'delete' |
37647
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1439 |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1440 with remote.commandexecutor() as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1441 r = e.callcommand( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1442 b'pushkey', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1443 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1444 b'namespace': b'bookmarks', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1445 b'key': b, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1446 b'old': hex(old), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1447 b'new': hex(new), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1448 }, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1449 ).result() |
37647
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1450 |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1451 if r: |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1452 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
|
1453 else: |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1454 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
|
1455 # 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
|
1456 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
|
1457 pushop.bkresult = 1 |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1458 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1459 |
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48935
diff
changeset
|
1460 class pulloperation: |
20472
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1461 """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
|
1462 |
23219
61cd79ac4b99
exchange: swap "push" for "pull" in pulloperation docstring
Mike Edgar <adgar@google.com>
parents:
23218
diff
changeset
|
1463 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
|
1464 |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
1465 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
|
1466 afterward. |
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1467 """ |
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1468 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1469 def __init__( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1470 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1471 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1472 remote, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1473 heads=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1474 force=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1475 bookmarks=(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1476 remotebookmarks=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1477 streamclonerequested=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1478 includepats=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1479 excludepats=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1480 depth=None, |
48292
aad84024660f
pull: make the new argument a keyword argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48242
diff
changeset
|
1481 path=None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1482 ): |
20596
004a1744088d
exchange: fix docs for pulloperation
Siddharth Agarwal <sid0@fb.com>
parents:
20489
diff
changeset
|
1483 # repo we pull into |
20472
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1484 self.repo = repo |
20596
004a1744088d
exchange: fix docs for pulloperation
Siddharth Agarwal <sid0@fb.com>
parents:
20489
diff
changeset
|
1485 # 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
|
1486 self.remote = remote |
48241
7d1e60244561
path: keep the path instance in the `pulloperation`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47492
diff
changeset
|
1487 # path object used to build this remote |
7d1e60244561
path: keep the path instance in the `pulloperation`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47492
diff
changeset
|
1488 # |
7d1e60244561
path: keep the path instance in the `pulloperation`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47492
diff
changeset
|
1489 # Ideally, the remote peer would carry that directly. |
7d1e60244561
path: keep the path instance in the `pulloperation`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47492
diff
changeset
|
1490 self.remote_path = path |
20474
c9bceafc61be
pull: move `heads` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20473
diff
changeset
|
1491 # 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
|
1492 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
|
1493 # bookmark pulled explicitly |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1494 self.explicitbookmarks = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1495 repo._bookmarks.expandname(bookmark) for bookmark in bookmarks |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1496 ] |
20475
b79b405583af
pull: move `force` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20474
diff
changeset
|
1497 # do we force pull? |
b79b405583af
pull: move `force` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20474
diff
changeset
|
1498 self.force = force |
26448
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1499 # whether a streaming clone was requested |
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1500 self.streamclonerequested = streamclonerequested |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1501 # transaction manager |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1502 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
|
1503 # 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
|
1504 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
|
1505 # 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
|
1506 self.rheads = None |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
1507 # 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
|
1508 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
|
1509 # 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
|
1510 self.remotebookmarks = remotebookmarks |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
1511 # 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
|
1512 self.cgresult = None |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1513 # list of step already done |
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1514 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
|
1515 # 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
|
1516 self.clonebundleattempted = False |
39553
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1517 # Set of file patterns to include. |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1518 self.includepats = includepats |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1519 # Set of file patterns to exclude. |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1520 self.excludepats = excludepats |
40331
ac59de55c8b4
exchange: support declaring pull depth
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39911
diff
changeset
|
1521 # Number of ancestor changesets to pull from each pulled head. |
ac59de55c8b4
exchange: support declaring pull depth
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39911
diff
changeset
|
1522 self.depth = depth |
20487
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1523 |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1524 @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
|
1525 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
|
1526 """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
|
1527 # 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
|
1528 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
|
1529 # 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
|
1530 # 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
|
1531 c = set(self.common) |
09e7118715eb
pull: prevent duplicated entry in `op.pulledsubset`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20596
diff
changeset
|
1532 ret = list(self.common) |
09e7118715eb
pull: prevent duplicated entry in `op.pulledsubset`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20596
diff
changeset
|
1533 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
|
1534 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
|
1535 ret.append(n) |
09e7118715eb
pull: prevent duplicated entry in `op.pulledsubset`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20596
diff
changeset
|
1536 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
|
1537 else: |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1538 # 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
|
1539 # 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
|
1540 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
|
1541 |
26464
9a7fc6d48898
exchange: expose bundle2 capabilities on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26462
diff
changeset
|
1542 @util.propertycache |
26465
eda32ee9962f
exchange: expose bundle2 availability on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26464
diff
changeset
|
1543 def canusebundle2(self): |
29682
2db085d5f5a2
bundle2: rename the _canusebundle2 method to _forcebundle1
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29389
diff
changeset
|
1544 return not _forcebundle1(self) |
26465
eda32ee9962f
exchange: expose bundle2 availability on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26464
diff
changeset
|
1545 |
eda32ee9962f
exchange: expose bundle2 availability on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26464
diff
changeset
|
1546 @util.propertycache |
26464
9a7fc6d48898
exchange: expose bundle2 capabilities on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26462
diff
changeset
|
1547 def remotebundle2caps(self): |
9a7fc6d48898
exchange: expose bundle2 capabilities on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26462
diff
changeset
|
1548 return bundle2.bundle2caps(self.remote) |
9a7fc6d48898
exchange: expose bundle2 capabilities on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26462
diff
changeset
|
1549 |
20477
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
1550 def gettransaction(self): |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1551 # deprecated; talk to trmanager directly |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1552 return self.trmanager.transaction() |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1553 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1554 |
33793
bbbbd3c30bfc
util: add base class for transactional context managers
Martin von Zweigbergk <martinvonz@google.com>
parents:
33792
diff
changeset
|
1555 class transactionmanager(util.transactional): |
23543
4dd8a6a1240d
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23439
diff
changeset
|
1556 """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
|
1557 |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1558 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
|
1559 closing the transaction.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1560 |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1561 def __init__(self, repo, source, url): |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1562 self.repo = repo |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1563 self.source = source |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1564 self.url = url |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1565 self._tr = None |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1566 |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1567 def transaction(self): |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1568 """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
|
1569 if not self._tr: |
46907
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
1570 trname = b'%s\n%s' % (self.source, urlutil.hidepassword(self.url)) |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1571 self._tr = self.repo.transaction(trname) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1572 self._tr.hookargs[b'source'] = self.source |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1573 self._tr.hookargs[b'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
|
1574 return self._tr |
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
1575 |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1576 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
|
1577 """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
|
1578 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
|
1579 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
|
1580 |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1581 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
|
1582 """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
|
1583 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
|
1584 self._tr.release() |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1585 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1586 |
37757
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
1587 def listkeys(remote, namespace): |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
1588 with remote.commandexecutor() as e: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1589 return e.callcommand(b'listkeys', {b'namespace': namespace}).result() |
37757
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
1590 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1591 |
37498
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1592 def _fullpullbundle2(repo, pullop): |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1593 # The server may send a partial reply, i.e. when inlining |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1594 # pre-computed bundles. In that case, update the common |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1595 # set based on the results and pull another bundle. |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1596 # |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1597 # There are two indicators that the process is finished: |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1598 # - no changeset has been added, or |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1599 # - all remote heads are known locally. |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1600 # The head check must use the unfiltered view as obsoletion |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1601 # markers can hide heads. |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1602 unfi = repo.unfiltered() |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1603 unficl = unfi.changelog |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1604 |
37498
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1605 def headsofdiff(h1, h2): |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1606 """Returns heads(h1 % h2)""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1607 res = unfi.set(b'heads(%ln %% %ln)', h1, h2) |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44372
diff
changeset
|
1608 return {ctx.node() for ctx in res} |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1609 |
37498
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1610 def headsofunion(h1, h2): |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1611 """Returns heads((h1 + h2) - null)""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1612 res = unfi.set(b'heads((%ln + %ln - null))', h1, h2) |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44372
diff
changeset
|
1613 return {ctx.node() for ctx in res} |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1614 |
37498
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1615 while True: |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1616 old_heads = unficl.heads() |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1617 clstart = len(unficl) |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1618 _pullbundle2(pullop) |
45372
77b8588dd84e
requirements: introduce new requirements related module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45371
diff
changeset
|
1619 if requirements.NARROW_REQUIREMENT in repo.requirements: |
37498
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1620 # XXX narrow clones filter the heads on the server side during |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1621 # XXX getbundle and result in partial replies as well. |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1622 # XXX Disable pull bundles in this case as band aid to avoid |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1623 # XXX extra round trips. |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1624 break |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1625 if clstart == len(unficl): |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1626 break |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1627 if all(unficl.hasnode(n) for n in pullop.rheads): |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1628 break |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1629 new_heads = headsofdiff(unficl.heads(), old_heads) |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1630 pullop.common = headsofunion(new_heads, pullop.common) |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1631 pullop.rheads = set(pullop.rheads) - pullop.common |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1632 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1633 |
44545
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1634 def add_confirm_callback(repo, pullop): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45910
diff
changeset
|
1635 """adds a finalize callback to transaction which can be used to show stats |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45910
diff
changeset
|
1636 to user and confirm the pull before committing transaction""" |
44545
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1637 |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1638 tr = pullop.trmanager.transaction() |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1639 scmutil.registersummarycallback( |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1640 repo, tr, txnname=b'pull', as_validator=True |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1641 ) |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1642 reporef = weakref.ref(repo.unfiltered()) |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1643 |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1644 def prompt(tr): |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1645 repo = reporef() |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1646 cm = _(b'accept incoming changes (yn)?$$ &Yes $$ &No') |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1647 if repo.ui.promptchoice(cm): |
45681
a736ab681b78
errors: stop passing non-strings to Abort's constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45552
diff
changeset
|
1648 raise error.Abort(b"user aborted") |
44545
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1649 |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1650 tr.addvalidator(b'900-pull-prompt', prompt) |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1651 |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1652 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1653 def pull( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1654 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1655 remote, |
48241
7d1e60244561
path: keep the path instance in the `pulloperation`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47492
diff
changeset
|
1656 path=None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1657 heads=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1658 force=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1659 bookmarks=(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1660 opargs=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1661 streamclonerequested=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1662 includepats=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1663 excludepats=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1664 depth=None, |
44545
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1665 confirm=None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1666 ): |
26440
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1667 """Fetch repository data from a remote. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1668 |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1669 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
|
1670 |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1671 ``repo`` is the local repository to clone into. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1672 ``remote`` is a peer instance. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1673 ``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
|
1674 default) means to pull everything from the remote. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1675 ``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
|
1676 default, all remote bookmarks are pulled. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1677 ``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
|
1678 initialization. |
26448
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1679 ``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
|
1680 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
|
1681 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
|
1682 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
|
1683 configuration for preferring stream clones. |
39553
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1684 ``includepats`` and ``excludepats`` define explicit file patterns to |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1685 include and exclude in storage, respectively. If not defined, narrow |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1686 patterns from the repo instance are used, if available. |
40331
ac59de55c8b4
exchange: support declaring pull depth
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39911
diff
changeset
|
1687 ``depth`` is an integer indicating the DAG depth of history we're |
ac59de55c8b4
exchange: support declaring pull depth
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39911
diff
changeset
|
1688 interested in. If defined, for each revision specified in ``heads``, we |
ac59de55c8b4
exchange: support declaring pull depth
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39911
diff
changeset
|
1689 will fetch up to this many of its ancestors and data associated with them. |
44545
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1690 ``confirm`` is a boolean indicating whether the pull should be confirmed |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1691 before committing the transaction. This overrides HGPLAIN. |
26440
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1692 |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1693 Returns the ``pulloperation`` created for this pull. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1694 """ |
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
|
1695 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
|
1696 opargs = {} |
39553
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1697 |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1698 # We allow the narrow patterns to be passed in explicitly to provide more |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1699 # flexibility for API consumers. |
50530
b361e9da3c3b
exchange: allow passing no includes/excludes to `pull()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
50524
diff
changeset
|
1700 if includepats is not None or excludepats is not None: |
39553
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1701 includepats = includepats or set() |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1702 excludepats = excludepats or set() |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1703 else: |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1704 includepats, excludepats = repo.narrowpats |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1705 |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1706 narrowspec.validatepatterns(includepats) |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1707 narrowspec.validatepatterns(excludepats) |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1708 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1709 pullop = pulloperation( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1710 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1711 remote, |
48241
7d1e60244561
path: keep the path instance in the `pulloperation`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47492
diff
changeset
|
1712 path=path, |
7d1e60244561
path: keep the path instance in the `pulloperation`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47492
diff
changeset
|
1713 heads=heads, |
7d1e60244561
path: keep the path instance in the `pulloperation`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47492
diff
changeset
|
1714 force=force, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1715 bookmarks=bookmarks, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1716 streamclonerequested=streamclonerequested, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1717 includepats=includepats, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1718 excludepats=excludepats, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1719 depth=depth, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1720 **pycompat.strkwargs(opargs) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1721 ) |
33702
033484935391
exchange: access requirements on repo instead of peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33701
diff
changeset
|
1722 |
033484935391
exchange: access requirements on repo instead of peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33701
diff
changeset
|
1723 peerlocal = pullop.remote.local() |
033484935391
exchange: access requirements on repo instead of peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33701
diff
changeset
|
1724 if peerlocal: |
033484935391
exchange: access requirements on repo instead of peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33701
diff
changeset
|
1725 missing = set(peerlocal.requirements) - pullop.repo.supported |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1726 if missing: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1727 msg = _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1728 b"required features are not" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1729 b" supported in the destination:" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1730 b" %s" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1731 ) % (b', '.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
|
1732 raise error.Abort(msg) |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1733 |
46713
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1734 for category in repo._wanted_sidedata: |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1735 # Check that a computer is registered for that category for at least |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1736 # one revlog kind. |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1737 for kind, computers in repo._sidedata_computers.items(): |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1738 if computers.get(category): |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1739 break |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1740 else: |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1741 # This should never happen since repos are supposed to be able to |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1742 # generate the sidedata they require. |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1743 raise error.ProgrammingError( |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1744 _( |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1745 b'sidedata category requested by local side without local' |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1746 b"support: '%s'" |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1747 ) |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1748 % pycompat.bytestr(category) |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1749 ) |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1750 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1751 pullop.trmanager = transactionmanager(repo, b'pull', remote.url()) |
51633
429d57227e7f
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51561
diff
changeset
|
1752 wlock = util.nullcontextmanager |
42326
5d4ec64a6fcb
exchange: don't take wlock if bookmarks are stored in .hg/store/
Martin von Zweigbergk <martinvonz@google.com>
parents:
42209
diff
changeset
|
1753 if not bookmod.bookmarksinstore(repo): |
51633
429d57227e7f
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51561
diff
changeset
|
1754 wlock = repo.wlock |
429d57227e7f
exchange: fix locking to actually be scoped
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51561
diff
changeset
|
1755 with wlock(), repo.lock(), pullop.trmanager: |
44545
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1756 if confirm or ( |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1757 repo.ui.configbool(b"pull", b"confirm") and not repo.ui.plain() |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1758 ): |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1759 add_confirm_callback(repo, pullop) |
bd7b2c8d06cc
pull: add `--confirm` flag to confirm before writing changes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44452
diff
changeset
|
1760 |
48526 | 1761 # This should ideally be in _pullbundle2(). However, it needs to run |
1762 # before discovery to avoid extra work. | |
1763 _maybeapplyclonebundle(pullop) | |
1764 streamclone.maybeperformlegacystreamclone(pullop) | |
1765 _pulldiscovery(pullop) | |
1766 if pullop.canusebundle2: | |
1767 _fullpullbundle2(repo, pullop) | |
1768 _pullchangeset(pullop) | |
1769 _pullphase(pullop) | |
1770 _pullbookmarks(pullop) | |
1771 _pullobsolete(pullop) | |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1772 |
35236
5a62910948d2
remotenames: move function to pull remotenames from the remoterepo to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35041
diff
changeset
|
1773 # storing remotenames |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1774 if repo.ui.configbool(b'experimental', b'remotenames'): |
35347
a29fe459fc49
remotenames: rename related file and storage dir to logexchange
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35305
diff
changeset
|
1775 logexchange.pullremotenames(repo, remote) |
35236
5a62910948d2
remotenames: move function to pull remotenames from the remoterepo to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35041
diff
changeset
|
1776 |
22693
68439b154063
exchange: have `pull` return the pulloperation object
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22666
diff
changeset
|
1777 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
|
1778 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1779 |
22936
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1780 # 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
|
1781 pulldiscoveryorder = [] |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1782 |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1783 # Mapping between step name and function |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1784 # |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1785 # 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
|
1786 pulldiscoverymapping = {} |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1787 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1788 |
22936
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1789 def pulldiscovery(stepname): |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1790 """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
|
1791 |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1792 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
|
1793 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
|
1794 may matter). |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1795 |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1796 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
|
1797 from an extension, change the pulldiscovery dictionary directly.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1798 |
22936
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1799 def dec(func): |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1800 assert stepname not in pulldiscoverymapping |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1801 pulldiscoverymapping[stepname] = func |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1802 pulldiscoveryorder.append(stepname) |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1803 return func |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1804 |
22936
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1805 return dec |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1806 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1807 |
20900
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1808 def _pulldiscovery(pullop): |
22936
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1809 """Run all discovery steps""" |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1810 for stepname in pulldiscoveryorder: |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1811 step = pulldiscoverymapping[stepname] |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1812 step(pullop) |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1813 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1814 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1815 @pulldiscovery(b'b1:bookmarks') |
25369
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1816 def _pullbookmarkbundle1(pullop): |
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1817 """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
|
1818 |
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1819 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
|
1820 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
|
1821 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
|
1822 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1823 if pullop.canusebundle2 and b'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
|
1824 # 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
|
1825 # 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
|
1826 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1827 books = listkeys(pullop.remote, b'bookmarks') |
35039
d7a4384d2d87
pull: store binary node in pullop.remotebookmarks
Boris Feld <boris.feld@octobus.net>
parents:
34910
diff
changeset
|
1828 pullop.remotebookmarks = bookmod.unhexlifybookmarks(books) |
25369
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1829 |
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1830 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1831 @pulldiscovery(b'changegroup') |
22936
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1832 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
|
1833 """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
|
1834 |
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1835 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
|
1836 at some point.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1837 tmp = discovery.findcommonincoming( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1838 pullop.repo, pullop.remote, heads=pullop.heads, force=pullop.force |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1839 ) |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1840 common, fetch, rheads = tmp |
43545
9c1f4e2f1fc4
index: use `index.has_node` in `exchange._pulldiscoverychangegroup`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43506
diff
changeset
|
1841 has_node = pullop.repo.unfiltered().changelog.index.has_node |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1842 if fetch and rheads: |
34317
e45ec589f962
discovery: avoid dropping remote heads hidden locally
Boris Feld <boris.feld@octobus.net>
parents:
34221
diff
changeset
|
1843 # If a remote heads is filtered locally, put in back in common. |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1844 # |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1845 # 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
|
1846 # 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
|
1847 # 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
|
1848 # 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
|
1849 # |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1850 # 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
|
1851 # 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
|
1852 scommon = set(common) |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1853 for n in rheads: |
43545
9c1f4e2f1fc4
index: use `index.has_node` in `exchange._pulldiscoverychangegroup`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43506
diff
changeset
|
1854 if has_node(n): |
23975
3b7088a5c64c
discovery: properly exclude locally known but filtered heads
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23890
diff
changeset
|
1855 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
|
1856 common.append(n) |
34317
e45ec589f962
discovery: avoid dropping remote heads hidden locally
Boris Feld <boris.feld@octobus.net>
parents:
34221
diff
changeset
|
1857 if set(rheads).issubset(set(common)): |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1858 fetch = [] |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1859 pullop.common = common |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1860 pullop.fetch = fetch |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1861 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
|
1862 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1863 |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1864 def _pullbundle2(pullop): |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1865 """pull data using bundle2 |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1866 |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1867 For now, the only supported data are changegroup.""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1868 kwargs = {b'bundlecaps': caps20to10(pullop.repo, role=b'client')} |
26471
41dd7b2c7e15
exchange: add "streaming all changes" to bundle2 pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26465
diff
changeset
|
1869 |
35761
1908d360f977
pull: reorganize bundle2 argument bundling
Boris Feld <boris.feld@octobus.net>
parents:
35759
diff
changeset
|
1870 # make ui easier to access |
1908d360f977
pull: reorganize bundle2 argument bundling
Boris Feld <boris.feld@octobus.net>
parents:
35759
diff
changeset
|
1871 ui = pullop.repo.ui |
1908d360f977
pull: reorganize bundle2 argument bundling
Boris Feld <boris.feld@octobus.net>
parents:
35759
diff
changeset
|
1872 |
32257
205bd3936179
bundle2: don't check for whether we can do stream clones
Siddharth Agarwal <sid0@fb.com>
parents:
32222
diff
changeset
|
1873 # At the moment we don't do stream clones over bundle2. If that is |
205bd3936179
bundle2: don't check for whether we can do stream clones
Siddharth Agarwal <sid0@fb.com>
parents:
32222
diff
changeset
|
1874 # implemented then here's where the check for that will go. |
35763
7eedbd5d4880
streamclone: add support for bundle2 based stream clone
Boris Feld <boris.feld@octobus.net>
parents:
35762
diff
changeset
|
1875 streaming = streamclone.canperformstreamclone(pullop, bundle2=True)[0] |
26471
41dd7b2c7e15
exchange: add "streaming all changes" to bundle2 pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26465
diff
changeset
|
1876 |
35761
1908d360f977
pull: reorganize bundle2 argument bundling
Boris Feld <boris.feld@octobus.net>
parents:
35759
diff
changeset
|
1877 # declare pull perimeters |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1878 kwargs[b'common'] = pullop.common |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1879 kwargs[b'heads'] = pullop.heads or pullop.rheads |
35761
1908d360f977
pull: reorganize bundle2 argument bundling
Boris Feld <boris.feld@octobus.net>
parents:
35759
diff
changeset
|
1880 |
40492
440f5b65be57
exchange: pass includepats and excludepats as arguments to getbundle()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40352
diff
changeset
|
1881 # check server supports narrow and then adding includepats and excludepats |
440f5b65be57
exchange: pass includepats and excludepats as arguments to getbundle()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40352
diff
changeset
|
1882 servernarrow = pullop.remote.capable(wireprototypes.NARROWCAP) |
440f5b65be57
exchange: pass includepats and excludepats as arguments to getbundle()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40352
diff
changeset
|
1883 if servernarrow and pullop.includepats: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1884 kwargs[b'includepats'] = pullop.includepats |
40492
440f5b65be57
exchange: pass includepats and excludepats as arguments to getbundle()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40352
diff
changeset
|
1885 if servernarrow and pullop.excludepats: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1886 kwargs[b'excludepats'] = pullop.excludepats |
40492
440f5b65be57
exchange: pass includepats and excludepats as arguments to getbundle()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40352
diff
changeset
|
1887 |
35763
7eedbd5d4880
streamclone: add support for bundle2 based stream clone
Boris Feld <boris.feld@octobus.net>
parents:
35762
diff
changeset
|
1888 if streaming: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1889 kwargs[b'cg'] = False |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1890 kwargs[b'stream'] = True |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1891 pullop.stepsdone.add(b'changegroup') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1892 pullop.stepsdone.add(b'phases') |
35763
7eedbd5d4880
streamclone: add support for bundle2 based stream clone
Boris Feld <boris.feld@octobus.net>
parents:
35762
diff
changeset
|
1893 |
7eedbd5d4880
streamclone: add support for bundle2 based stream clone
Boris Feld <boris.feld@octobus.net>
parents:
35762
diff
changeset
|
1894 else: |
35762
40df727b6f4f
pull: preindent some code
Boris Feld <boris.feld@octobus.net>
parents:
35761
diff
changeset
|
1895 # pulling changegroup |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1896 pullop.stepsdone.add(b'changegroup') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1897 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1898 kwargs[b'cg'] = pullop.fetch |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1899 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1900 legacyphase = b'phases' in ui.configlist(b'devel', b'legacy.exchange') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1901 hasbinaryphase = b'heads' in pullop.remotebundle2caps.get(b'phases', ()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1902 if not legacyphase and hasbinaryphase: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1903 kwargs[b'phases'] = True |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1904 pullop.stepsdone.add(b'phases') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1905 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1906 if b'listkeys' in pullop.remotebundle2caps: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1907 if b'phases' not in pullop.stepsdone: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1908 kwargs[b'listkeys'] = [b'phases'] |
35761
1908d360f977
pull: reorganize bundle2 argument bundling
Boris Feld <boris.feld@octobus.net>
parents:
35759
diff
changeset
|
1909 |
35268
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1910 bookmarksrequested = False |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1911 legacybookmark = b'bookmarks' in ui.configlist(b'devel', b'legacy.exchange') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1912 hasbinarybook = b'bookmarks' in pullop.remotebundle2caps |
35268
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1913 |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1914 if pullop.remotebookmarks is not None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1915 pullop.stepsdone.add(b'request-bookmarks') |
35268
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1916 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1917 if ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1918 b'request-bookmarks' not in pullop.stepsdone |
35268
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1919 and pullop.remotebookmarks is None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1920 and not legacybookmark |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1921 and hasbinarybook |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1922 ): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1923 kwargs[b'bookmarks'] = True |
35268
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1924 bookmarksrequested = True |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1925 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1926 if b'listkeys' in pullop.remotebundle2caps: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1927 if b'request-bookmarks' not in pullop.stepsdone: |
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
|
1928 # 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
|
1929 # `hg incoming --bundle` to using this function. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1930 pullop.stepsdone.add(b'request-bookmarks') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1931 kwargs.setdefault(b'listkeys', []).append(b'bookmarks') |
26690
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1932 |
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1933 # 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
|
1934 # 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
|
1935 # 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
|
1936 # 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
|
1937 # differently from those that don't. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1938 if ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1939 pullop.remote.capable(b'clonebundles') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1940 and pullop.heads is None |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46977
diff
changeset
|
1941 and list(pullop.common) == [pullop.repo.nullid] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1942 ): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1943 kwargs[b'cbattempted'] = pullop.clonebundleattempted |
26690
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1944 |
26471
41dd7b2c7e15
exchange: add "streaming all changes" to bundle2 pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26465
diff
changeset
|
1945 if streaming: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1946 pullop.repo.ui.status(_(b'streaming all changes\n')) |
26471
41dd7b2c7e15
exchange: add "streaming all changes" to bundle2 pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26465
diff
changeset
|
1947 elif not pullop.fetch: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1948 pullop.repo.ui.status(_(b"no changes found\n")) |
21258
71931b789424
exchange: fix bad indentation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21257
diff
changeset
|
1949 pullop.cgresult = 0 |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1950 else: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46977
diff
changeset
|
1951 if pullop.heads is None and list(pullop.common) == [pullop.repo.nullid]: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1952 pullop.repo.ui.status(_(b"requesting all changes\n")) |
22953
b1d694d3975e
obsolete: add exchange option
Durham Goode <durham@fb.com>
parents:
22937
diff
changeset
|
1953 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
|
1954 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
|
1955 if obsolete.commonversion(remoteversions) is not None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1956 kwargs[b'obsmarkers'] = True |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1957 pullop.stepsdone.add(b'obsmarkers') |
21159
024f38f6d5f6
bundle2: allow extensions to extend the getbundle request
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21158
diff
changeset
|
1958 _pullbundle2extraprepare(pullop, kwargs) |
37648
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1959 |
46713
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1960 remote_sidedata = bundle2.read_remote_wanted_sidedata(pullop.remote) |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1961 if remote_sidedata: |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1962 kwargs[b'remote_sidedata'] = remote_sidedata |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
1963 |
37648
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1964 with pullop.remote.commandexecutor() as e: |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1965 args = dict(kwargs) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1966 args[b'source'] = b'pull' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1967 bundle = e.callcommand(b'getbundle', args).result() |
37648
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1968 |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1969 try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1970 op = bundle2.bundleoperation( |
49765
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
1971 pullop.repo, |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
1972 pullop.gettransaction, |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
1973 source=b'pull', |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
1974 remote=pullop.remote, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
1975 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1976 op.modes[b'bookmarks'] = b'records' |
49765
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
1977 bundle2.processbundle( |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
1978 pullop.repo, |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
1979 bundle, |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
1980 op=op, |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
1981 remote=pullop.remote, |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
1982 ) |
37648
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1983 except bundle2.AbortFromPart as exc: |
46478
db9e33beb0fb
bundle2: print "error:abort" message to stderr instead of stdout
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
1984 pullop.repo.ui.error(_(b'remote: abort: %s\n') % exc) |
46977
3f87d2af0bd6
errors: raise RemoteError in some places in exchange.py
Martin von Zweigbergk <martinvonz@google.com>
parents:
46907
diff
changeset
|
1985 raise error.RemoteError(_(b'pull failed on remote'), hint=exc.hint) |
37648
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1986 except error.BundleValueError as exc: |
46977
3f87d2af0bd6
errors: raise RemoteError in some places in exchange.py
Martin von Zweigbergk <martinvonz@google.com>
parents:
46907
diff
changeset
|
1987 raise error.RemoteError(_(b'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
|
1988 |
ab5040cd5749
bundle2: fix bundle2 pulling all revs on empty pulls
Durham Goode <durham@fb.com>
parents:
21258
diff
changeset
|
1989 if pullop.fetch: |
33037
d765ad56081f
bundle: make combinechangegroupresults() take a bundleoperation
Martin von Zweigbergk <martinvonz@google.com>
parents:
33036
diff
changeset
|
1990 pullop.cgresult = bundle2.combinechangegroupresults(op) |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1991 |
21658
0696ca0a685b
pull: when remote supports it, pull phase data alongside changesets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21657
diff
changeset
|
1992 # processing phases change |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1993 for namespace, value in op.records[b'listkeys']: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1994 if namespace == b'phases': |
21658
0696ca0a685b
pull: when remote supports it, pull phase data alongside changesets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21657
diff
changeset
|
1995 _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
|
1996 |
22656
c9276945eba3
pull: retrieve bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22655
diff
changeset
|
1997 # processing bookmark update |
35268
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1998 if bookmarksrequested: |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1999 books = {} |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2000 for record in op.records[b'bookmarks']: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2001 books[record[b'bookmark']] = record[b"node"] |
35268
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
2002 pullop.remotebookmarks = books |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
2003 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2004 for namespace, value in op.records[b'listkeys']: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2005 if namespace == b'bookmarks': |
35268
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
2006 pullop.remotebookmarks = bookmod.unhexlifybookmarks(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
|
2007 |
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
|
2008 # 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
|
2009 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
|
2010 _pullbookmarks(pullop) |
22656
c9276945eba3
pull: retrieve bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22655
diff
changeset
|
2011 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2012 |
21159
024f38f6d5f6
bundle2: allow extensions to extend the getbundle request
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21158
diff
changeset
|
2013 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
|
2014 """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
|
2015 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2016 |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
2017 def _pullchangeset(pullop): |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
2018 """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
|
2019 # 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
|
2020 # 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
|
2021 # rollback call |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2022 if b'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
|
2023 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2024 pullop.stepsdone.add(b'changegroup') |
20899
d62319f91cb7
pull: move the cgresult logic in _pullchangeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20898
diff
changeset
|
2025 if not pullop.fetch: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2026 pullop.repo.ui.status(_(b"no changes found\n")) |
23217
2f12ac53b528
exchange: fix indentation in _pullchangeset
Mike Edgar <adgar@google.com>
parents:
23208
diff
changeset
|
2027 pullop.cgresult = 0 |
2f12ac53b528
exchange: fix indentation in _pullchangeset
Mike Edgar <adgar@google.com>
parents:
23208
diff
changeset
|
2028 return |
32930
af31d531dda0
changegroup: let callers pass in transaction to apply() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
32927
diff
changeset
|
2029 tr = pullop.gettransaction() |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46977
diff
changeset
|
2030 if pullop.heads is None and list(pullop.common) == [pullop.repo.nullid]: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2031 pullop.repo.ui.status(_(b"requesting all changes\n")) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2032 elif pullop.heads is None and pullop.remote.capable(b'changegroupsubset'): |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
2033 # 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
|
2034 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
|
2035 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2036 if pullop.remote.capable(b'getbundle'): |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
2037 # TODO: get bundlecaps from remote |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2038 cg = pullop.remote.getbundle( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2039 b'pull', common=pullop.common, heads=pullop.heads or pullop.rheads |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2040 ) |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
2041 elif pullop.heads is None: |
37635
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37498
diff
changeset
|
2042 with pullop.remote.commandexecutor() as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2043 cg = e.callcommand( |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45910
diff
changeset
|
2044 b'changegroup', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45910
diff
changeset
|
2045 { |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45910
diff
changeset
|
2046 b'nodes': pullop.fetch, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45910
diff
changeset
|
2047 b'source': b'pull', |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45910
diff
changeset
|
2048 }, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2049 ).result() |
37635
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37498
diff
changeset
|
2050 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2051 elif not pullop.remote.capable(b'changegroupsubset'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2052 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2053 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2054 b"partial pull cannot be done because " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2055 b"other repository doesn't support " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2056 b"changegroupsubset." |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2057 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2058 ) |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
2059 else: |
37635
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37498
diff
changeset
|
2060 with pullop.remote.commandexecutor() as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2061 cg = e.callcommand( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2062 b'changegroupsubset', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2063 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2064 b'bases': pullop.fetch, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2065 b'heads': pullop.heads, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2066 b'source': b'pull', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2067 }, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2068 ).result() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2069 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2070 bundleop = bundle2.applybundle( |
49765
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
2071 pullop.repo, |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
2072 cg, |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
2073 tr, |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
2074 b'pull', |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
2075 pullop.remote.url(), |
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49335
diff
changeset
|
2076 remote=pullop.remote, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2077 ) |
33040
2baef42a2881
bundle: make applybundle1() return a bundleoperation
Martin von Zweigbergk <martinvonz@google.com>
parents:
33039
diff
changeset
|
2078 pullop.cgresult = bundle2.combinechangegroupresults(bundleop) |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
2079 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2080 |
20486
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
2081 def _pullphase(pullop): |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
2082 # Get remote phases data from remote |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2083 if b'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
|
2084 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2085 remotephases = listkeys(pullop.remote, b'phases') |
21654
ddf9a00c1239
pull: split remote phases retrieval from actual application
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21645
diff
changeset
|
2086 _pullapplyphases(pullop, remotephases) |
ddf9a00c1239
pull: split remote phases retrieval from actual application
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21645
diff
changeset
|
2087 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2088 |
21654
ddf9a00c1239
pull: split remote phases retrieval from actual application
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21645
diff
changeset
|
2089 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
|
2090 """apply phase movement from observed remote state""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2091 if b'phases' in pullop.stepsdone: |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
2092 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2093 pullop.stepsdone.add(b'phases') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2094 publishing = bool(remotephases.get(b'publishing', False)) |
20486
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
2095 if remotephases and not publishing: |
51581
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
2096 unfi = pullop.repo.unfiltered() |
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
2097 to_rev = unfi.changelog.index.rev |
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
2098 to_node = unfi.changelog.node |
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
2099 pulledsubset_revs = [to_rev(n) for n in pullop.pulledsubset] |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
30187
diff
changeset
|
2100 # remote is new and non-publishing |
51581
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
2101 pheads_revs, _dr = phases.analyze_remote_phases( |
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
2102 pullop.repo, |
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
2103 pulledsubset_revs, |
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
2104 remotephases, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2105 ) |
51581
e0194b3ea312
phases: use revision number in analyze_remote_phases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51577
diff
changeset
|
2106 pheads = [to_node(r) for r in pheads_revs] |
22068
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
2107 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
|
2108 else: |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
2109 # 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
|
2110 # 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
|
2111 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
|
2112 dheads = [] |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
2113 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
|
2114 phase = unfi._phasecache.phase |
43563
4d8a4ecbb8b9
index: use `index.get_rev` in `exchange._pullapplyphases`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43562
diff
changeset
|
2115 rev = unfi.changelog.index.get_rev |
22068
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
2116 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
|
2117 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
|
2118 |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
2119 # 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
|
2120 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
|
2121 if pheads: |
22069
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22068
diff
changeset
|
2122 tr = pullop.gettransaction() |
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22068
diff
changeset
|
2123 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
|
2124 |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
2125 # 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
|
2126 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
|
2127 if dheads: |
22069
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22068
diff
changeset
|
2128 tr = pullop.gettransaction() |
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22068
diff
changeset
|
2129 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
|
2130 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2131 |
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
2132 def _pullbookmarks(pullop): |
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
2133 """process the remote bookmark information to update the local one""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2134 if b'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
|
2135 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2136 pullop.stepsdone.add(b'bookmarks') |
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
2137 repo = pullop.repo |
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
2138 remotebookmarks = pullop.remotebookmarks |
48242
4d2ab365699e
bookmarks: move the `mirror` option to the `paths` section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48241
diff
changeset
|
2139 bookmarks_mode = None |
4d2ab365699e
bookmarks: move the `mirror` option to the `paths` section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48241
diff
changeset
|
2140 if pullop.remote_path is not None: |
4d2ab365699e
bookmarks: move the `mirror` option to the `paths` section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48241
diff
changeset
|
2141 bookmarks_mode = pullop.remote_path.bookmarks_mode |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2142 bookmod.updatefromremote( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2143 repo.ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2144 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2145 remotebookmarks, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2146 pullop.remote.url(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2147 pullop.gettransaction, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2148 explicit=pullop.explicitbookmarks, |
48242
4d2ab365699e
bookmarks: move the `mirror` option to the `paths` section
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48241
diff
changeset
|
2149 mode=bookmarks_mode, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2150 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2151 |
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
2152 |
20478
80628d4069be
push: feed pulloperation object to _pullobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20477
diff
changeset
|
2153 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
|
2154 """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
|
2155 |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
2156 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
|
2157 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
|
2158 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
|
2159 |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
2160 Exists mostly to allow overriding for experimentation purpose""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2161 if b'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
|
2162 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2163 pullop.stepsdone.add(b'obsmarkers') |
20476
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
2164 tr = None |
22953
b1d694d3975e
obsolete: add exchange option
Durham Goode <durham@fb.com>
parents:
22937
diff
changeset
|
2165 if obsolete.isenabled(pullop.repo, obsolete.exchangeopt): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2166 pullop.repo.ui.debug(b'fetching remote obsolete markers\n') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2167 remoteobs = listkeys(pullop.remote, b'obsolete') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2168 if b'dump0' in remoteobs: |
20478
80628d4069be
push: feed pulloperation object to _pullobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20477
diff
changeset
|
2169 tr = pullop.gettransaction() |
27558
b5b54825de6b
pull: make a single call to obsstore.add (issue5006)
Matt Mackall <mpm@selenic.com>
parents:
27523
diff
changeset
|
2170 markers = [] |
20476
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
2171 for key in sorted(remoteobs, reverse=True): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2172 if key.startswith(b'dump'): |
32201
4462a981e8df
base85: proxy through util module
Yuya Nishihara <yuya@tcha.org>
parents:
32166
diff
changeset
|
2173 data = util.b85decode(remoteobs[key]) |
27558
b5b54825de6b
pull: make a single call to obsstore.add (issue5006)
Matt Mackall <mpm@selenic.com>
parents:
27523
diff
changeset
|
2174 version, newmarks = obsolete._readmarkers(data) |
b5b54825de6b
pull: make a single call to obsstore.add (issue5006)
Matt Mackall <mpm@selenic.com>
parents:
27523
diff
changeset
|
2175 markers += newmarks |
b5b54825de6b
pull: make a single call to obsstore.add (issue5006)
Matt Mackall <mpm@selenic.com>
parents:
27523
diff
changeset
|
2176 if markers: |
b5b54825de6b
pull: make a single call to obsstore.add (issue5006)
Matt Mackall <mpm@selenic.com>
parents:
27523
diff
changeset
|
2177 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
|
2178 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
|
2179 return tr |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
2180 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2181 |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2182 def applynarrowacl(repo, kwargs): |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2183 """Apply narrow fetch access control. |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2184 |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2185 This massages the named arguments for getbundle wire protocol commands |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2186 so requested data is filtered through access control rules. |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2187 """ |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2188 ui = repo.ui |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2189 # TODO this assumes existence of HTTP and is a layering violation. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2190 username = ui.shortuser(ui.environ.get(b'REMOTE_USER') or ui.username()) |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2191 user_includes = ui.configlist( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2192 _NARROWACL_SECTION, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2193 username + b'.includes', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2194 ui.configlist(_NARROWACL_SECTION, b'default.includes'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2195 ) |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2196 user_excludes = ui.configlist( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2197 _NARROWACL_SECTION, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2198 username + b'.excludes', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2199 ui.configlist(_NARROWACL_SECTION, b'default.excludes'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2200 ) |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2201 if not user_includes: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2202 raise error.Abort( |
43769
27c6d6f53d46
exchange: eliminate some bytes.format() calls
Matt Harbison <matt_harbison@yahoo.com>
parents:
43661
diff
changeset
|
2203 _(b"%s configuration for user %s is empty") |
27c6d6f53d46
exchange: eliminate some bytes.format() calls
Matt Harbison <matt_harbison@yahoo.com>
parents:
43661
diff
changeset
|
2204 % (_NARROWACL_SECTION, username) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2205 ) |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2206 |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2207 user_includes = [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2208 b'path:.' if p == b'*' else b'path:' + p for p in user_includes |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2209 ] |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2210 user_excludes = [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2211 b'path:.' if p == b'*' else b'path:' + p for p in user_excludes |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2212 ] |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2213 |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2214 req_includes = set(kwargs.get('includepats', [])) |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2215 req_excludes = set(kwargs.get('excludepats', [])) |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2216 |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2217 req_includes, req_excludes, invalid_includes = narrowspec.restrictpatterns( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2218 req_includes, req_excludes, user_includes, user_excludes |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2219 ) |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2220 |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2221 if invalid_includes: |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2222 raise error.Abort( |
43769
27c6d6f53d46
exchange: eliminate some bytes.format() calls
Matt Harbison <matt_harbison@yahoo.com>
parents:
43661
diff
changeset
|
2223 _(b"The following includes are not accessible for %s: %s") |
43821
ea97cd64c500
exchange: fix an attempt to format a list into bytes
Matt Harbison <matt_harbison@yahoo.com>
parents:
43795
diff
changeset
|
2224 % (username, stringutil.pprint(invalid_includes)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2225 ) |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2226 |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2227 new_args = {} |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2228 new_args.update(kwargs) |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2229 new_args['narrow'] = True |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2230 new_args['narrow_acl'] = True |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2231 new_args['includepats'] = req_includes |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2232 if req_excludes: |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2233 new_args['excludepats'] = req_excludes |
38807
98df52d5042c
exchange: make narrow ACL presence imply narrow=True
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38792
diff
changeset
|
2234 |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2235 return new_args |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
2236 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2237 |
38791
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2238 def _computeellipsis(repo, common, heads, known, match, depth=None): |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2239 """Compute the shape of a narrowed DAG. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2240 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2241 Args: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2242 repo: The repository we're transferring. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2243 common: The roots of the DAG range we're transferring. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2244 May be just [nullid], which means all ancestors of heads. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2245 heads: The heads of the DAG range we're transferring. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2246 match: The narrowmatcher that allows us to identify relevant changes. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2247 depth: If not None, only consider nodes to be full nodes if they are at |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2248 most depth changesets away from one of heads. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2249 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2250 Returns: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2251 A tuple of (visitnodes, relevant_nodes, ellipsisroots) where: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2252 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2253 visitnodes: The list of nodes (either full or ellipsis) which |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2254 need to be sent to the client. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2255 relevant_nodes: The set of changelog nodes which change a file inside |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2256 the narrowspec. The client needs these as non-ellipsis nodes. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2257 ellipsisroots: A dict of {rev: parents} that is used in |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2258 narrowchangegroup to produce ellipsis nodes with the |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2259 correct parents. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2260 """ |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2261 cl = repo.changelog |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2262 mfl = repo.manifestlog |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2263 |
39158
b0c73866c9fb
exchange: don't use dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
2264 clrev = cl.rev |
b0c73866c9fb
exchange: don't use dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
2265 |
b0c73866c9fb
exchange: don't use dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
2266 commonrevs = {clrev(n) for n in common} | {nullrev} |
b0c73866c9fb
exchange: don't use dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
2267 headsrevs = {clrev(n) for n in heads} |
b0c73866c9fb
exchange: don't use dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
2268 |
38791
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2269 if depth: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2270 revdepth = {h: 0 for h in headsrevs} |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2271 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2272 ellipsisheads = collections.defaultdict(set) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2273 ellipsisroots = collections.defaultdict(set) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2274 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2275 def addroot(head, curchange): |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2276 """Add a root to an ellipsis head, splitting heads with 3 roots.""" |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2277 ellipsisroots[head].add(curchange) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2278 # Recursively split ellipsis heads with 3 roots by finding the |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2279 # roots' youngest common descendant which is an elided merge commit. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2280 # That descendant takes 2 of the 3 roots as its own, and becomes a |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2281 # root of the head. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2282 while len(ellipsisroots[head]) > 2: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2283 child, roots = splithead(head) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2284 splitroots(head, child, roots) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2285 head = child # Recurse in case we just added a 3rd root |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2286 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2287 def splitroots(head, child, roots): |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2288 ellipsisroots[head].difference_update(roots) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2289 ellipsisroots[head].add(child) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2290 ellipsisroots[child].update(roots) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2291 ellipsisroots[child].discard(child) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2292 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2293 def splithead(head): |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2294 r1, r2, r3 = sorted(ellipsisroots[head]) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2295 for nr1, nr2 in ((r2, r3), (r1, r3), (r1, r2)): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2296 mid = repo.revs( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2297 b'sort(merge() & %d::%d & %d::%d, -rev)', nr1, head, nr2, head |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2298 ) |
38791
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2299 for j in mid: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2300 if j == nr2: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2301 return nr2, (nr1, nr2) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2302 if j not in ellipsisroots or len(ellipsisroots[j]) < 2: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2303 return j, (nr1, nr2) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2304 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2305 _( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2306 b'Failed to split up ellipsis node! head: %d, ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2307 b'roots: %d %d %d' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2308 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2309 % (head, r1, r2, r3) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2310 ) |
38791
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2311 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2312 missing = list(cl.findmissingrevs(common=commonrevs, heads=headsrevs)) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2313 visit = reversed(missing) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2314 relevant_nodes = set() |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2315 visitnodes = [cl.node(m) for m in missing] |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2316 required = set(headsrevs) | known |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2317 for rev in visit: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2318 clrev = cl.changelogrevision(rev) |
39158
b0c73866c9fb
exchange: don't use dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
2319 ps = [prev for prev in cl.parentrevs(rev) if prev != nullrev] |
38791
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2320 if depth is not None: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2321 curdepth = revdepth[rev] |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2322 for p in ps: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2323 revdepth[p] = min(curdepth + 1, revdepth.get(p, depth + 1)) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2324 needed = False |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2325 shallow_enough = depth is None or revdepth[rev] <= depth |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2326 if shallow_enough: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2327 curmf = mfl[clrev.manifest].read() |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2328 if ps: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2329 # We choose to not trust the changed files list in |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2330 # changesets because it's not always correct. TODO: could |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2331 # we trust it for the non-merge case? |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2332 p1mf = mfl[cl.changelogrevision(ps[0]).manifest].read() |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2333 needed = bool(curmf.diff(p1mf, match)) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2334 if not needed and len(ps) > 1: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2335 # For merge changes, the list of changed files is not |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2336 # helpful, since we need to emit the merge if a file |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2337 # in the narrow spec has changed on either side of the |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2338 # merge. As a result, we do a manifest diff to check. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2339 p2mf = mfl[cl.changelogrevision(ps[1]).manifest].read() |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2340 needed = bool(curmf.diff(p2mf, match)) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2341 else: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2342 # For a root node, we need to include the node if any |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2343 # files in the node match the narrowspec. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2344 needed = any(curmf.walk(match)) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2345 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2346 if needed: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2347 for head in ellipsisheads[rev]: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2348 addroot(head, rev) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2349 for p in ps: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2350 required.add(p) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2351 relevant_nodes.add(cl.node(rev)) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2352 else: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2353 if not ps: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2354 ps = [nullrev] |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2355 if rev in required: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2356 for head in ellipsisheads[rev]: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2357 addroot(head, rev) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2358 for p in ps: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2359 ellipsisheads[p].add(rev) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2360 else: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2361 for p in ps: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2362 ellipsisheads[p] |= ellipsisheads[rev] |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2363 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2364 # add common changesets as roots of their reachable ellipsis heads |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2365 for c in commonrevs: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2366 for head in ellipsisheads[c]: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2367 addroot(head, c) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2368 return visitnodes, relevant_nodes, ellipsisroots |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2369 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2370 |
35783
c97639ad6874
bundle2: specify what capabilities will be used for
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35765
diff
changeset
|
2371 def caps20to10(repo, role): |
21645
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
2372 """return a set with appropriate options to use bundle20 during getbundle""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2373 caps = {b'HG20'} |
35783
c97639ad6874
bundle2: specify what capabilities will be used for
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35765
diff
changeset
|
2374 capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo, role=role)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2375 caps.add(b'bundle2=' + urlreq.quote(capsblob)) |
21645
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
2376 return caps |
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
2377 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2378 |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2379 # 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
|
2380 getbundle2partsorder = [] |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2381 |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2382 # Mapping between step name and function |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2383 # |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2384 # 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
|
2385 getbundle2partsmapping = {} |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2386 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2387 |
24732
8f70b529cb0c
bundle2: add an 'idx' argument to the 'getbundle2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24731
diff
changeset
|
2388 def getbundle2partsgenerator(stepname, idx=None): |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2389 """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
|
2390 |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2391 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
|
2392 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
|
2393 (this may matter). |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2394 |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2395 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
|
2396 from an extension, attack the getbundle2partsmapping dictionary directly.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2397 |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2398 def dec(func): |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2399 assert stepname not in getbundle2partsmapping |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2400 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
|
2401 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
|
2402 getbundle2partsorder.append(stepname) |
8f70b529cb0c
bundle2: add an 'idx' argument to the 'getbundle2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24731
diff
changeset
|
2403 else: |
8f70b529cb0c
bundle2: add an 'idx' argument to the 'getbundle2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24731
diff
changeset
|
2404 getbundle2partsorder.insert(idx, stepname) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2405 return func |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2406 |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2407 return dec |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2408 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2409 |
27244
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
2410 def bundle2requested(bundlecaps): |
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
2411 if bundlecaps is not None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2412 return any(cap.startswith(b'HG2') for cap in bundlecaps) |
27244
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
2413 return False |
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
2414 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2415 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2416 def getbundlechunks( |
46711
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2417 repo, |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2418 source, |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2419 heads=None, |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2420 common=None, |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2421 bundlecaps=None, |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2422 remote_sidedata=None, |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2423 **kwargs |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2424 ): |
30187
3e86261bf110
exchange: refactor APIs to obtain bundle data (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30068
diff
changeset
|
2425 """Return chunks constituting a bundle's raw data. |
20954
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
2426 |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
2427 Could be a bundle HG10 or a bundle HG20 depending on bundlecaps |
30187
3e86261bf110
exchange: refactor APIs to obtain bundle data (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30068
diff
changeset
|
2428 passed. |
20954
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
2429 |
35785
ba15580e53d5
exchange: return bundle info from getbundlechunks() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35784
diff
changeset
|
2430 Returns a 2-tuple of a dict with metadata about the generated bundle |
ba15580e53d5
exchange: return bundle info from getbundlechunks() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35784
diff
changeset
|
2431 and an iterator over raw chunks (of varying sizes). |
20954
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
2432 """ |
33016
4e6dc34b5d7a
py3: convert kwargs keys' back to bytes using pycompat.byteskwargs()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32991
diff
changeset
|
2433 kwargs = pycompat.byteskwargs(kwargs) |
35785
ba15580e53d5
exchange: return bundle info from getbundlechunks() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35784
diff
changeset
|
2434 info = {} |
27244
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
2435 usebundle2 = bundle2requested(bundlecaps) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2436 # 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
|
2437 if not usebundle2: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2438 if bundlecaps and not kwargs.get(b'cg', True): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2439 raise ValueError( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2440 _(b'request for bundle10 must include changegroup') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2441 ) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2442 |
21656
36200dc6b3bd
getbundle: raise error if extra arguments are provided for bundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21654
diff
changeset
|
2443 if kwargs: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2444 raise ValueError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2445 _(b'unsupported getbundle arguments: %s') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2446 % b', '.join(sorted(kwargs.keys())) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2447 ) |
29808
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
2448 outgoing = _computeoutgoing(repo, heads, common) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2449 info[b'bundleversion'] = 1 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2450 return ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2451 info, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2452 changegroup.makestream( |
46711
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2453 repo, |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2454 outgoing, |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2455 b'01', |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2456 source, |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2457 bundlecaps=bundlecaps, |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2458 remote_sidedata=remote_sidedata, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2459 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2460 ) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2461 |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2462 # bundle20 case |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2463 info[b'bundleversion'] = 2 |
21143
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
2464 b2caps = {} |
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
2465 for bcaps in bundlecaps: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2466 if bcaps.startswith(b'bundle2='): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2467 blob = urlreq.unquote(bcaps[len(b'bundle2=') :]) |
21143
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
2468 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
|
2469 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
|
2470 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2471 kwargs[b'heads'] = heads |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2472 kwargs[b'common'] = common |
23218
0e78ea8e592a
exchange: prepare kwargs for bundle2 part generation exactly once
Mike Edgar <adgar@google.com>
parents:
23217
diff
changeset
|
2473 |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2474 for name in getbundle2partsorder: |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2475 func = getbundle2partsmapping[name] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2476 func( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2477 bundler, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2478 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2479 source, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2480 bundlecaps=bundlecaps, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2481 b2caps=b2caps, |
46711
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2482 remote_sidedata=remote_sidedata, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2483 **pycompat.strkwargs(kwargs) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2484 ) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2485 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2486 info[b'prefercompressed'] = bundler.prefercompressed |
35787
a84dbc87dae9
exchange: send bundle2 stream clones uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35785
diff
changeset
|
2487 |
35785
ba15580e53d5
exchange: return bundle info from getbundlechunks() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35784
diff
changeset
|
2488 return info, bundler.getchunks() |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2489 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2490 |
50524
58adcabc295f
stream-clone: introduce the notion of an experimental "v3" version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49765
diff
changeset
|
2491 @getbundle2partsgenerator(b'stream') |
37167
6f467adf9f05
bundle: add the possibility to bundle a stream v2 part
Boris Feld <boris.feld@octobus.net>
parents:
37165
diff
changeset
|
2492 def _getbundlestream2(bundler, repo, *args, **kwargs): |
6f467adf9f05
bundle: add the possibility to bundle a stream v2 part
Boris Feld <boris.feld@octobus.net>
parents:
37165
diff
changeset
|
2493 return bundle2.addpartbundlestream2(bundler, repo, **kwargs) |
35759
c24dad55ac19
bundle2: add support for a 'stream' parameter to 'getbundle'
Boris Feld <boris.feld@octobus.net>
parents:
35578
diff
changeset
|
2494 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2495 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2496 @getbundle2partsgenerator(b'changegroup') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2497 def _getbundlechangegrouppart( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2498 bundler, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2499 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2500 source, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2501 bundlecaps=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2502 b2caps=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2503 heads=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2504 common=None, |
46711
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2505 remote_sidedata=None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2506 **kwargs |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2507 ): |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2508 """add a changegroup part to the requested bundle""" |
43770
44b605638918
exchange: guard against method invocation on `b2caps=None` args
Matt Harbison <matt_harbison@yahoo.com>
parents:
43769
diff
changeset
|
2509 if not kwargs.get('cg', True) or not b2caps: |
38792
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2510 return |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2511 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2512 version = b'01' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2513 cgversions = b2caps.get(b'changegroup') |
38792
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2514 if cgversions: # 3.1 and 3.2 ship with an empty value |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2515 cgversions = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2516 v |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2517 for v in cgversions |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2518 if v in changegroup.supportedoutgoingversions(repo) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2519 ] |
38792
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2520 if not cgversions: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2521 raise error.Abort(_(b'no common changegroup version')) |
38792
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2522 version = max(cgversions) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2523 |
38792
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2524 outgoing = _computeoutgoing(repo, heads, common) |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2525 if not outgoing.missing: |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2526 return |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2527 |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2528 if kwargs.get('narrow', False): |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2529 include = sorted(filter(bool, kwargs.get('includepats', []))) |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2530 exclude = sorted(filter(bool, kwargs.get('excludepats', []))) |
40344
2c5835b4246b
narrow: when widening, don't include manifests the client already has
Martin von Zweigbergk <martinvonz@google.com>
parents:
40337
diff
changeset
|
2531 matcher = narrowspec.match(repo.root, include=include, exclude=exclude) |
38808
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
2532 else: |
40344
2c5835b4246b
narrow: when widening, don't include manifests the client already has
Martin von Zweigbergk <martinvonz@google.com>
parents:
40337
diff
changeset
|
2533 matcher = None |
38808
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
2534 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2535 cgstream = changegroup.makestream( |
46711
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2536 repo, |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2537 outgoing, |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2538 version, |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2539 source, |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2540 bundlecaps=bundlecaps, |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2541 matcher=matcher, |
a41565bef69f
changegroup: add v4 changegroup for revlog v2 exchange
Raphaël Gomès <rgomes@octobus.net>
parents:
46478
diff
changeset
|
2542 remote_sidedata=remote_sidedata, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2543 ) |
38792
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2544 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2545 part = bundler.newpart(b'changegroup', data=cgstream) |
38792
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2546 if cgversions: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2547 part.addparam(b'version', version) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2548 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2549 part.addparam(b'nbchanges', b'%d' % len(outgoing.missing), mandatory=False) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2550 |
45552
10284ce3d5ed
scmutil: introduce function to check whether repo uses treemanifest or not
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45372
diff
changeset
|
2551 if scmutil.istreemanifest(repo): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2552 part.addparam(b'treemanifest', b'1') |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2553 |
47226
19d4802cb304
sidedata: add a 'side-data' repository feature and use it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47012
diff
changeset
|
2554 if repository.REPO_FEATURE_SIDE_DATA in repo.features: |
43131
c17a63eb5d4c
sidedata: apply basic but tight security around exchange
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
2555 part.addparam(b'exp-sidedata', b'1') |
46713
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
2556 sidedata = bundle2.format_remote_wanted_sidedata(repo) |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46711
diff
changeset
|
2557 part.addparam(b'exp-wanted-sidedata', sidedata) |
43131
c17a63eb5d4c
sidedata: apply basic but tight security around exchange
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
2558 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2559 if ( |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2560 kwargs.get('narrow', False) |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2561 and kwargs.get('narrow_acl', False) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2562 and (include or exclude) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2563 ): |
42209
280f7a095df8
narrow: send specs as bundle2 data instead of param (issue5952) (issue6019)
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
42057
diff
changeset
|
2564 # this is mandatory because otherwise ACL clients won't work |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2565 narrowspecpart = bundler.newpart(b'Narrow:responsespec') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2566 narrowspecpart.data = b'%s\0%s' % ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2567 b'\n'.join(include), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2568 b'\n'.join(exclude), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2569 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2570 |
38808
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
2571 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2572 @getbundle2partsgenerator(b'bookmarks') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2573 def _getbundlebookmarkpart( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2574 bundler, repo, source, bundlecaps=None, b2caps=None, **kwargs |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2575 ): |
35267
cb4dcd7fabe7
getbundle: add support for 'bookmarks' boolean argument
Boris Feld <boris.feld@octobus.net>
parents:
35264
diff
changeset
|
2576 """add a bookmark part to the requested bundle""" |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2577 if not kwargs.get('bookmarks', False): |
35267
cb4dcd7fabe7
getbundle: add support for 'bookmarks' boolean argument
Boris Feld <boris.feld@octobus.net>
parents:
35264
diff
changeset
|
2578 return |
43770
44b605638918
exchange: guard against method invocation on `b2caps=None` args
Matt Harbison <matt_harbison@yahoo.com>
parents:
43769
diff
changeset
|
2579 if not b2caps or b'bookmarks' not in b2caps: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2580 raise error.Abort(_(b'no common bookmarks exchange method')) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2581 books = bookmod.listbinbookmarks(repo) |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
2582 data = bookmod.binaryencode(repo, books) |
35267
cb4dcd7fabe7
getbundle: add support for 'bookmarks' boolean argument
Boris Feld <boris.feld@octobus.net>
parents:
35264
diff
changeset
|
2583 if data: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2584 bundler.newpart(b'bookmarks', data=data) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2585 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2586 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2587 @getbundle2partsgenerator(b'listkeys') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2588 def _getbundlelistkeysparts( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2589 bundler, repo, source, bundlecaps=None, b2caps=None, **kwargs |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2590 ): |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2591 """add parts containing listkeys namespaces to the requested bundle""" |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2592 listkeys = kwargs.get('listkeys', ()) |
21657
0ff44e06275d
getbundle: support of listkeys argument when bundle2 is used
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21656
diff
changeset
|
2593 for namespace in listkeys: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2594 part = bundler.newpart(b'listkeys') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2595 part.addparam(b'namespace', namespace) |
21657
0ff44e06275d
getbundle: support of listkeys argument when bundle2 is used
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21656
diff
changeset
|
2596 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
|
2597 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
|
2598 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2599 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2600 @getbundle2partsgenerator(b'obsmarkers') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2601 def _getbundleobsmarkerpart( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2602 bundler, repo, source, bundlecaps=None, b2caps=None, heads=None, **kwargs |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2603 ): |
22541
4e1a80c022a4
bundle2: pass b2caps down to functions adding bundle2 parts for getbundle
Mike Hommey <mh@glandium.org>
parents:
22390
diff
changeset
|
2604 """add an obsolescence markers part to the requested bundle""" |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2605 if kwargs.get('obsmarkers', False): |
22353
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
2606 if heads is None: |
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
2607 heads = repo.heads() |
51661
a0f1378b932e
Backed out changeset f28c52a9f7b4
Raphaël Gomès <rgomes@octobus.net>
parents:
51644
diff
changeset
|
2608 subset = [c.node() for c in repo.set(b'::%ln', heads)] |
a0f1378b932e
Backed out changeset f28c52a9f7b4
Raphaël Gomès <rgomes@octobus.net>
parents:
51644
diff
changeset
|
2609 markers = repo.obsstore.relevantmarkers(subset) |
43580
e513e87b0476
py3: fix sorting of obsolete markers in obsutil (issue6217)
Denis Laxalde <denis@laxalde.org>
parents:
43278
diff
changeset
|
2610 markers = obsutil.sortedmarkers(markers) |
32515
e70d6dbde713
bundle2: move function building obsmarker-part in the bundle2 module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32291
diff
changeset
|
2611 bundle2.buildobsmarkerspart(bundler, markers) |
22353
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
2612 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2613 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2614 @getbundle2partsgenerator(b'phases') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2615 def _getbundlephasespart( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2616 bundler, repo, source, bundlecaps=None, b2caps=None, heads=None, **kwargs |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2617 ): |
34322
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2618 """add phase heads part to the requested bundle""" |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2619 if kwargs.get('phases', False): |
43795
0f6782df1100
exchange: replace a "not x in ys" by more Pythonic "x not in ys"
Martin von Zweigbergk <martinvonz@google.com>
parents:
43770
diff
changeset
|
2620 if not b2caps or b'heads' not in b2caps.get(b'phases'): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2621 raise error.Abort(_(b'no common phases exchange method')) |
34322
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2622 if heads is None: |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2623 heads = repo.heads() |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2624 |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2625 headsbyphase = collections.defaultdict(set) |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2626 if repo.publishing(): |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2627 headsbyphase[phases.public] = heads |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2628 else: |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2629 # find the appropriate heads to move |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2630 |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2631 phase = repo._phasecache.phase |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2632 node = repo.changelog.node |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2633 rev = repo.changelog.rev |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2634 for h in heads: |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2635 headsbyphase[phase(repo, rev(h))].add(h) |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2636 seenphases = list(headsbyphase.keys()) |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2637 |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2638 # We do not handle anything but public and draft phase for now) |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2639 if seenphases: |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2640 assert max(seenphases) <= phases.draft |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2641 |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2642 # if client is pulling non-public changesets, we need to find |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2643 # intermediate public heads. |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2644 draftheads = headsbyphase.get(phases.draft, set()) |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2645 if draftheads: |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2646 publicheads = headsbyphase.get(phases.public, set()) |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2647 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2648 revset = b'heads(only(%ln, %ln) and public())' |
34322
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2649 extraheads = repo.revs(revset, draftheads, publicheads) |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2650 for r in extraheads: |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2651 headsbyphase[phases.public].add(node(r)) |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2652 |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2653 # transform data in a format used by the encoding function |
45117
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45062
diff
changeset
|
2654 phasemapping = { |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45062
diff
changeset
|
2655 phase: sorted(headsbyphase[phase]) for phase in phases.allphases |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45062
diff
changeset
|
2656 } |
34322
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2657 |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2658 # generate the actual part |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2659 phasedata = phases.binaryencode(phasemapping) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2660 bundler.newpart(b'phase-heads', data=phasedata) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2661 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2662 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2663 @getbundle2partsgenerator(b'hgtagsfnodes') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2664 def _getbundletagsfnodes( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2665 bundler, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2666 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2667 source, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2668 bundlecaps=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2669 b2caps=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2670 heads=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2671 common=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2672 **kwargs |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2673 ): |
25402
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2674 """Transfer the .hgtags filenodes mapping. |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2675 |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2676 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
|
2677 |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2678 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
|
2679 filenodes raw values. |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2680 """ |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2681 # Don't send unless: |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2682 # - changeset are being exchanged, |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2683 # - the client supports it. |
43770
44b605638918
exchange: guard against method invocation on `b2caps=None` args
Matt Harbison <matt_harbison@yahoo.com>
parents:
43769
diff
changeset
|
2684 if not b2caps or not (kwargs.get('cg', True) and b'hgtagsfnodes' in b2caps): |
25402
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2685 return |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2686 |
29808
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
2687 outgoing = _computeoutgoing(repo, heads, common) |
32222
6068712cbf03
bundle2: move tagsfnodecache generation in a generic function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32201
diff
changeset
|
2688 bundle2.addparttagsfnodescache(repo, bundler, outgoing) |
25402
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2689 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2690 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2691 @getbundle2partsgenerator(b'cache:rev-branch-cache') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2692 def _getbundlerevbranchcache( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2693 bundler, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2694 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2695 source, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2696 bundlecaps=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2697 b2caps=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2698 heads=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2699 common=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2700 **kwargs |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2701 ): |
36966
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2702 """Transfer the rev-branch-cache mapping |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2703 |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2704 The payload is a series of data related to each branch |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2705 |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2706 1) branch name length |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2707 2) number of open heads |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2708 3) number of closed heads |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2709 4) open heads nodes |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2710 5) closed heads nodes |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2711 """ |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2712 # Don't send unless: |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2713 # - changeset are being exchanged, |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2714 # - the client supports it. |
38789
9b64b73d702b
exchange: move disabling of rev-branch-cache bundle part out of narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38614
diff
changeset
|
2715 # - narrow bundle isn't in play (not currently compatible). |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2716 if ( |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2717 not kwargs.get('cg', True) |
43770
44b605638918
exchange: guard against method invocation on `b2caps=None` args
Matt Harbison <matt_harbison@yahoo.com>
parents:
43769
diff
changeset
|
2718 or not b2caps |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2719 or b'rev-branch-cache' not in b2caps |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43278
diff
changeset
|
2720 or kwargs.get('narrow', False) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2721 or repo.ui.has_section(_NARROWACL_SECTION) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2722 ): |
36966
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2723 return |
38789
9b64b73d702b
exchange: move disabling of rev-branch-cache bundle part out of narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38614
diff
changeset
|
2724 |
36966
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2725 outgoing = _computeoutgoing(repo, heads, common) |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2726 bundle2.addpartrevbranchcache(repo, bundler, outgoing) |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2727 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2728 |
20967
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
2729 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
|
2730 """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
|
2731 |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
2732 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
|
2733 """ |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
2734 heads = repo.heads() |
44060
a61287a95dc3
core: migrate uses of hashlib.sha1 to hashutil.sha1
Augie Fackler <augie@google.com>
parents:
43913
diff
changeset
|
2735 heads_hash = hashutil.sha1(b''.join(sorted(heads))).digest() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2736 if not ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2737 their_heads == [b'force'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2738 or their_heads == heads |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2739 or their_heads == [b'hashed', heads_hash] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2740 ): |
20967
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
2741 # 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
|
2742 # were transferring data |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2743 raise error.PushRaced( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
2744 b'repository changed while %s - please try again' % context |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2745 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2746 |
20968
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
2747 |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
2748 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
|
2749 """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
|
2750 |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
2751 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
|
2752 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
|
2753 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
|
2754 |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
2755 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
|
2756 r = 0 |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
2757 # 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
|
2758 # [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
|
2759 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
|
2760 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
|
2761 # quick fix for output mismatch with bundle2 in 3.4 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2762 captureoutput = repo.ui.configbool( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2763 b'experimental', b'bundle2-output-capture' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2764 ) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2765 if url.startswith(b'remote:http:') or url.startswith(b'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
|
2766 captureoutput = True |
20968
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
2767 try: |
30868
847f06179f60
unbundle: add a small comment to clarify the 'check_heads' call
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30685
diff
changeset
|
2768 # note: outside bundle1, 'heads' is expected to be empty and this |
847f06179f60
unbundle: add a small comment to clarify the 'check_heads' call
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30685
diff
changeset
|
2769 # 'check_heads' call wil be a no-op |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2770 check_heads(repo, heads, b'uploading changes') |
20968
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
2771 # push can proceed |
32891
7e2eb964a561
exchange: switch to usual way of testing for bundle2-ness
Martin von Zweigbergk <martinvonz@google.com>
parents:
32845
diff
changeset
|
2772 if not isinstance(cg, bundle2.unbundle20): |
30870
c5bee6aa4971
unbundle: swap conditional branches for clarity
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30869
diff
changeset
|
2773 # legacy case: bundle1 (changegroup 01) |
46907
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
2774 txnname = b"\n".join([source, urlutil.hidepassword(url)]) |
32930
af31d531dda0
changegroup: let callers pass in transaction to apply() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
32927
diff
changeset
|
2775 with repo.lock(), repo.transaction(txnname) as tr: |
33043
18c2489ac96d
bundle: make applybundle() delegate v1 bundles to applybundle1()
Martin von Zweigbergk <martinvonz@google.com>
parents:
33040
diff
changeset
|
2776 op = bundle2.applybundle(repo, cg, tr, source, url) |
33040
2baef42a2881
bundle: make applybundle1() return a bundleoperation
Martin von Zweigbergk <martinvonz@google.com>
parents:
33039
diff
changeset
|
2777 r = bundle2.combinechangegroupresults(op) |
30870
c5bee6aa4971
unbundle: swap conditional branches for clarity
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30869
diff
changeset
|
2778 else: |
24795
f9aa4cb8f2dd
bundle2: store the salvaged output on the exception object
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24754
diff
changeset
|
2779 r = None |
21187
bcfd44abad93
bundle2: gracefully handle hook abort
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
2780 try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2781 |
26566
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2782 def gettransaction(): |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2783 if not lockandtr[2]: |
42326
5d4ec64a6fcb
exchange: don't take wlock if bookmarks are stored in .hg/store/
Martin von Zweigbergk <martinvonz@google.com>
parents:
42209
diff
changeset
|
2784 if not bookmod.bookmarksinstore(repo): |
5d4ec64a6fcb
exchange: don't take wlock if bookmarks are stored in .hg/store/
Martin von Zweigbergk <martinvonz@google.com>
parents:
42209
diff
changeset
|
2785 lockandtr[0] = repo.wlock() |
26566
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2786 lockandtr[1] = repo.lock() |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2787 lockandtr[2] = repo.transaction(source) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2788 lockandtr[2].hookargs[b'source'] = source |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2789 lockandtr[2].hookargs[b'url'] = url |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2790 lockandtr[2].hookargs[b'bundle2'] = b'1' |
26566
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2791 return lockandtr[2] |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2792 |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2793 # 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
|
2794 # locking. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2795 if not repo.ui.configbool( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2796 b'experimental', b'bundle2lazylocking' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2797 ): |
26566
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2798 gettransaction() |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2799 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2800 op = bundle2.bundleoperation( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2801 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2802 gettransaction, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2803 captureoutput=captureoutput, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2804 source=b'push', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2805 ) |
24851
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
2806 try: |
25896
6805a4f76cda
exchange: fix dead assignment
Martin von Zweigbergk <martinvonz@google.com>
parents:
25895
diff
changeset
|
2807 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
|
2808 finally: |
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
2809 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
|
2810 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
|
2811 repo.ui.pushbuffer(error=True, subproc=True) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2812 |
24851
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
2813 def recordout(output): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2814 r.newpart(b'output', data=output, mandatory=False) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2815 |
26566
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2816 if lockandtr[2] is not None: |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2817 lockandtr[2].close() |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25640
diff
changeset
|
2818 except BaseException as exc: |
21187
bcfd44abad93
bundle2: gracefully handle hook abort
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
2819 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
|
2820 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
|
2821 parts = exc._bundle2salvagedoutput = r.salvageoutput() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2822 |
24847
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
2823 def recordout(output): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2824 part = bundle2.bundlepart( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2825 b'output', data=output, mandatory=False |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2826 ) |
24847
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
2827 parts.append(part) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2828 |
21187
bcfd44abad93
bundle2: gracefully handle hook abort
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
2829 raise |
20968
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
2830 finally: |
26566
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2831 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
|
2832 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
|
2833 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
|
2834 return r |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2835 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2836 |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2837 def _maybeapplyclonebundle(pullop): |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2838 """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
|
2839 |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2840 repo = pullop.repo |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2841 remote = pullop.remote |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2842 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2843 if not repo.ui.configbool(b'ui', b'clonebundles'): |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2844 return |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2845 |
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
|
2846 # 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
|
2847 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
|
2848 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
|
2849 |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2850 if pullop.heads: |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2851 return |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2852 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2853 if not remote.capable(b'clonebundles'): |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2854 return |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2855 |
37649
a168799687e5
wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37648
diff
changeset
|
2856 with remote.commandexecutor() as e: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2857 res = e.callcommand(b'clonebundles', {}).result() |
26689
2c9f15366982
exchange: record that we attempted to fetch a clone bundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26688
diff
changeset
|
2858 |
2c9f15366982
exchange: record that we attempted to fetch a clone bundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26688
diff
changeset
|
2859 # 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
|
2860 # attempt. |
2c9f15366982
exchange: record that we attempted to fetch a clone bundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26688
diff
changeset
|
2861 pullop.clonebundleattempted = True |
2c9f15366982
exchange: record that we attempted to fetch a clone bundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26688
diff
changeset
|
2862 |
45784
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45681
diff
changeset
|
2863 entries = bundlecaches.parseclonebundlesmanifest(repo, res) |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2864 if not entries: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2865 repo.ui.note( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2866 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2867 b'no clone bundles available on remote; ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2868 b'falling back to regular clone\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2869 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2870 ) |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2871 return |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2872 |
45784
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45681
diff
changeset
|
2873 entries = bundlecaches.filterclonebundleentries( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2874 repo, entries, streamclonerequested=pullop.streamclonerequested |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2875 ) |
34364
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2876 |
26644
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2877 if not entries: |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2878 # 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
|
2879 # 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
|
2880 # 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
|
2881 # 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
|
2882 # clone! |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2883 repo.ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2884 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2885 b'no compatible clone bundles available on server; ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2886 b'falling back to regular clone\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2887 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2888 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2889 repo.ui.warn( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
2890 _(b'(you may want to report this to the server operator)\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2891 ) |
26644
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2892 return |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2893 |
45784
74271829ddc0
clonebundles: move a bundle of clone bundle related code to a new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45681
diff
changeset
|
2894 entries = bundlecaches.sortclonebundleentries(repo.ui, entries) |
26644
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2895 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2896 url = entries[0][b'URL'] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2897 repo.ui.status(_(b'applying clone bundle from %s\n') % url) |
50666
60f9602b413e
clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
50533
diff
changeset
|
2898 if trypullbundlefromurl(repo.ui, repo, url, remote): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2899 repo.ui.status(_(b'finished applying clone bundle\n')) |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2900 # Bundle failed. |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2901 # |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2902 # 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
|
2903 # 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
|
2904 # clone load to be offloaded. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2905 elif repo.ui.configbool(b'ui', b'clonebundlefallback'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2906 repo.ui.warn(_(b'falling back to normal clone\n')) |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2907 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2908 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2909 _(b'error applying bundle'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2910 hint=_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2911 b'if this error persists, consider contacting ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2912 b'the server operator or disable clone ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2913 b'bundles via ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2914 b'"--config ui.clonebundles=false"' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2915 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2916 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2917 |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2918 |
50666
60f9602b413e
clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
50533
diff
changeset
|
2919 def inline_clone_bundle_open(ui, url, peer): |
60f9602b413e
clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
50533
diff
changeset
|
2920 if not peer: |
60f9602b413e
clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
50533
diff
changeset
|
2921 raise error.Abort(_(b'no remote repository supplied for %s' % url)) |
60f9602b413e
clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
50533
diff
changeset
|
2922 clonebundleid = url[len(bundlecaches.CLONEBUNDLESCHEME) :] |
50699
2aaabd8f4471
clone-bundle: rename the methods and wireprotole command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50666
diff
changeset
|
2923 peerclonebundle = peer.get_cached_bundle_inline(clonebundleid) |
50666
60f9602b413e
clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
50533
diff
changeset
|
2924 return util.chunkbuffer(peerclonebundle) |
60f9602b413e
clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
50533
diff
changeset
|
2925 |
60f9602b413e
clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
50533
diff
changeset
|
2926 |
60f9602b413e
clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
50533
diff
changeset
|
2927 def trypullbundlefromurl(ui, repo, url, peer): |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2928 """Attempt to apply a bundle from a URL.""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2929 with repo.lock(), repo.transaction(b'bundleurl') as tr: |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2930 try: |
50666
60f9602b413e
clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
50533
diff
changeset
|
2931 if url.startswith(bundlecaches.CLONEBUNDLESCHEME): |
60f9602b413e
clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
50533
diff
changeset
|
2932 fh = inline_clone_bundle_open(ui, url, peer) |
60f9602b413e
clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
50533
diff
changeset
|
2933 else: |
60f9602b413e
clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents:
50533
diff
changeset
|
2934 fh = urlmod.open(ui, url) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2935 cg = readbundle(ui, fh, b'stream') |
26643
d2e16419d3f4
clonebundle: support bundle2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26640
diff
changeset
|
2936 |
33043
18c2489ac96d
bundle: make applybundle() delegate v1 bundles to applybundle1()
Martin von Zweigbergk <martinvonz@google.com>
parents:
33040
diff
changeset
|
2937 if isinstance(cg, streamclone.streamcloneapplier): |
32843
a470bbb4e3af
clonebundle: use context managers for lock and transaction
Martin von Zweigbergk <martinvonz@google.com>
parents:
32709
diff
changeset
|
2938 cg.apply(repo) |
a470bbb4e3af
clonebundle: use context managers for lock and transaction
Martin von Zweigbergk <martinvonz@google.com>
parents:
32709
diff
changeset
|
2939 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2940 bundle2.applybundle(repo, cg, tr, b'clonebundles', url) |
32843
a470bbb4e3af
clonebundle: use context managers for lock and transaction
Martin von Zweigbergk <martinvonz@google.com>
parents:
32709
diff
changeset
|
2941 return True |
a470bbb4e3af
clonebundle: use context managers for lock and transaction
Martin von Zweigbergk <martinvonz@google.com>
parents:
32709
diff
changeset
|
2942 except urlerr.httperror as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2943 ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2944 _(b'HTTP error fetching bundle: %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2945 % stringutil.forcebytestr(e) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2946 ) |
32843
a470bbb4e3af
clonebundle: use context managers for lock and transaction
Martin von Zweigbergk <martinvonz@google.com>
parents:
32709
diff
changeset
|
2947 except urlerr.urlerror as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2948 ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2949 _(b'error fetching bundle: %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2950 % stringutil.forcebytestr(e.reason) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42925
diff
changeset
|
2951 ) |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2952 |
32843
a470bbb4e3af
clonebundle: use context managers for lock and transaction
Martin von Zweigbergk <martinvonz@google.com>
parents:
32709
diff
changeset
|
2953 return False |