Mercurial > hg
annotate mercurial/exchange.py @ 41987:c1d83d916e85
revert: option to choose what to keep, not what to discard
I know the you (the reader) are probably tired of discussing how `hg
revert -i -r .` should behave and so am I. And I know I'm one of the
people who argued that showing the diff from the working copy to the
parent was confusing. I think it is less confusing now that we show
the diff from the parent to the working copy, but I still find it
confusing. I think showing the diff of hunks to keep might make it
easier to understand. So that's what this patch provides an option
for.
One argument doing it this way is that most people seem to find `hg
split` natural. I suspect that is because it shows the forward diff
(from parent commit to the commit) and asks you what to put in the
first commit. I think the new "keep" mode for revert (this patch)
matches that.
In "keep" mode, all the changes are still selected by default. That
means that `hg revert -i` followed by 'A' (keep all) (or 'c' in
curses) will be different from `hg revert -a`. That's mostly because
that was simplest. It can also be argued that it's safest. But it can
also be argued that it should be consistent with `hg revert -a`.
Note that in this mode, you can edit the hunks and it will do what you
expect (e.g. add new lines to your file if you added a new lines when
editing). The test case shows that that works.
Differential Revision: https://phab.mercurial-scm.org/D6125
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 12 Mar 2019 14:17:41 -0700 |
parents | 1eb2fc21da12 |
children | 566daffc607d |
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 # |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
4 # |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
7 |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
8 from __future__ import absolute_import |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
9 |
34322
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
10 import collections |
29341
0d83ad967bf8
cleanup: replace uses of util.(md5|sha1|sha256|sha512) with hashlib.\1
Augie Fackler <raf@durin42.com>
parents:
29064
diff
changeset
|
11 import hashlib |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
12 |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
13 from .i18n import _ |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
14 from .node import ( |
35259
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
15 bin, |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
16 hex, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
17 nullid, |
38791
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
18 nullrev, |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
19 ) |
37164
b229fd9adeae
bundlespec: introduce an attr-based class for bundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37084
diff
changeset
|
20 from .thirdparty import ( |
b229fd9adeae
bundlespec: introduce an attr-based class for bundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37084
diff
changeset
|
21 attr, |
b229fd9adeae
bundlespec: introduce an attr-based class for bundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37084
diff
changeset
|
22 ) |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
23 from . import ( |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
24 bookmarks as bookmod, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
25 bundle2, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
26 changegroup, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
27 discovery, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
28 error, |
39629
a86d21e70b2b
exchangev2: start to implement pull with wire protocol v2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39553
diff
changeset
|
29 exchangev2, |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
30 lock as lockmod, |
35347
a29fe459fc49
remotenames: rename related file and storage dir to logexchange
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35305
diff
changeset
|
31 logexchange, |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
32 narrowspec, |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
33 obsolete, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
34 phases, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
35 pushkey, |
32896
e14484e7f562
py3: use pycompat.strkwargs() to convert kwargs keys to str before passing
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32891
diff
changeset
|
36 pycompat, |
38835
a232e6744ba3
narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents:
38808
diff
changeset
|
37 repository, |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
38 scmutil, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
39 sslutil, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
40 streamclone, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
41 url as urlmod, |
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
42 util, |
40492
440f5b65be57
exchange: pass includepats and excludepats as arguments to getbundle()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40352
diff
changeset
|
43 wireprototypes, |
27523
68b9abf1cb82
exchange: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27244
diff
changeset
|
44 ) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36966
diff
changeset
|
45 from .utils import ( |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36966
diff
changeset
|
46 stringutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36966
diff
changeset
|
47 ) |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
48 |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
49 urlerr = util.urlerr |
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
50 urlreq = util.urlreq |
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
51 |
38789
9b64b73d702b
exchange: move disabling of rev-branch-cache bundle part out of narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38614
diff
changeset
|
52 _NARROWACL_SECTION = 'narrowhgacl' |
9b64b73d702b
exchange: move disabling of rev-branch-cache bundle part out of narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38614
diff
changeset
|
53 |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
54 # Maps bundle version human names to changegroup versions. |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
55 _bundlespeccgversions = {'v1': '01', |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
56 'v2': '02', |
26756
9e272a96f764
exchange: support for streaming clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26732
diff
changeset
|
57 'packed1': 's1', |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
58 'bundle2': '02', #legacy |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
59 } |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
60 |
37165
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
61 # Maps bundle version with content opts to choose which part to bundle |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
62 _bundlespeccontentopts = { |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
63 'v1': { |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
64 'changegroup': True, |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
65 'cg.version': '01', |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
66 'obsolescence': False, |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
67 'phases': False, |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
68 'tagsfnodescache': False, |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
69 'revbranchcache': False |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
70 }, |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
71 'v2': { |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
72 'changegroup': True, |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
73 'cg.version': '02', |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
74 'obsolescence': False, |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
75 'phases': False, |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
76 'tagsfnodescache': True, |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
77 'revbranchcache': True |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
78 }, |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
79 'packed1' : { |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
80 'cg.version': 's1' |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
81 } |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
82 } |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
83 _bundlespeccontentopts['bundle2'] = _bundlespeccontentopts['v2'] |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
84 |
37168
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
85 _bundlespecvariants = {"streamv2": {"changegroup": False, "streamv2": True, |
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
86 "tagsfnodescache": False, |
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
87 "revbranchcache": False}} |
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
88 |
31473
ffed3bf5cd4c
exchange: reject new compression engines for v1 bundles (issue5506)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30913
diff
changeset
|
89 # Compression engines allowed in version 1. THIS SHOULD NEVER CHANGE. |
32291
bd872f64a8ba
cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents:
32287
diff
changeset
|
90 _bundlespecv1compengines = {'gzip', 'bzip2', 'none'} |
31473
ffed3bf5cd4c
exchange: reject new compression engines for v1 bundles (issue5506)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30913
diff
changeset
|
91 |
37164
b229fd9adeae
bundlespec: introduce an attr-based class for bundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37084
diff
changeset
|
92 @attr.s |
b229fd9adeae
bundlespec: introduce an attr-based class for bundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37084
diff
changeset
|
93 class bundlespec(object): |
b229fd9adeae
bundlespec: introduce an attr-based class for bundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37084
diff
changeset
|
94 compression = attr.ib() |
37768
5527aa808dea
bundlespec: drop externalnames flag
Joerg Sonnenberger <joerg@bec.de>
parents:
37757
diff
changeset
|
95 wirecompression = attr.ib() |
37164
b229fd9adeae
bundlespec: introduce an attr-based class for bundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37084
diff
changeset
|
96 version = attr.ib() |
37768
5527aa808dea
bundlespec: drop externalnames flag
Joerg Sonnenberger <joerg@bec.de>
parents:
37757
diff
changeset
|
97 wireversion = attr.ib() |
37164
b229fd9adeae
bundlespec: introduce an attr-based class for bundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37084
diff
changeset
|
98 params = attr.ib() |
37165
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
99 contentopts = attr.ib() |
37164
b229fd9adeae
bundlespec: introduce an attr-based class for bundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37084
diff
changeset
|
100 |
37768
5527aa808dea
bundlespec: drop externalnames flag
Joerg Sonnenberger <joerg@bec.de>
parents:
37757
diff
changeset
|
101 def parsebundlespec(repo, spec, strict=True): |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
102 """Parse a bundle string specification into parts. |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
103 |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
104 Bundle specifications denote a well-defined bundle/exchange format. |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
105 The content of a given specification should not change over time in |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
106 order to ensure that bundles produced by a newer version of Mercurial are |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
107 readable from an older version. |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
108 |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
109 The string currently has the form: |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
110 |
26759
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
111 <compression>-<type>[;<parameter0>[;<parameter1>]] |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
112 |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
113 Where <compression> is one of the supported compression formats |
26759
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
114 and <type> is (currently) a version string. A ";" can follow the type and |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
30187
diff
changeset
|
115 all text afterwards is interpreted as URI encoded, ";" delimited key=value |
26759
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
116 pairs. |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
117 |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
118 If ``strict`` is True (the default) <compression> is required. Otherwise, |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
119 it is optional. |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
120 |
37164
b229fd9adeae
bundlespec: introduce an attr-based class for bundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37084
diff
changeset
|
121 Returns a bundlespec object of (compression, version, parameters). |
b229fd9adeae
bundlespec: introduce an attr-based class for bundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37084
diff
changeset
|
122 Compression will be ``None`` if not in strict mode and a compression isn't |
b229fd9adeae
bundlespec: introduce an attr-based class for bundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37084
diff
changeset
|
123 defined. |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
124 |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
125 An ``InvalidBundleSpecification`` is raised when the specification is |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
126 not syntactically well formed. |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
127 |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
128 An ``UnsupportedBundleSpecification`` is raised when the compression or |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
129 bundle type/version is not recognized. |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
130 |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
131 Note: this function will likely eventually return a more complex data |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
132 structure, including bundle2 part information. |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
133 """ |
26759
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
134 def parseparams(s): |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
135 if ';' not in s: |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
136 return s, {} |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
137 |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
138 params = {} |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
139 version, paramstr = s.split(';', 1) |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
140 |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
141 for p in paramstr.split(';'): |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
142 if '=' not in p: |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
143 raise error.InvalidBundleSpecification( |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
144 _('invalid bundle specification: ' |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
145 'missing "=" in parameter: %s') % p) |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
146 |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
147 key, value = p.split('=', 1) |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
148 key = urlreq.unquote(key) |
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
149 value = urlreq.unquote(value) |
26759
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
150 params[key] = value |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
151 |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
152 return version, params |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
153 |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
154 |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
155 if strict and '-' not in spec: |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
156 raise error.InvalidBundleSpecification( |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
157 _('invalid bundle specification; ' |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
158 'must be prefixed with compression: %s') % spec) |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
159 |
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
160 if '-' in spec: |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
161 compression, version = spec.split('-', 1) |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
162 |
30440
c3944ab1443a
exchange: obtain compression engines from the registrar
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30332
diff
changeset
|
163 if compression not in util.compengines.supportedbundlenames: |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
164 raise error.UnsupportedBundleSpecification( |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
165 _('%s compression is not supported') % compression) |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
166 |
26759
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
167 version, params = parseparams(version) |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
168 |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
169 if version not in _bundlespeccgversions: |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
170 raise error.UnsupportedBundleSpecification( |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
171 _('%s is not a recognized bundle version') % version) |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
172 else: |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
173 # Value could be just the compression or just the version, in which |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
174 # case some defaults are assumed (but only when not in strict mode). |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
175 assert not strict |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
176 |
26759
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
177 spec, params = parseparams(spec) |
c0f475ac997e
exchange: support parameters in bundle specification strings
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26756
diff
changeset
|
178 |
30440
c3944ab1443a
exchange: obtain compression engines from the registrar
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30332
diff
changeset
|
179 if spec in util.compengines.supportedbundlenames: |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
180 compression = spec |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
181 version = 'v1' |
31474
10c0ee338535
exchange: use v2 bundles for modern compression engines (issue5506)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31473
diff
changeset
|
182 # Generaldelta repos require v2. |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
183 if 'generaldelta' in repo.requirements: |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
184 version = 'v2' |
31474
10c0ee338535
exchange: use v2 bundles for modern compression engines (issue5506)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31473
diff
changeset
|
185 # Modern compression engines require v2. |
10c0ee338535
exchange: use v2 bundles for modern compression engines (issue5506)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31473
diff
changeset
|
186 if compression not in _bundlespecv1compengines: |
10c0ee338535
exchange: use v2 bundles for modern compression engines (issue5506)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31473
diff
changeset
|
187 version = 'v2' |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
188 elif spec in _bundlespeccgversions: |
26756
9e272a96f764
exchange: support for streaming clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26732
diff
changeset
|
189 if spec == 'packed1': |
9e272a96f764
exchange: support for streaming clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26732
diff
changeset
|
190 compression = 'none' |
9e272a96f764
exchange: support for streaming clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26732
diff
changeset
|
191 else: |
9e272a96f764
exchange: support for streaming clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26732
diff
changeset
|
192 compression = 'bzip2' |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
193 version = spec |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
194 else: |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
195 raise error.UnsupportedBundleSpecification( |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26639
diff
changeset
|
196 _('%s is not a recognized bundle specification') % spec) |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
197 |
31473
ffed3bf5cd4c
exchange: reject new compression engines for v1 bundles (issue5506)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30913
diff
changeset
|
198 # Bundle version 1 only supports a known set of compression engines. |
ffed3bf5cd4c
exchange: reject new compression engines for v1 bundles (issue5506)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30913
diff
changeset
|
199 if version == 'v1' and compression not in _bundlespecv1compengines: |
ffed3bf5cd4c
exchange: reject new compression engines for v1 bundles (issue5506)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30913
diff
changeset
|
200 raise error.UnsupportedBundleSpecification( |
ffed3bf5cd4c
exchange: reject new compression engines for v1 bundles (issue5506)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30913
diff
changeset
|
201 _('compression engine %s is not supported on v1 bundles') % |
ffed3bf5cd4c
exchange: reject new compression engines for v1 bundles (issue5506)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30913
diff
changeset
|
202 compression) |
ffed3bf5cd4c
exchange: reject new compression engines for v1 bundles (issue5506)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30913
diff
changeset
|
203 |
26760
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
204 # The specification for packed1 can optionally declare the data formats |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
205 # required to apply it. If we see this metadata, compare against what the |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
206 # repo supports and error if the bundle isn't compatible. |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
207 if version == 'packed1' and 'requirements' in params: |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
208 requirements = set(params['requirements'].split(',')) |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
209 missingreqs = requirements - repo.supportedformats |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
210 if missingreqs: |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
211 raise error.UnsupportedBundleSpecification( |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
212 _('missing support for repository features: %s') % |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
213 ', '.join(sorted(missingreqs))) |
a18ee7da38c2
exchange: parse requirements from stream clone specification string
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26759
diff
changeset
|
214 |
37165
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
215 # Compute contentopts based on the version |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
216 contentopts = _bundlespeccontentopts.get(version, {}).copy() |
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37164
diff
changeset
|
217 |
37168
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
218 # Process the variants |
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
219 if "stream" in params and params["stream"] == "v2": |
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
220 variant = _bundlespecvariants["streamv2"] |
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
221 contentopts.update(variant) |
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
222 |
37768
5527aa808dea
bundlespec: drop externalnames flag
Joerg Sonnenberger <joerg@bec.de>
parents:
37757
diff
changeset
|
223 engine = util.compengines.forbundlename(compression) |
5527aa808dea
bundlespec: drop externalnames flag
Joerg Sonnenberger <joerg@bec.de>
parents:
37757
diff
changeset
|
224 compression, wirecompression = engine.bundletype() |
5527aa808dea
bundlespec: drop externalnames flag
Joerg Sonnenberger <joerg@bec.de>
parents:
37757
diff
changeset
|
225 wireversion = _bundlespeccgversions[version] |
37164
b229fd9adeae
bundlespec: introduce an attr-based class for bundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37084
diff
changeset
|
226 |
37768
5527aa808dea
bundlespec: drop externalnames flag
Joerg Sonnenberger <joerg@bec.de>
parents:
37757
diff
changeset
|
227 return bundlespec(compression, wirecompression, version, wireversion, |
5527aa808dea
bundlespec: drop externalnames flag
Joerg Sonnenberger <joerg@bec.de>
parents:
37757
diff
changeset
|
228 params, contentopts) |
26639
92d67e5729b9
exchange: move bundle specification parsing from cmdutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26623
diff
changeset
|
229 |
21064
4d9d490d7bbe
bundle2: add a ui argument to readbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21063
diff
changeset
|
230 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
|
231 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
|
232 |
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
|
233 alg = None |
21063
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
234 if not fname: |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
235 fname = "stream" |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
236 if not header.startswith('HG') and header.startswith('\0'): |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
237 fh = changegroup.headerlessfixup(fh, header) |
21065
f9a9a6d63e89
bundle2: prepare readbundle to return more that one type of bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21064
diff
changeset
|
238 header = "HG10" |
f9a9a6d63e89
bundle2: prepare readbundle to return more that one type of bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21064
diff
changeset
|
239 alg = 'UN' |
21063
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
240 elif vfs: |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
241 fname = vfs.join(fname) |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
242 |
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
|
243 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
|
244 |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
245 if magic != 'HG': |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26566
diff
changeset
|
246 raise error.Abort(_('%s: not a Mercurial bundle') % fname) |
21065
f9a9a6d63e89
bundle2: prepare readbundle to return more that one type of bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21064
diff
changeset
|
247 if version == '10': |
f9a9a6d63e89
bundle2: prepare readbundle to return more that one type of bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21064
diff
changeset
|
248 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
|
249 alg = changegroup.readexactly(fh, 2) |
22390
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22354
diff
changeset
|
250 return changegroup.cg1unpacker(fh, alg) |
24649
2d15c59a001b
bundle2: detect bundle2 stream/request on /HG2./ instead of /HG2Y/
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24641
diff
changeset
|
251 elif version.startswith('2'): |
25640
39f0064a3079
bundle2.getunbundler: rename "header" to "magicstring"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25559
diff
changeset
|
252 return bundle2.getunbundler(ui, fh, magicstring=magic + version) |
26756
9e272a96f764
exchange: support for streaming clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26732
diff
changeset
|
253 elif version == 'S1': |
9e272a96f764
exchange: support for streaming clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26732
diff
changeset
|
254 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
|
255 else: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26566
diff
changeset
|
256 raise error.Abort(_('%s: unknown bundle version %s') % (fname, version)) |
21063
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
257 |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
258 def getbundlespec(ui, fh): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
259 """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
|
260 |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
261 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
|
262 restored. |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
263 """ |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
264 def speccompression(alg): |
30440
c3944ab1443a
exchange: obtain compression engines from the registrar
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30332
diff
changeset
|
265 try: |
c3944ab1443a
exchange: obtain compression engines from the registrar
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30332
diff
changeset
|
266 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
|
267 except KeyError: |
c3944ab1443a
exchange: obtain compression engines from the registrar
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30332
diff
changeset
|
268 return None |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
269 |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
270 b = readbundle(ui, fh, None) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
271 if isinstance(b, changegroup.cg1unpacker): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
272 alg = b._type |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
273 if alg == '_truncatedBZ': |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
274 alg = 'BZ' |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
275 comp = speccompression(alg) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
276 if not comp: |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
277 raise error.Abort(_('unknown compression algorithm: %s') % alg) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
278 return '%s-v1' % comp |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
279 elif isinstance(b, bundle2.unbundle20): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
280 if 'Compression' in b.params: |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
281 comp = speccompression(b.params['Compression']) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
282 if not comp: |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
283 raise error.Abort(_('unknown compression algorithm: %s') % comp) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
284 else: |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
285 comp = 'none' |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
286 |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
287 version = None |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
288 for part in b.iterparts(): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
289 if part.type == 'changegroup': |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
290 version = part.params['version'] |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
291 if version in ('01', '02'): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
292 version = 'v2' |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
293 else: |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
294 raise error.Abort(_('changegroup version %s does not have ' |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
295 'a known bundlespec') % version, |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
296 hint=_('try upgrading your Mercurial ' |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
297 'client')) |
37168
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
298 elif part.type == 'stream2' and version is None: |
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
299 # A stream2 part requires to be part of a v2 bundle |
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
300 requirements = urlreq.unquote(part.params['requirements']) |
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
301 splitted = requirements.split() |
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
302 params = bundle2._formatrequirementsparams(splitted) |
a2b350d9f6ae
bundlespec: add support for some variants
Boris Feld <boris.feld@octobus.net>
parents:
37167
diff
changeset
|
303 return 'none-v2;stream=v2;%s' % params |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
304 |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
305 if not version: |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
306 raise error.Abort(_('could not identify changegroup version in ' |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
307 'bundle')) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
308 |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
309 return '%s-%s' % (comp, version) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
310 elif isinstance(b, streamclone.streamcloneapplier): |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
311 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
|
312 formatted = bundle2._formatrequirementsparams(requirements) |
6f467adf9f05
bundle: add the possibility to bundle a stream v2 part
Boris Feld <boris.feld@octobus.net>
parents:
37165
diff
changeset
|
313 return 'none-packed1;%s' % formatted |
27883
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
314 else: |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
315 raise error.Abort(_('unknown bundle type: %s') % b) |
4f4b80b3f2bf
exchange: implement function for inferring bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27751
diff
changeset
|
316 |
29808
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
317 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
|
318 """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
|
319 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
|
320 |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
321 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
|
322 the logic. |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
323 |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
324 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
|
325 """ |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
326 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
|
327 if common: |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
328 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
|
329 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
|
330 else: |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
331 common = [nullid] |
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
332 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
|
333 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
|
334 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
|
335 |
40767
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
336 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
|
337 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
|
338 ui = repo.ui |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
339 behavior = ui.config('experimental', 'auto-publish') |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
340 if pushop.publish or behavior not in ('warn', 'confirm', 'abort'): |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
341 return |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
342 remotephases = listkeys(pushop.remote, 'phases') |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
343 if not remotephases.get('publishing', False): |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
344 return |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
345 |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
346 if pushop.revs is None: |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
347 published = repo.filtered('served').revs('not public()') |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
348 else: |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
349 published = repo.revs('::%ln - public()', pushop.revs) |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
350 if published: |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
351 if behavior == 'warn': |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
352 ui.warn(_('%i changesets about to be published\n') |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
353 % len(published)) |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
354 elif behavior == 'confirm': |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
355 if ui.promptchoice(_('push and publish %i changesets (yn)?' |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
356 '$$ &Yes $$ &No') % len(published)): |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
357 raise error.Abort(_('user quit')) |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
358 elif behavior == 'abort': |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
359 msg = _('push would publish %i changesets') % len(published) |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
360 hint = _("use --publish or adjust 'experimental.auto-publish'" |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
361 " config") |
33d30fb1e4ae
push: config option to control behavior when pushing to a publishing server
Anton Shestakov <av6@dwimlabs.net>
parents:
40686
diff
changeset
|
362 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
|
363 |
29682
2db085d5f5a2
bundle2: rename the _canusebundle2 method to _forcebundle1
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29389
diff
changeset
|
364 def _forcebundle1(op): |
2db085d5f5a2
bundle2: rename the _canusebundle2 method to _forcebundle1
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29389
diff
changeset
|
365 """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
|
366 |
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
|
367 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
|
368 ui = op.repo.ui |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
30187
diff
changeset
|
369 # 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
|
370 # 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
|
371 # 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
|
372 # 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
|
373 # |
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
|
374 # developer config: devel.legacy.exchange |
6786c3f8684d
bundle2: add a devel option controling bundle version used for exchange
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29682
diff
changeset
|
375 exchange = ui.configlist('devel', 'legacy.exchange') |
29689
39537bc64442
bundle2: remove 'experimental.bundle2-exp' boolean config (BC)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29683
diff
changeset
|
376 forcebundle1 = 'bundle2' not in exchange and 'bundle1' in exchange |
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
|
377 return forcebundle1 or not op.remote.capable('bundle2') |
24650
b83a8f512a80
exchange: introduce a '_canusebundle2' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24649
diff
changeset
|
378 |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
379 class pushoperation(object): |
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
380 """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
|
381 |
28456
d9d51da7a850
pushoperation: fix language issues in docstring
Nathan Goldbaum <ngoldbau@illinois.edu>
parents:
28182
diff
changeset
|
382 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
|
383 |
28456
d9d51da7a850
pushoperation: fix language issues in docstring
Nathan Goldbaum <ngoldbau@illinois.edu>
parents:
28182
diff
changeset
|
384 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
|
385 discarded afterward. |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
386 """ |
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
387 |
22623
cd7e17aa6040
push: pass list of bookmark to `exchange.push`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22622
diff
changeset
|
388 def __init__(self, repo, remote, force=False, revs=None, newbranch=False, |
40686
9b8d1ad851f8
push: add --publish flag to change phase of pushed changesets
Anton Shestakov <av6@dwimlabs.net>
parents:
40492
diff
changeset
|
389 bookmarks=(), publish=False, pushvars=None): |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
390 # repo we push from |
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
391 self.repo = repo |
20347
3ec5f833348e
push: ease access to current ui object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20346
diff
changeset
|
392 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
|
393 # 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
|
394 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
|
395 # force option provided |
89f90457979e
push: move `force` argument into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20348
diff
changeset
|
396 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
|
397 # 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
|
398 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
|
399 # bookmark explicitly pushed |
cd7e17aa6040
push: pass list of bookmark to `exchange.push`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22622
diff
changeset
|
400 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
|
401 # 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
|
402 self.newbranch = newbranch |
21901
8612c4ab7f54
push: add a ``pushop.stepsdone`` attribute
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21899
diff
changeset
|
403 # step already performed |
8612c4ab7f54
push: add a ``pushop.stepsdone`` attribute
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21899
diff
changeset
|
404 # (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
|
405 self.stepsdone = set() |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
406 # 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
|
407 # - 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
|
408 # - 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
|
409 # - 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
|
410 # 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
|
411 # - 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
|
412 self.cgresult = None |
22624
eef31f9a4c0f
push: add `pushoperation.bkresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22623
diff
changeset
|
413 # Boolean value for the bookmark push |
eef31f9a4c0f
push: add `pushoperation.bkresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22623
diff
changeset
|
414 self.bkresult = None |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
415 # 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
|
416 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
|
417 # 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
|
418 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
|
419 # 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
|
420 # |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
421 # 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
|
422 # [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
|
423 # [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
|
424 # [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
|
425 # - 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
|
426 # - 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
|
427 # 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
|
428 # - 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
|
429 # - 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
|
430 # - 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
|
431 self.pushbranchmap = None |
20464
d032417db243
push: move `incoming` into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20463
diff
changeset
|
432 # 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
|
433 self.incoming = None |
34819
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34818
diff
changeset
|
434 # 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
|
435 self.remotephases = None |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
436 # 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
|
437 self.outdatedphases = None |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
438 # 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
|
439 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
|
440 # outgoing obsmarkers |
22035
24bb01f42e82
push: introduce a discovery step for obsmarker
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22034
diff
changeset
|
441 self.outobsmarkers = set() |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
442 # outgoing bookmarks |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
443 self.outbookmarks = [] |
23437
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
444 # transaction manager |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
445 self.trmanager = None |
25485
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
446 # 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
|
447 # 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
|
448 self.pkfailcb = {} |
33885 | 449 # an iterable of pushvars or None |
450 self.pushvars = pushvars | |
40686
9b8d1ad851f8
push: add --publish flag to change phase of pushed changesets
Anton Shestakov <av6@dwimlabs.net>
parents:
40492
diff
changeset
|
451 # publish pushed changesets |
9b8d1ad851f8
push: add --publish flag to change phase of pushed changesets
Anton Shestakov <av6@dwimlabs.net>
parents:
40492
diff
changeset
|
452 self.publish = publish |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
453 |
22014
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
454 @util.propertycache |
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
455 def futureheads(self): |
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
456 """future remote heads if the changeset push succeeds""" |
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
457 return self.outgoing.missingheads |
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
458 |
22015
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
459 @util.propertycache |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
460 def fallbackheads(self): |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
461 """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
|
462 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
|
463 # 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
|
464 return self.outgoing.commonheads |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
465 unfi = self.repo.unfiltered() |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
466 # I want cheads = heads(::missingheads and ::commonheads) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
467 # (missingheads is revs with secret changeset filtered out) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
468 # |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
469 # This can be expressed as: |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
470 # cheads = ( (missingheads and ::commonheads) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
471 # + (commonheads and ::missingheads))" |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
472 # ) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
473 # |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
474 # while trying to push we already computed the following: |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
475 # common = (::commonheads) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
476 # missing = ((commonheads::missingheads) - commonheads) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
477 # |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
478 # We can pick: |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
479 # * missingheads part of common (::commonheads) |
26184
327d09f0b5d4
exchange: allow fallbackheads to use lazy set behavior
Durham Goode <durham@fb.com>
parents:
25896
diff
changeset
|
480 common = self.outgoing.common |
22015
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
481 nm = self.repo.changelog.nodemap |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
482 cheads = [node for node in self.revs if nm[node] in common] |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
483 # and |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
484 # * commonheads parents on missing |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
485 revset = unfi.set('%ln and parents(roots(%ln))', |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
486 self.outgoing.commonheads, |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
487 self.outgoing.missing) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
488 cheads.extend(c.node() for c in revset) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
489 return cheads |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
490 |
22016
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
491 @property |
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
492 def commonheads(self): |
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
493 """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
|
494 if self.cgresult: |
22016
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
495 return self.futureheads |
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
496 else: |
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
497 return self.fallbackheads |
22015
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
498 |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
499 # mapping of message used when pushing bookmark |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
500 bookmsgmap = {'update': (_("updating bookmark %s\n"), |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
501 _('updating bookmark %s failed!\n')), |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
502 'export': (_("exporting bookmark %s\n"), |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
503 _('exporting bookmark %s failed!\n')), |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
504 'delete': (_("deleting remote bookmark %s\n"), |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
505 _('deleting remote bookmark %s failed!\n')), |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
506 } |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
507 |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
508 |
26729
16e69e6b357b
exchange: add oparg to push so that extensions can wrap pushop
Sean Farley <sean@farley.io>
parents:
26700
diff
changeset
|
509 def push(repo, remote, force=False, revs=None, newbranch=False, bookmarks=(), |
40686
9b8d1ad851f8
push: add --publish flag to change phase of pushed changesets
Anton Shestakov <av6@dwimlabs.net>
parents:
40492
diff
changeset
|
510 publish=False, opargs=None): |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
511 '''Push outgoing changesets (limited by revs) from a local |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
512 repository to remote. Return an integer: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
513 - None means nothing to push |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
514 - 0 means HTTP error |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
515 - 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
|
516 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
|
517 - other values as described by addchangegroup() |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
518 ''' |
26729
16e69e6b357b
exchange: add oparg to push so that extensions can wrap pushop
Sean Farley <sean@farley.io>
parents:
26700
diff
changeset
|
519 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
|
520 opargs = {} |
16e69e6b357b
exchange: add oparg to push so that extensions can wrap pushop
Sean Farley <sean@farley.io>
parents:
26700
diff
changeset
|
521 pushop = pushoperation(repo, remote, force, revs, newbranch, bookmarks, |
40686
9b8d1ad851f8
push: add --publish flag to change phase of pushed changesets
Anton Shestakov <av6@dwimlabs.net>
parents:
40492
diff
changeset
|
522 publish, **pycompat.strkwargs(opargs)) |
20348
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
523 if pushop.remote.local(): |
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
524 missing = (set(pushop.repo.requirements) |
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
525 - pushop.remote.local().supported) |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
526 if missing: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
527 msg = _("required features are not" |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
528 " supported in the destination:" |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
529 " %s") % (', '.join(sorted(missing))) |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26566
diff
changeset
|
530 raise error.Abort(msg) |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
531 |
20348
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
532 if not pushop.remote.canpush(): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26566
diff
changeset
|
533 raise error.Abort(_("destination does not support push")) |
33701
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
534 |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
535 if not pushop.remote.capable('unbundle'): |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
536 raise error.Abort(_('cannot push: destination does not support the ' |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
537 'unbundle wire protocol command')) |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
538 |
33791
20d663a104fb
exchange: drop now-unnecessary "local" from lock name variables
Martin von Zweigbergk <martinvonz@google.com>
parents:
33790
diff
changeset
|
539 # 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
|
540 wlock = lock = None |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
541 try: |
24754
5dc5cd7abbf5
push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24752
diff
changeset
|
542 # bundle2 push may receive a reply bundle touching bookmarks or other |
5dc5cd7abbf5
push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24752
diff
changeset
|
543 # things requiring the wlock. Take it now to ensure proper ordering. |
5dc5cd7abbf5
push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24752
diff
changeset
|
544 maypushback = pushop.ui.configbool('experimental', 'bundle2.pushback') |
29682
2db085d5f5a2
bundle2: rename the _canusebundle2 method to _forcebundle1
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29389
diff
changeset
|
545 if (not _forcebundle1(pushop)) and maypushback: |
33791
20d663a104fb
exchange: drop now-unnecessary "local" from lock name variables
Martin von Zweigbergk <martinvonz@google.com>
parents:
33790
diff
changeset
|
546 wlock = pushop.repo.wlock() |
20d663a104fb
exchange: drop now-unnecessary "local" from lock name variables
Martin von Zweigbergk <martinvonz@google.com>
parents:
33790
diff
changeset
|
547 lock = pushop.repo.lock() |
33792
5904511fc9f8
exchange: remove need for "locked" variable
Martin von Zweigbergk <martinvonz@google.com>
parents:
33791
diff
changeset
|
548 pushop.trmanager = transactionmanager(pushop.repo, |
5904511fc9f8
exchange: remove need for "locked" variable
Martin von Zweigbergk <martinvonz@google.com>
parents:
33791
diff
changeset
|
549 'push-response', |
5904511fc9f8
exchange: remove need for "locked" variable
Martin von Zweigbergk <martinvonz@google.com>
parents:
33791
diff
changeset
|
550 pushop.remote.url()) |
38000
7c05198cd1ca
push: continue without locking on lock failure other than EEXIST (issue5882)
Yuya Nishihara <yuya@tcha.org>
parents:
37768
diff
changeset
|
551 except error.LockUnavailable as err: |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
552 # source repo cannot be locked. |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
553 # We do not abort the push, but just disable the local phase |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
554 # synchronisation. |
39911
d1bc6cf2be69
py3: use util.forcebytestr() to convert push lock error to bytes
Matt Harbison <matt_harbison@yahoo.com>
parents:
39630
diff
changeset
|
555 msg = ('cannot lock source repository: %s\n' |
d1bc6cf2be69
py3: use util.forcebytestr() to convert push lock error to bytes
Matt Harbison <matt_harbison@yahoo.com>
parents:
39630
diff
changeset
|
556 % stringutil.forcebytestr(err)) |
20347
3ec5f833348e
push: ease access to current ui object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20346
diff
changeset
|
557 pushop.ui.debug(msg) |
33792
5904511fc9f8
exchange: remove need for "locked" variable
Martin von Zweigbergk <martinvonz@google.com>
parents:
33791
diff
changeset
|
558 |
41760
1eb2fc21da12
cleanup: prefer nested context managers to \-continuations
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
559 with wlock or util.nullcontextmanager(): |
1eb2fc21da12
cleanup: prefer nested context managers to \-continuations
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
560 with lock or util.nullcontextmanager(): |
1eb2fc21da12
cleanup: prefer nested context managers to \-continuations
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
561 with pushop.trmanager or util.nullcontextmanager(): |
1eb2fc21da12
cleanup: prefer nested context managers to \-continuations
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
562 pushop.repo.checkpush(pushop) |
1eb2fc21da12
cleanup: prefer nested context managers to \-continuations
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
563 _checkpublish(pushop) |
1eb2fc21da12
cleanup: prefer nested context managers to \-continuations
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
564 _pushdiscovery(pushop) |
1eb2fc21da12
cleanup: prefer nested context managers to \-continuations
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
565 if not _forcebundle1(pushop): |
1eb2fc21da12
cleanup: prefer nested context managers to \-continuations
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
566 _pushbundle2(pushop) |
1eb2fc21da12
cleanup: prefer nested context managers to \-continuations
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
567 _pushchangeset(pushop) |
1eb2fc21da12
cleanup: prefer nested context managers to \-continuations
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
568 _pushsyncphase(pushop) |
1eb2fc21da12
cleanup: prefer nested context managers to \-continuations
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
569 _pushobsolete(pushop) |
1eb2fc21da12
cleanup: prefer nested context managers to \-continuations
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
570 _pushbookmark(pushop) |
33701
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
571 |
38614
4d5fb4062f0b
remotenames: synchronise remotenames after push also
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38604
diff
changeset
|
572 if repo.ui.configbool('experimental', 'remotenames'): |
4d5fb4062f0b
remotenames: synchronise remotenames after push also
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38604
diff
changeset
|
573 logexchange.pullremotenames(repo, remote) |
4d5fb4062f0b
remotenames: synchronise remotenames after push also
Pulkit Goyal <7895pulkit@gmail.com>
parents:
38604
diff
changeset
|
574 |
22616
cda85cfc8252
push: `exchange.push` now returns the `pushoperation` object
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22615
diff
changeset
|
575 return pushop |
20352
58300f61b139
push: move bookmarks exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20351
diff
changeset
|
576 |
22018
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
577 # 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
|
578 pushdiscoveryorder = [] |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
579 |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
580 # Mapping between step name and function |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
581 # |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
582 # 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
|
583 pushdiscoverymapping = {} |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
584 |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
585 def pushdiscovery(stepname): |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
586 """decorator for function performing discovery before push |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
587 |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
588 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
|
589 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
|
590 may matter). |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
591 |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
592 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
|
593 from an extension, change the pushdiscovery dictionary directly.""" |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
594 def dec(func): |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
595 assert stepname not in pushdiscoverymapping |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
596 pushdiscoverymapping[stepname] = func |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
597 pushdiscoveryorder.append(stepname) |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
598 return func |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
599 return dec |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
600 |
20466
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
601 def _pushdiscovery(pushop): |
22018
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
602 """Run all discovery steps""" |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
603 for stepname in pushdiscoveryorder: |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
604 step = pushdiscoverymapping[stepname] |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
605 step(pushop) |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
606 |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
607 @pushdiscovery('changeset') |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
608 def _pushdiscoverychangeset(pushop): |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
609 """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
|
610 fci = discovery.findcommonincoming |
35305
483b5dd0f1aa
push: restrict common discovery to the pushed set
Boris Feld <boris.feld@octobus.net>
parents:
35268
diff
changeset
|
611 if pushop.revs: |
483b5dd0f1aa
push: restrict common discovery to the pushed set
Boris Feld <boris.feld@octobus.net>
parents:
35268
diff
changeset
|
612 commoninc = fci(pushop.repo, pushop.remote, force=pushop.force, |
483b5dd0f1aa
push: restrict common discovery to the pushed set
Boris Feld <boris.feld@octobus.net>
parents:
35268
diff
changeset
|
613 ancestorsof=pushop.revs) |
483b5dd0f1aa
push: restrict common discovery to the pushed set
Boris Feld <boris.feld@octobus.net>
parents:
35268
diff
changeset
|
614 else: |
483b5dd0f1aa
push: restrict common discovery to the pushed set
Boris Feld <boris.feld@octobus.net>
parents:
35268
diff
changeset
|
615 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
|
616 common, inc, remoteheads = commoninc |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
617 fco = discovery.findcommonoutgoing |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
618 outgoing = fco(pushop.repo, pushop.remote, onlyheads=pushop.revs, |
20466
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
619 commoninc=commoninc, force=pushop.force) |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
620 pushop.outgoing = outgoing |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
621 pushop.remoteheads = remoteheads |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
622 pushop.incoming = inc |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
623 |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
624 @pushdiscovery('phase') |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
625 def _pushdiscoveryphase(pushop): |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
626 """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
|
627 |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
628 (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
|
629 outgoing = pushop.outgoing |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
630 unfi = pushop.repo.unfiltered() |
37757
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
631 remotephases = listkeys(pushop.remote, 'phases') |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
632 |
33499
0407a51b9d8c
codemod: register core configitems using a script
Jun Wu <quark@fb.com>
parents:
33138
diff
changeset
|
633 if (pushop.ui.configbool('ui', '_usedassubrepo') |
25337
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
634 and remotephases # server supports phases |
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
635 and not pushop.outgoing.missing # no changesets to be pushed |
34818
6709b5661d1b
phase: simplify the check for issue3781 shortcut in discovery
Boris Feld <boris.feld@octobus.net>
parents:
34817
diff
changeset
|
636 and remotephases.get('publishing', False)): |
25337
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
637 # When: |
636b1f1b9f8d
subrepo: detect issue3781 case earlier so it apply to bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25236
diff
changeset
|
638 # - 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
|
639 # - 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
|
640 # - 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
|
641 # - and remote is publishing |
34817
a80142b03552
exchange: fix issue3781 reference in the comment
Boris Feld <boris.feld@octobus.net>
parents:
34374
diff
changeset
|
642 # 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
|
643 # 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
|
644 # 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
|
645 # on the remote. |
34818
6709b5661d1b
phase: simplify the check for issue3781 shortcut in discovery
Boris Feld <boris.feld@octobus.net>
parents:
34817
diff
changeset
|
646 pushop.outdatedphases = [] |
6709b5661d1b
phase: simplify the check for issue3781 shortcut in discovery
Boris Feld <boris.feld@octobus.net>
parents:
34817
diff
changeset
|
647 pushop.fallbackoutdatedphases = [] |
6709b5661d1b
phase: simplify the check for issue3781 shortcut in discovery
Boris Feld <boris.feld@octobus.net>
parents:
34817
diff
changeset
|
648 return |
34819
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34818
diff
changeset
|
649 |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34818
diff
changeset
|
650 pushop.remotephases = phases.remotephasessummary(pushop.repo, |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34818
diff
changeset
|
651 pushop.fallbackheads, |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34818
diff
changeset
|
652 remotephases) |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34818
diff
changeset
|
653 droots = pushop.remotephases.draftroots |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34818
diff
changeset
|
654 |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
655 extracond = '' |
34819
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34818
diff
changeset
|
656 if not pushop.remotephases.publishing: |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
657 extracond = ' and public()' |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
658 revset = 'heads((%%ln::%%ln) %s)' % extracond |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
659 # Get the list of all revs draft on remote by public here. |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
660 # XXX Beware that revset break if droots is not strictly |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
661 # XXX root we may want to ensure it is but it is costly |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
662 fallback = list(unfi.set(revset, droots, pushop.fallbackheads)) |
40686
9b8d1ad851f8
push: add --publish flag to change phase of pushed changesets
Anton Shestakov <av6@dwimlabs.net>
parents:
40492
diff
changeset
|
663 if not pushop.remotephases.publishing and pushop.publish: |
9b8d1ad851f8
push: add --publish flag to change phase of pushed changesets
Anton Shestakov <av6@dwimlabs.net>
parents:
40492
diff
changeset
|
664 future = list(unfi.set('%ln and (not public() or %ln::)', |
9b8d1ad851f8
push: add --publish flag to change phase of pushed changesets
Anton Shestakov <av6@dwimlabs.net>
parents:
40492
diff
changeset
|
665 pushop.futureheads, droots)) |
9b8d1ad851f8
push: add --publish flag to change phase of pushed changesets
Anton Shestakov <av6@dwimlabs.net>
parents:
40492
diff
changeset
|
666 elif not outgoing.missing: |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
667 future = fallback |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
668 else: |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
669 # adds changeset we are going to push as draft |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
670 # |
23139
e53f6b72a0e4
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23082
diff
changeset
|
671 # should not be necessary for publishing server, but because of an |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
672 # issue fixed in xxxxx we have to do it anyway. |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
673 fdroots = list(unfi.set('roots(%ln + %ln::)', |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
674 outgoing.missing, droots)) |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
675 fdroots = [f.node() for f in fdroots] |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
676 future = list(unfi.set(revset, fdroots, pushop.futureheads)) |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
677 pushop.outdatedphases = future |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
678 pushop.fallbackoutdatedphases = fallback |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
679 |
22035
24bb01f42e82
push: introduce a discovery step for obsmarker
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22034
diff
changeset
|
680 @pushdiscovery('obsmarker') |
24bb01f42e82
push: introduce a discovery step for obsmarker
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22034
diff
changeset
|
681 def _pushdiscoveryobsmarkers(pushop): |
37757
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
682 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
|
683 return |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
684 |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
685 if not pushop.repo.obsstore: |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
686 return |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
687 |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
688 if 'obsolete' not in listkeys(pushop.remote, 'namespaces'): |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
689 return |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
690 |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
691 repo = pushop.repo |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
692 # 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
|
693 # However: evolution is currently slow on them anyway. |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
694 nodes = (c.node() for c in repo.set('::%ln', pushop.futureheads)) |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
695 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
|
696 |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
697 @pushdiscovery('bookmarks') |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
698 def _pushdiscoverybookmarks(pushop): |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
699 ui = pushop.ui |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
700 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
|
701 remote = pushop.remote |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
702 ui.debug("checking for updated bookmarks\n") |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
703 ancestors = () |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
704 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
|
705 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
|
706 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
|
707 |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
708 remotebookmark = listkeys(remote, 'bookmarks') |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
709 |
28182
e4fe4e903e97
bookmarks: add 'hg push -B .' for pushing the active bookmark (issue4917)
liscju <piotr.listkiewicz@gmail.com>
parents:
27953
diff
changeset
|
710 explicit = set([repo._bookmarks.expandname(bookmark) |
e4fe4e903e97
bookmarks: add 'hg push -B .' for pushing the active bookmark (issue4917)
liscju <piotr.listkiewicz@gmail.com>
parents:
27953
diff
changeset
|
711 for bookmark in pushop.bookmarks]) |
22651
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
712 |
30583
8f8211903b83
bookmarks: make bookmarks.comparebookmarks accept binary nodes (API)
Stanislau Hlebik <stash@fb.com>
parents:
30582
diff
changeset
|
713 remotebookmark = bookmod.unhexlifybookmarks(remotebookmark) |
8f8211903b83
bookmarks: make bookmarks.comparebookmarks accept binary nodes (API)
Stanislau Hlebik <stash@fb.com>
parents:
30582
diff
changeset
|
714 comp = bookmod.comparebookmarks(repo, repo._bookmarks, remotebookmark) |
8f8211903b83
bookmarks: make bookmarks.comparebookmarks accept binary nodes (API)
Stanislau Hlebik <stash@fb.com>
parents:
30582
diff
changeset
|
715 |
8f8211903b83
bookmarks: make bookmarks.comparebookmarks accept binary nodes (API)
Stanislau Hlebik <stash@fb.com>
parents:
30582
diff
changeset
|
716 def safehex(x): |
8f8211903b83
bookmarks: make bookmarks.comparebookmarks accept binary nodes (API)
Stanislau Hlebik <stash@fb.com>
parents:
30582
diff
changeset
|
717 if x is None: |
8f8211903b83
bookmarks: make bookmarks.comparebookmarks accept binary nodes (API)
Stanislau Hlebik <stash@fb.com>
parents:
30582
diff
changeset
|
718 return x |
8f8211903b83
bookmarks: make bookmarks.comparebookmarks accept binary nodes (API)
Stanislau Hlebik <stash@fb.com>
parents:
30582
diff
changeset
|
719 return hex(x) |
8f8211903b83
bookmarks: make bookmarks.comparebookmarks accept binary nodes (API)
Stanislau Hlebik <stash@fb.com>
parents:
30582
diff
changeset
|
720 |
8f8211903b83
bookmarks: make bookmarks.comparebookmarks accept binary nodes (API)
Stanislau Hlebik <stash@fb.com>
parents:
30582
diff
changeset
|
721 def hexifycompbookmarks(bookmarks): |
36937
cc51b6a07869
push-discovery: don't turn use generator when comparing bookmarks
Boris Feld <boris.feld@octobus.net>
parents:
36575
diff
changeset
|
722 return [(b, safehex(scid), safehex(dcid)) |
cc51b6a07869
push-discovery: don't turn use generator when comparing bookmarks
Boris Feld <boris.feld@octobus.net>
parents:
36575
diff
changeset
|
723 for (b, scid, dcid) in bookmarks] |
30583
8f8211903b83
bookmarks: make bookmarks.comparebookmarks accept binary nodes (API)
Stanislau Hlebik <stash@fb.com>
parents:
30582
diff
changeset
|
724 |
8f8211903b83
bookmarks: make bookmarks.comparebookmarks accept binary nodes (API)
Stanislau Hlebik <stash@fb.com>
parents:
30582
diff
changeset
|
725 comp = [hexifycompbookmarks(marks) for marks in comp] |
36938
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
726 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
|
727 |
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
728 def _processcompared(pushop, pushed, explicit, remotebms, comp): |
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
729 """take decision on bookmark to pull from the remote bookmark |
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
730 |
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
731 Exist to help extensions who want to alter this behavior. |
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
732 """ |
23081
e62c330a044f
bookmarks: explicitly track identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23047
diff
changeset
|
733 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
|
734 |
36938
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
735 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
|
736 |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
737 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
|
738 if b in explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
739 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
|
740 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
|
741 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
|
742 # search added bookmark |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
743 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
|
744 if b in explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
745 explicit.remove(b) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
746 pushop.outbookmarks.append((b, '', scid)) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
747 # search for overwritten bookmark |
30583
8f8211903b83
bookmarks: make bookmarks.comparebookmarks accept binary nodes (API)
Stanislau Hlebik <stash@fb.com>
parents:
30582
diff
changeset
|
748 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
|
749 if b in explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
750 explicit.remove(b) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
751 pushop.outbookmarks.append((b, dcid, scid)) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
752 # search for bookmark to delete |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
753 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
|
754 if b in explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
755 explicit.remove(b) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
756 # treat as "deleted locally" |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
757 pushop.outbookmarks.append((b, dcid, '')) |
23082
0fc4686de1d7
exchange: don't report failure from identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23081
diff
changeset
|
758 # 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
|
759 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
|
760 if b in explicit: |
0fc4686de1d7
exchange: don't report failure from identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23081
diff
changeset
|
761 explicit.remove(b) |
22651
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
762 |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
763 if explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
764 explicit = sorted(explicit) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
765 # we should probably list all of them |
36938
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
766 pushop.ui.warn(_('bookmark %s does not exist on the local ' |
8fd9b56e8d7c
push-discovery: extract the bookmark comparison logic in its own function
Boris Feld <boris.feld@octobus.net>
parents:
36937
diff
changeset
|
767 'or remote repository!\n') % explicit[0]) |
22651
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
768 pushop.bkresult = 2 |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
769 |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
770 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
|
771 |
20465
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
772 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
|
773 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
|
774 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
|
775 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
|
776 # 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
|
777 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
|
778 return False |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
779 # 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
|
780 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
|
781 # 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
|
782 # 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
|
783 if unfi.obsstore: |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
784 # this message are here for 80 char limit reason |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
785 mso = _("push includes obsolete changeset: %s!") |
33689
9c27a2891b75
evolution: rename bumped to phase-divergent
Boris Feld <boris.feld@octobus.net>
parents:
33688
diff
changeset
|
786 mspd = _("push includes phase-divergent changeset: %s!") |
33688
2194a8723138
evolution: rename divergent to content-divergent
Boris Feld <boris.feld@octobus.net>
parents:
33667
diff
changeset
|
787 mscd = _("push includes content-divergent changeset: %s!") |
33667
03039ff3082b
evolution: rename unstable to orphan
Boris Feld <boris.feld@octobus.net>
parents:
33499
diff
changeset
|
788 mst = {"orphan": _("push includes orphan changeset: %s!"), |
33689
9c27a2891b75
evolution: rename bumped to phase-divergent
Boris Feld <boris.feld@octobus.net>
parents:
33688
diff
changeset
|
789 "phase-divergent": mspd, |
33688
2194a8723138
evolution: rename divergent to content-divergent
Boris Feld <boris.feld@octobus.net>
parents:
33667
diff
changeset
|
790 "content-divergent": mscd} |
20465
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
791 # If we are to push if there is at least one |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
792 # obsolete or unstable changeset in missing, at |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
793 # least one of the missinghead will be obsolete or |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
794 # unstable. So checking heads only is ok |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
795 for node in outgoing.missingheads: |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
796 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
|
797 if ctx.obsolete(): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26566
diff
changeset
|
798 raise error.Abort(mso % ctx) |
33730
52c5ff856b49
context: rename troubled into isunstable
Boris Feld <boris.feld@octobus.net>
parents:
33726
diff
changeset
|
799 elif ctx.isunstable(): |
33726
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33702
diff
changeset
|
800 # TODO print more than one instability in the abort |
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33702
diff
changeset
|
801 # message |
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33702
diff
changeset
|
802 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
|
803 |
26935
c4a7bbc78c74
exchange: pass pushop to discovery.checkheads
Ryan McElroy <rmcelroy@fb.com>
parents:
26855
diff
changeset
|
804 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
|
805 return True |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
806 |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
807 # 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
|
808 b2partsgenorder = [] |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
809 |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
810 # Mapping between step name and function |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
811 # |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
812 # 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
|
813 b2partsgenmapping = {} |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
814 |
24731
88a36edefea5
bundle2: add an 'idx' argument to the 'b2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24697
diff
changeset
|
815 def b2partsgenerator(stepname, idx=None): |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
816 """decorator for function generating bundle2 part |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
817 |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
818 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
|
819 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
|
820 (this may matter). |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
821 |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
822 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
|
823 from an extension, attack the b2partsgenmapping dictionary directly.""" |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
824 def dec(func): |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
825 assert stepname not in b2partsgenmapping |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
826 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
|
827 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
|
828 b2partsgenorder.append(stepname) |
88a36edefea5
bundle2: add an 'idx' argument to the 'b2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24697
diff
changeset
|
829 else: |
88a36edefea5
bundle2: add an 'idx' argument to the 'b2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24697
diff
changeset
|
830 b2partsgenorder.insert(idx, stepname) |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
831 return func |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
832 return dec |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
833 |
26428
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
834 def _pushb2ctxcheckheads(pushop, bundler): |
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
835 """Generate race condition checking parts |
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
836 |
26781
1aee2ab0f902
spelling: trivial spell checking
Mads Kiilerich <madski@unity3d.com>
parents:
26779
diff
changeset
|
837 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
|
838 """ |
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
|
839 # * '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
|
840 # * if we don't push anything, there are nothing to check. |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
841 if not pushop.force and pushop.outgoing.missingheads: |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
842 allowunrelated = 'related' in bundler.capabilities.get('checkheads', ()) |
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
|
843 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
|
844 if not allowunrelated or emptyremote: |
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
|
845 bundler.newpart('check:heads', data=iter(pushop.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
|
846 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
|
847 affected = set() |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
848 for branch, heads in pushop.pushbranchmap.iteritems(): |
16ada4cbb1a9
push: add a way to allow concurrent pushes on unrelated heads
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32652
diff
changeset
|
849 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
|
850 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
|
851 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
|
852 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
|
853 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
|
854 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
|
855 data = iter(sorted(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
|
856 bundler.newpart('check:updated-heads', data=data) |
26428
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
857 |
34821
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
858 def _pushing(pushop): |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
859 """return True if we are pushing anything""" |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
860 return bool(pushop.outgoing.missing |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
861 or pushop.outdatedphases |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
862 or pushop.outobsmarkers |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
863 or pushop.outbookmarks) |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
864 |
35259
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
865 @b2partsgenerator('check-bookmarks') |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
866 def _pushb2checkbookmarks(pushop, bundler): |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
867 """insert bookmark move checking""" |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
868 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
|
869 return |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
870 b2caps = bundle2.bundle2caps(pushop.remote) |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
871 hasbookmarkcheck = 'bookmarks' in b2caps |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
872 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
|
873 return |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
874 data = [] |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
875 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
|
876 old = bin(old) |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
877 data.append((book, old)) |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
878 checkdata = bookmod.binaryencode(data) |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
879 bundler.newpart('check:bookmarks', data=checkdata) |
ad5f2b923b0d
push: include a 'check:bookmarks' part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35236
diff
changeset
|
880 |
34821
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
881 @b2partsgenerator('check-phases') |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
882 def _pushb2checkphases(pushop, bundler): |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
883 """insert phase move checking""" |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
884 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
|
885 return |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
886 b2caps = bundle2.bundle2caps(pushop.remote) |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
887 hasphaseheads = 'heads' in b2caps.get('phases', ()) |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
888 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
|
889 # check that the remote phase has not changed |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
890 checks = [[] for p in phases.allphases] |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
891 checks[phases.public].extend(pushop.remotephases.publicheads) |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
892 checks[phases.draft].extend(pushop.remotephases.draftroots) |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
893 if any(checks): |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
894 for nodes in checks: |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
895 nodes.sort() |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
896 checkdata = phases.binaryencode(checks) |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
897 bundler.newpart('check:phases', data=checkdata) |
aa5e7b4a3a01
phase: generate a push-race detection part on push
Boris Feld <boris.feld@octobus.net>
parents:
34819
diff
changeset
|
898 |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
899 @b2partsgenerator('changeset') |
21899
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
900 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
|
901 """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
|
902 |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
903 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
|
904 """ |
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
|
905 if 'changesets' in pushop.stepsdone: |
7a7def851ba0
push: use `stepsdone` to control changegroup push through bundle10 or bundle20
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21901
diff
changeset
|
906 return |
7a7def851ba0
push: use `stepsdone` to control changegroup push through bundle10 or bundle20
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21901
diff
changeset
|
907 pushop.stepsdone.add('changesets') |
21899
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
908 # 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
|
909 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
|
910 return |
28876
79b8f052ee51
localrepo: refactor prepushoutgoinghook to take a pushop
Mads Kiilerich <madski@unity3d.com>
parents:
28668
diff
changeset
|
911 pushop.repo.prepushoutgoinghooks(pushop) |
26428
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
912 |
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
913 _pushb2ctxcheckheads(pushop, bundler) |
b75c4651b186
bundle2: generate check:heads in a independent function
Ryan McElroy <rmcelroy@fb.com>
parents:
26184
diff
changeset
|
914 |
23180
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
915 b2caps = bundle2.bundle2caps(pushop.remote) |
28668
07f1fbf1f758
exchange: make _pushb2ctx() look more like _getbundlechangegrouppart()
Martin von Zweigbergk <martinvonz@google.com>
parents:
28667
diff
changeset
|
916 version = '01' |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
917 cgversions = b2caps.get('changegroup') |
28668
07f1fbf1f758
exchange: make _pushb2ctx() look more like _getbundlechangegrouppart()
Martin von Zweigbergk <martinvonz@google.com>
parents:
28667
diff
changeset
|
918 if cgversions: # 3.1 and 3.2 ship with an empty value |
27751
a40e2f7fe49d
changegroup: hide packermap behind methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
27738
diff
changeset
|
919 cgversions = [v for v in cgversions |
27953
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27938
diff
changeset
|
920 if v in changegroup.supportedoutgoingversions( |
88609cfa3745
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27938
diff
changeset
|
921 pushop.repo)] |
23180
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
922 if not cgversions: |
41704
3b0ba4575c8c
exchange: raise error.Abort instead of ValueError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41365
diff
changeset
|
923 raise error.Abort(_('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
|
924 version = max(cgversions) |
34098
d8245139e720
changegroup: replace getlocalchangegroupraw with makestream
Durham Goode <durham@fb.com>
parents:
34096
diff
changeset
|
925 cgstream = changegroup.makestream(pushop.repo, pushop.outgoing, version, |
d8245139e720
changegroup: replace getlocalchangegroupraw with makestream
Durham Goode <durham@fb.com>
parents:
34096
diff
changeset
|
926 'push') |
d8245139e720
changegroup: replace getlocalchangegroupraw with makestream
Durham Goode <durham@fb.com>
parents:
34096
diff
changeset
|
927 cgpart = bundler.newpart('changegroup', data=cgstream) |
28668
07f1fbf1f758
exchange: make _pushb2ctx() look more like _getbundlechangegrouppart()
Martin von Zweigbergk <martinvonz@google.com>
parents:
28667
diff
changeset
|
928 if cgversions: |
23180
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
929 cgpart.addparam('version', version) |
27938
cabac7dfc621
exchange: set 'treemanifest' param on pushed changegroups too
Martin von Zweigbergk <martinvonz@google.com>
parents:
27883
diff
changeset
|
930 if 'treemanifest' in pushop.repo.requirements: |
cabac7dfc621
exchange: set 'treemanifest' param on pushed changegroups too
Martin von Zweigbergk <martinvonz@google.com>
parents:
27883
diff
changeset
|
931 cgpart.addparam('treemanifest', '1') |
21899
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
932 def handlereply(op): |
23139
e53f6b72a0e4
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23082
diff
changeset
|
933 """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
|
934 cgreplies = op.records.getreplies(cgpart.id) |
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
935 assert len(cgreplies['changegroup']) == 1 |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
936 pushop.cgresult = cgreplies['changegroup'][0]['return'] |
21899
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
937 return handlereply |
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
938 |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
939 @b2partsgenerator('phase') |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
940 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
|
941 """handle phase push through bundle2""" |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
942 if 'phases' in pushop.stepsdone: |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
943 return |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
944 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
|
945 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
|
946 |
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
947 legacyphase = 'phases' in ui.configlist('devel', 'legacy.exchange') |
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
948 haspushkey = 'pushkey' in b2caps |
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
949 hasphaseheads = 'heads' in b2caps.get('phases', ()) |
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
950 |
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
951 if hasphaseheads and not legacyphase: |
34910
498697fe41f2
exchange: propagate the subfunctions return
Boris Feld <boris.feld@octobus.net>
parents:
34836
diff
changeset
|
952 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
|
953 elif haspushkey: |
34910
498697fe41f2
exchange: propagate the subfunctions return
Boris Feld <boris.feld@octobus.net>
parents:
34836
diff
changeset
|
954 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
|
955 |
34836
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
956 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
|
957 """push phase information through a bundle2 - binary part""" |
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
958 pushop.stepsdone.add('phases') |
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
959 if pushop.outdatedphases: |
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
960 updates = [[] for p in phases.allphases] |
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
961 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
|
962 phasedata = phases.binaryencode(updates) |
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
963 bundler.newpart('phase-heads', data=phasedata) |
537de0b14030
phase: use a binary phase part to push through bundle2 (BC)
Boris Feld <boris.feld@octobus.net>
parents:
34822
diff
changeset
|
964 |
34822
c1e7ce11db9b
phase: isolate logic to update remote phrase through bundle2 pushkey
Boris Feld <boris.feld@octobus.net>
parents:
34821
diff
changeset
|
965 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
|
966 """push phase information through a bundle2 - pushkey part""" |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
967 pushop.stepsdone.add('phases') |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
968 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
|
969 |
bd41c19383db
phases: abort the whole push if phases fail to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25501
diff
changeset
|
970 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
|
971 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
|
972 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
|
973 if partid == targetid: |
bd41c19383db
phases: abort the whole push if phases fail to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25501
diff
changeset
|
974 raise error.Abort(_('updating %s to public failed') % node) |
bd41c19383db
phases: abort the whole push if phases fail to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25501
diff
changeset
|
975 |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
976 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
|
977 for newremotehead in pushop.outdatedphases: |
25502
bd41c19383db
phases: abort the whole push if phases fail to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25501
diff
changeset
|
978 part = bundler.newpart('pushkey') |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
979 part.addparam('namespace', enc('phases')) |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
980 part.addparam('key', enc(newremotehead.hex())) |
34203
3a5d8e2996f8
exchange: use '%d' % x instead of str(x) to encode ints
Augie Fackler <raf@durin42.com>
parents:
34127
diff
changeset
|
981 part.addparam('old', enc('%d' % phases.draft)) |
3a5d8e2996f8
exchange: use '%d' % x instead of str(x) to encode ints
Augie Fackler <raf@durin42.com>
parents:
34127
diff
changeset
|
982 part.addparam('new', enc('%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
|
983 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
|
984 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
|
985 |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
986 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
|
987 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
|
988 partrep = op.records.getreplies(partid) |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
989 results = partrep['pushkey'] |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
990 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
|
991 msg = None |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
992 if not results: |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
993 msg = _('server ignored update of %s to public!\n') % node |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
994 elif not int(results[0]['return']): |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
995 msg = _('updating %s to public failed!\n') % node |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
996 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
|
997 pushop.ui.warn(msg) |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
998 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
|
999 |
22347
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
1000 @b2partsgenerator('obsmarkers') |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
1001 def _pushb2obsmarkers(pushop, bundler): |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
1002 if 'obsmarkers' in pushop.stepsdone: |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
1003 return |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
1004 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
|
1005 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
|
1006 return |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
1007 pushop.stepsdone.add('obsmarkers') |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
1008 if pushop.outobsmarkers: |
25118
e632a2429982
obsolete: sort obsmarkers during exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24878
diff
changeset
|
1009 markers = sorted(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
|
1010 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
|
1011 |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1012 @b2partsgenerator('bookmarks') |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1013 def _pushb2bookmarks(pushop, bundler): |
25895
c30b739c322f
exchange: s/phase/bookmark/ in _pushb2bookmarks()
Martin von Zweigbergk <martinvonz@google.com>
parents:
25836
diff
changeset
|
1014 """handle bookmark push through bundle2""" |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1015 if 'bookmarks' in pushop.stepsdone: |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1016 return |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1017 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
|
1018 |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1019 legacy = pushop.repo.ui.configlist('devel', 'legacy.exchange') |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1020 legacybooks = 'bookmarks' in legacy |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1021 |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1022 if not legacybooks and 'bookmarks' in b2caps: |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1023 return _pushb2bookmarkspart(pushop, bundler) |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1024 elif '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
|
1025 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
|
1026 |
35264
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1027 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
|
1028 """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
|
1029 if not old: |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1030 return 'export' |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1031 elif not new: |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1032 return 'delete' |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1033 return 'update' |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1034 |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1035 def _pushb2bookmarkspart(pushop, bundler): |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1036 pushop.stepsdone.add('bookmarks') |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1037 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
|
1038 return |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1039 |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1040 allactions = [] |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1041 data = [] |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1042 for book, old, new in pushop.outbookmarks: |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1043 new = bin(new) |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1044 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
|
1045 allactions.append((book, _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
|
1046 checkdata = bookmod.binaryencode(data) |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1047 bundler.newpart('bookmarks', data=checkdata) |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1048 |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1049 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
|
1050 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
|
1051 # if success |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1052 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
|
1053 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
|
1054 |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1055 return handlereply |
a1e70c1dbec0
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)
Boris Feld <boris.feld@octobus.net>
parents:
35262
diff
changeset
|
1056 |
35262
3fd5f05a5b87
push: move bundle2-pushkey based bookmarks exchange in its own function
Boris Feld <boris.feld@octobus.net>
parents:
35259
diff
changeset
|
1057 def _pushb2bookmarkspushkey(pushop, bundler): |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1058 pushop.stepsdone.add('bookmarks') |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1059 part2book = [] |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1060 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
|
1061 |
a99fee62611d
bookmarks: abort the whole push if bookmarks fails to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25485
diff
changeset
|
1062 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
|
1063 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
|
1064 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
|
1065 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
|
1066 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
|
1067 # 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
|
1068 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
|
1069 |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1070 for book, old, new in pushop.outbookmarks: |
25501
a99fee62611d
bookmarks: abort the whole push if bookmarks fails to update (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25485
diff
changeset
|
1071 part = bundler.newpart('pushkey') |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1072 part.addparam('namespace', enc('bookmarks')) |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1073 part.addparam('key', enc(book)) |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1074 part.addparam('old', enc(old)) |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1075 part.addparam('new', enc(new)) |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1076 action = 'update' |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1077 if not old: |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1078 action = 'export' |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1079 elif not new: |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1080 action = 'delete' |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1081 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
|
1082 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
|
1083 |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1084 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
|
1085 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
|
1086 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
|
1087 partrep = op.records.getreplies(partid) |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1088 results = partrep['pushkey'] |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1089 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
|
1090 if not results: |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1091 pushop.ui.warn(_('server ignored bookmark %s update\n') % book) |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1092 else: |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1093 ret = int(results[0]['return']) |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1094 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
|
1095 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
|
1096 else: |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1097 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
|
1098 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
|
1099 pushop.bkresult = 1 |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1100 return handlereply |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
1101 |
33693
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33689
diff
changeset
|
1102 @b2partsgenerator('pushvars', idx=0) |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33689
diff
changeset
|
1103 def _getbundlesendvars(pushop, bundler): |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33689
diff
changeset
|
1104 '''send shellvars via bundle2''' |
33885 | 1105 pushvars = pushop.pushvars |
1106 if pushvars: | |
1107 shellvars = {} | |
1108 for raw in pushvars: | |
1109 if '=' not in raw: | |
1110 msg = ("unable to parse variable '%s', should follow " | |
1111 "'KEY=VALUE' or 'KEY=' format") | |
1112 raise error.Abort(msg % raw) | |
1113 k, v = raw.split('=', 1) | |
1114 shellvars[k] = v | |
1115 | |
33693
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33689
diff
changeset
|
1116 part = bundler.newpart('pushvars') |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33689
diff
changeset
|
1117 |
33885 | 1118 for key, value in shellvars.iteritems(): |
33693
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33689
diff
changeset
|
1119 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
|
1120 |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1121 def _pushbundle2(pushop): |
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1122 """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
|
1123 |
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1124 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
|
1125 evolve in the future.""" |
21644
17755dd8c509
bundle2: introduce a bundle2caps function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21643
diff
changeset
|
1126 bundler = bundle2.bundle20(pushop.ui, bundle2.bundle2caps(pushop.remote)) |
23439
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
1127 pushback = (pushop.trmanager |
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
1128 and pushop.ui.configbool('experimental', 'bundle2.pushback')) |
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
1129 |
21142
15039ce3e4a3
bundle2: include client capabilities in the pushed bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21141
diff
changeset
|
1130 # create reply capability |
23439
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
1131 capsblob = bundle2.encodecaps(bundle2.getrepocaps(pushop.repo, |
35783
c97639ad6874
bundle2: specify what capabilities will be used for
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35765
diff
changeset
|
1132 allowpushback=pushback, |
c97639ad6874
bundle2: specify what capabilities will be used for
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35765
diff
changeset
|
1133 role='client')) |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
1134 bundler.newpart('replycaps', data=capsblob) |
21904
5fbccbcc07ea
bundle2-push: introduce a list of part generating functions
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21903
diff
changeset
|
1135 replyhandlers = [] |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
1136 for partgenname in b2partsgenorder: |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
1137 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
|
1138 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
|
1139 if callable(ret): |
dab31290c7eb
bundle2: only use callable return as reply handler
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21906
diff
changeset
|
1140 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
|
1141 # 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
|
1142 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
|
1143 return |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1144 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
|
1145 try: |
25485
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
1146 try: |
37646
72e26319f3b8
wireproto: use command executor for unbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
1147 with pushop.remote.commandexecutor() as e: |
72e26319f3b8
wireproto: use command executor for unbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
1148 reply = e.callcommand('unbundle', { |
72e26319f3b8
wireproto: use command executor for unbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
1149 'bundle': stream, |
72e26319f3b8
wireproto: use command executor for unbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
1150 'heads': ['force'], |
72e26319f3b8
wireproto: use command executor for unbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
1151 'url': pushop.remote.url(), |
72e26319f3b8
wireproto: use command executor for unbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
1152 }).result() |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25640
diff
changeset
|
1153 except error.BundleValueError as exc: |
29389
98e8313dcd9e
i18n: translate abort messages
liscju <piotr.listkiewicz@gmail.com>
parents:
29376
diff
changeset
|
1154 raise error.Abort(_('missing support for %s') % exc) |
25485
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
1155 try: |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
1156 trgetter = None |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
1157 if pushback: |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
1158 trgetter = pushop.trmanager.transaction |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
1159 op = bundle2.processbundle(pushop.repo, reply, trgetter) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25640
diff
changeset
|
1160 except error.BundleValueError as exc: |
29389
98e8313dcd9e
i18n: translate abort messages
liscju <piotr.listkiewicz@gmail.com>
parents:
29376
diff
changeset
|
1161 raise error.Abort(_('missing support for %s') % exc) |
26829
58f1645f72c3
bundle2: attribute remote failures to remote (issue4788)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26781
diff
changeset
|
1162 except bundle2.AbortFromPart as exc: |
58f1645f72c3
bundle2: attribute remote failures to remote (issue4788)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26781
diff
changeset
|
1163 pushop.ui.status(_('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
|
1164 if exc.hint is not None: |
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
|
1165 pushop.ui.status(_('remote: %s\n') % ('(%s)' % exc.hint)) |
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
|
1166 raise error.Abort(_('push failed on remote')) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25640
diff
changeset
|
1167 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
|
1168 partid = int(exc.partid) |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
1169 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
|
1170 raise |
8182163ae983
push: catch and process PushkeyFailed error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25480
diff
changeset
|
1171 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
|
1172 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
|
1173 rephand(op) |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1174 |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1175 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
|
1176 """Make the actual push of changeset bundle to remote repo""" |
21902
7a7def851ba0
push: use `stepsdone` to control changegroup push through bundle10 or bundle20
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21901
diff
changeset
|
1177 if 'changesets' in pushop.stepsdone: |
7a7def851ba0
push: use `stepsdone` to control changegroup push through bundle10 or bundle20
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21901
diff
changeset
|
1178 return |
7a7def851ba0
push: use `stepsdone` to control changegroup push through bundle10 or bundle20
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21901
diff
changeset
|
1179 pushop.stepsdone.add('changesets') |
21903
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
1180 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
|
1181 return |
33701
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1182 |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1183 # Should have verified this in push(). |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1184 assert pushop.remote.capable('unbundle') |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1185 |
28876
79b8f052ee51
localrepo: refactor prepushoutgoinghook to take a pushop
Mads Kiilerich <madski@unity3d.com>
parents:
28668
diff
changeset
|
1186 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
|
1187 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
|
1188 # 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
|
1189 bundlecaps = None |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1190 # create a changegroup from local |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1191 if pushop.revs is None and not (outgoing.excluded |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1192 or pushop.repo.changelog.filteredrevs): |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1193 # push everything, |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1194 # use the fast path, no race possible on push |
34096
f85dfde1731a
changegroup: replace getsubset with makechangegroup
Durham Goode <durham@fb.com>
parents:
33886
diff
changeset
|
1195 cg = changegroup.makechangegroup(pushop.repo, outgoing, '01', 'push', |
f85dfde1731a
changegroup: replace getsubset with makechangegroup
Durham Goode <durham@fb.com>
parents:
33886
diff
changeset
|
1196 fastpath=True, bundlecaps=bundlecaps) |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1197 else: |
34101
5ede882c249c
changegroup: replace getchangegroup with makechangegroup
Durham Goode <durham@fb.com>
parents:
34098
diff
changeset
|
1198 cg = changegroup.makechangegroup(pushop.repo, outgoing, '01', |
5ede882c249c
changegroup: replace getchangegroup with makechangegroup
Durham Goode <durham@fb.com>
parents:
34098
diff
changeset
|
1199 'push', bundlecaps=bundlecaps) |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1200 |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1201 # apply changegroup to remote |
33701
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1202 # 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
|
1203 # 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
|
1204 # 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
|
1205 # commit/push race), server aborts. |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1206 if pushop.force: |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1207 remoteheads = ['force'] |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1208 else: |
33701
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1209 remoteheads = pushop.remoteheads |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1210 # ssh: return remote's addchangegroup() |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1211 # http: return remote's addchangegroup() or 0 for error |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1212 pushop.cgresult = pushop.remote.unbundle(cg, remoteheads, |
fda0867cfe03
exchange: drop support for lock-based unbundling (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33693
diff
changeset
|
1213 pushop.repo.url()) |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
1214 |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1215 def _pushsyncphase(pushop): |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
1216 """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
|
1217 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
|
1218 # even when we don't push, exchanging phase data is useful |
37757
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
1219 remotephases = listkeys(pushop.remote, 'phases') |
33499
0407a51b9d8c
codemod: register core configitems using a script
Jun Wu <quark@fb.com>
parents:
33138
diff
changeset
|
1220 if (pushop.ui.configbool('ui', '_usedassubrepo') |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1221 and remotephases # server supports phases |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
1222 and pushop.cgresult is None # nothing was pushed |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1223 and remotephases.get('publishing', False)): |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1224 # When: |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1225 # - 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
|
1226 # - 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
|
1227 # - 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
|
1228 # - 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
|
1229 # 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
|
1230 # 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
|
1231 # 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
|
1232 # on the remote. |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1233 remotephases = {'publishing': 'True'} |
21012
c827a0028e6f
exchange: restore truncated comment
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21005
diff
changeset
|
1234 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
|
1235 _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
|
1236 # 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
|
1237 else: |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1238 ana = phases.analyzeremotephases(pushop.repo, cheads, |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1239 remotephases) |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1240 pheads, droots = ana |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1241 ### Apply remote phase on local |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1242 if remotephases.get('publishing', False): |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1243 _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
|
1244 else: # publish = False |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1245 _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
|
1246 _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
|
1247 ### 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
|
1248 |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
1249 if pushop.cgresult: |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
1250 if 'phases' in pushop.stepsdone: |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
1251 # 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
|
1252 return |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
1253 outdated = pushop.outdatedphases |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
1254 else: |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
1255 outdated = pushop.fallbackoutdatedphases |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
1256 |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
1257 pushop.stepsdone.add('phases') |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
1258 |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
1259 # 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
|
1260 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
|
1261 # 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
|
1262 for newremotehead in outdated: |
37647
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1263 with pushop.remote.commandexecutor() as e: |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1264 r = e.callcommand('pushkey', { |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1265 'namespace': 'phases', |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1266 'key': newremotehead.hex(), |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1267 'old': '%d' % phases.draft, |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1268 'new': '%d' % phases.public |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1269 }).result() |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1270 |
23376
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
1271 if not r: |
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
1272 pushop.ui.warn(_('updating %s to public failed!\n') |
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
1273 % newremotehead) |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
1274 |
20438
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1275 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
|
1276 """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
|
1277 if pushop.trmanager: |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
1278 phases.advanceboundary(pushop.repo, |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
1279 pushop.trmanager.transaction(), |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
1280 phase, |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
1281 nodes) |
20438
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1282 else: |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1283 # 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
|
1284 # 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
|
1285 # applicable. |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1286 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
|
1287 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
|
1288 if actualmoves: |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1289 pushop.ui.status(_('cannot lock source repo, skipping ' |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1290 'local %s phase update\n') % phasestr) |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
1291 |
20433
6af248474224
push: feed pushoperation object to _pushobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20432
diff
changeset
|
1292 def _pushobsolete(pushop): |
20434
e009e59e4566
push: drop now outdated comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20433
diff
changeset
|
1293 """utility function to push obsolete markers to a remote""" |
22036
f1528ef123f4
push: use stepsdone for obsmarkers push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22035
diff
changeset
|
1294 if 'obsmarkers' in pushop.stepsdone: |
f1528ef123f4
push: use stepsdone for obsmarkers push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22035
diff
changeset
|
1295 return |
20433
6af248474224
push: feed pushoperation object to _pushobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20432
diff
changeset
|
1296 repo = pushop.repo |
6af248474224
push: feed pushoperation object to _pushobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20432
diff
changeset
|
1297 remote = pushop.remote |
22036
f1528ef123f4
push: use stepsdone for obsmarkers push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22035
diff
changeset
|
1298 pushop.stepsdone.add('obsmarkers') |
22350
6d113cc7a31a
push: only push obsmarkers relevant to the "pushed subset"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22347
diff
changeset
|
1299 if pushop.outobsmarkers: |
25559
521c1a3139c9
push: only say we are trying to push obsmarkers when we actually try
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25516
diff
changeset
|
1300 pushop.ui.debug('try to push obsolete markers to remote\n') |
20432
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1301 rslts = [] |
25118
e632a2429982
obsolete: sort obsmarkers during exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24878
diff
changeset
|
1302 remotedata = obsolete._pushkeyescape(sorted(pushop.outobsmarkers)) |
20432
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1303 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
|
1304 # 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
|
1305 data = remotedata[key] |
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1306 rslts.append(remote.pushkey('obsolete', key, '', data)) |
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1307 if [r for r in rslts if not r]: |
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1308 msg = _('failed to push some obsolete markers!\n') |
1b926f0bbf8a
push: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20431
diff
changeset
|
1309 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
|
1310 |
20431
bebf8b8479f3
push: feed pushoperation object to _pushbookmark function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20352
diff
changeset
|
1311 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
|
1312 """Update bookmark position on remote""" |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
1313 if pushop.cgresult == 0 or 'bookmarks' in pushop.stepsdone: |
22228
a3dc2d385490
pushbookmark: do not attempt to update bookmarks if the push failed (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22227
diff
changeset
|
1314 return |
22240
d092f4b68fb6
push: use stepsdone to control bookmark push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22239
diff
changeset
|
1315 pushop.stepsdone.add('bookmarks') |
20431
bebf8b8479f3
push: feed pushoperation object to _pushbookmark function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20352
diff
changeset
|
1316 ui = pushop.ui |
bebf8b8479f3
push: feed pushoperation object to _pushbookmark function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20352
diff
changeset
|
1317 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
|
1318 |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
1319 for b, old, new in pushop.outbookmarks: |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1320 action = 'update' |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1321 if not old: |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1322 action = 'export' |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1323 elif not new: |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1324 action = 'delete' |
37647
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1325 |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1326 with remote.commandexecutor() as e: |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1327 r = e.callcommand('pushkey', { |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1328 'namespace': 'bookmarks', |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1329 'key': b, |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1330 'old': old, |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1331 'new': new, |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1332 }).result() |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1333 |
516b5a5edae3
exchange: use command executor for pushkey
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37646
diff
changeset
|
1334 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
|
1335 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
|
1336 else: |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
1337 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
|
1338 # 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
|
1339 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
|
1340 pushop.bkresult = 1 |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1341 |
20472
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1342 class pulloperation(object): |
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1343 """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
|
1344 |
23219
61cd79ac4b99
exchange: swap "push" for "pull" in pulloperation docstring
Mike Edgar <adgar@google.com>
parents:
23218
diff
changeset
|
1345 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
|
1346 |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
1347 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
|
1348 afterward. |
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1349 """ |
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1350 |
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
|
1351 def __init__(self, repo, remote, heads=None, force=False, bookmarks=(), |
39553
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1352 remotebookmarks=None, streamclonerequested=None, |
40331
ac59de55c8b4
exchange: support declaring pull depth
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39911
diff
changeset
|
1353 includepats=None, excludepats=None, depth=None): |
20596
004a1744088d
exchange: fix docs for pulloperation
Siddharth Agarwal <sid0@fb.com>
parents:
20489
diff
changeset
|
1354 # repo we pull into |
20472
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
1355 self.repo = repo |
20596
004a1744088d
exchange: fix docs for pulloperation
Siddharth Agarwal <sid0@fb.com>
parents:
20489
diff
changeset
|
1356 # 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
|
1357 self.remote = remote |
20474
c9bceafc61be
pull: move `heads` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20473
diff
changeset
|
1358 # 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
|
1359 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
|
1360 # bookmark pulled explicitly |
29376
113d0b23321a
bookmarks: add 'hg pull -B .' for pulling the active bookmark (issue5258)
liscju <piotr.listkiewicz@gmail.com>
parents:
29341
diff
changeset
|
1361 self.explicitbookmarks = [repo._bookmarks.expandname(bookmark) |
113d0b23321a
bookmarks: add 'hg pull -B .' for pulling the active bookmark (issue5258)
liscju <piotr.listkiewicz@gmail.com>
parents:
29341
diff
changeset
|
1362 for bookmark in bookmarks] |
20475
b79b405583af
pull: move `force` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20474
diff
changeset
|
1363 # do we force pull? |
b79b405583af
pull: move `force` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20474
diff
changeset
|
1364 self.force = force |
26448
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1365 # whether a streaming clone was requested |
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1366 self.streamclonerequested = streamclonerequested |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1367 # transaction manager |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1368 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
|
1369 # 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
|
1370 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
|
1371 # 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
|
1372 self.rheads = None |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
1373 # 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
|
1374 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
|
1375 # 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
|
1376 self.remotebookmarks = remotebookmarks |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
1377 # 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
|
1378 self.cgresult = None |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1379 # list of step already done |
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1380 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
|
1381 # 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
|
1382 self.clonebundleattempted = False |
39553
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1383 # 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
|
1384 self.includepats = includepats |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1385 # 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
|
1386 self.excludepats = excludepats |
40331
ac59de55c8b4
exchange: support declaring pull depth
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39911
diff
changeset
|
1387 # 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
|
1388 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
|
1389 |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1390 @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
|
1391 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
|
1392 """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
|
1393 # 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
|
1394 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
|
1395 # 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
|
1396 # 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
|
1397 c = set(self.common) |
09e7118715eb
pull: prevent duplicated entry in `op.pulledsubset`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20596
diff
changeset
|
1398 ret = list(self.common) |
09e7118715eb
pull: prevent duplicated entry in `op.pulledsubset`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20596
diff
changeset
|
1399 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
|
1400 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
|
1401 ret.append(n) |
09e7118715eb
pull: prevent duplicated entry in `op.pulledsubset`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20596
diff
changeset
|
1402 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
|
1403 else: |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
1404 # 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
|
1405 # 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
|
1406 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
|
1407 |
26464
9a7fc6d48898
exchange: expose bundle2 capabilities on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26462
diff
changeset
|
1408 @util.propertycache |
26465
eda32ee9962f
exchange: expose bundle2 availability on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26464
diff
changeset
|
1409 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
|
1410 return not _forcebundle1(self) |
26465
eda32ee9962f
exchange: expose bundle2 availability on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26464
diff
changeset
|
1411 |
eda32ee9962f
exchange: expose bundle2 availability on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26464
diff
changeset
|
1412 @util.propertycache |
26464
9a7fc6d48898
exchange: expose bundle2 capabilities on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26462
diff
changeset
|
1413 def remotebundle2caps(self): |
9a7fc6d48898
exchange: expose bundle2 capabilities on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26462
diff
changeset
|
1414 return bundle2.bundle2caps(self.remote) |
9a7fc6d48898
exchange: expose bundle2 capabilities on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26462
diff
changeset
|
1415 |
20477
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
1416 def gettransaction(self): |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1417 # deprecated; talk to trmanager directly |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1418 return self.trmanager.transaction() |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1419 |
33793
bbbbd3c30bfc
util: add base class for transactional context managers
Martin von Zweigbergk <martinvonz@google.com>
parents:
33792
diff
changeset
|
1420 class transactionmanager(util.transactional): |
23543
4dd8a6a1240d
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23439
diff
changeset
|
1421 """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
|
1422 |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1423 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
|
1424 closing the transaction.""" |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1425 def __init__(self, repo, source, url): |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1426 self.repo = repo |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1427 self.source = source |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1428 self.url = url |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1429 self._tr = None |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1430 |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1431 def transaction(self): |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1432 """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
|
1433 if not self._tr: |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1434 trname = '%s\n%s' % (self.source, util.hidepassword(self.url)) |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1435 self._tr = self.repo.transaction(trname) |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1436 self._tr.hookargs['source'] = self.source |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1437 self._tr.hookargs['url'] = self.url |
20477
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
1438 return self._tr |
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
1439 |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1440 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
|
1441 """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
|
1442 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
|
1443 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
|
1444 |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
1445 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
|
1446 """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
|
1447 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
|
1448 self._tr.release() |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1449 |
37757
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
1450 def listkeys(remote, namespace): |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
1451 with remote.commandexecutor() as e: |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
1452 return e.callcommand('listkeys', {'namespace': namespace}).result() |
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
1453 |
37498
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1454 def _fullpullbundle2(repo, pullop): |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1455 # 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
|
1456 # pre-computed bundles. In that case, update the common |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1457 # set based on the results and pull another bundle. |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1458 # |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1459 # There are two indicators that the process is finished: |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1460 # - no changeset has been added, or |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1461 # - all remote heads are known locally. |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1462 # The head check must use the unfiltered view as obsoletion |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1463 # markers can hide heads. |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1464 unfi = repo.unfiltered() |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1465 unficl = unfi.changelog |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1466 def headsofdiff(h1, h2): |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1467 """Returns heads(h1 % h2)""" |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1468 res = unfi.set('heads(%ln %% %ln)', h1, h2) |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1469 return set(ctx.node() for ctx in res) |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1470 def headsofunion(h1, h2): |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1471 """Returns heads((h1 + h2) - null)""" |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1472 res = unfi.set('heads((%ln + %ln - null))', h1, h2) |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1473 return set(ctx.node() for ctx in res) |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1474 while True: |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1475 old_heads = unficl.heads() |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1476 clstart = len(unficl) |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1477 _pullbundle2(pullop) |
38835
a232e6744ba3
narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents:
38808
diff
changeset
|
1478 if repository.NARROW_REQUIREMENT in repo.requirements: |
37498
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1479 # 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
|
1480 # XXX getbundle and result in partial replies as well. |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1481 # 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
|
1482 # XXX extra round trips. |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1483 break |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1484 if clstart == len(unficl): |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1485 break |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1486 if all(unficl.hasnode(n) for n in pullop.rheads): |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1487 break |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1488 new_heads = headsofdiff(unficl.heads(), old_heads) |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1489 pullop.common = headsofunion(new_heads, pullop.common) |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1490 pullop.rheads = set(pullop.rheads) - pullop.common |
aacfca6f9767
wireproto: support for pullbundles
Joerg Sonnenberger <joerg@bec.de>
parents:
37237
diff
changeset
|
1491 |
26448
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1492 def pull(repo, remote, heads=None, force=False, bookmarks=(), opargs=None, |
40331
ac59de55c8b4
exchange: support declaring pull depth
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39911
diff
changeset
|
1493 streamclonerequested=None, includepats=None, excludepats=None, |
ac59de55c8b4
exchange: support declaring pull depth
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39911
diff
changeset
|
1494 depth=None): |
26440
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1495 """Fetch repository data from a remote. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1496 |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1497 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
|
1498 |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1499 ``repo`` is the local repository to clone into. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1500 ``remote`` is a peer instance. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1501 ``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
|
1502 default) means to pull everything from the remote. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1503 ``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
|
1504 default, all remote bookmarks are pulled. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1505 ``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
|
1506 initialization. |
26448
e05fd574c922
exchange: teach pull about requested stream clones
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26443
diff
changeset
|
1507 ``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
|
1508 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
|
1509 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
|
1510 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
|
1511 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
|
1512 ``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
|
1513 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
|
1514 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
|
1515 ``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
|
1516 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
|
1517 will fetch up to this many of its ancestors and data associated with them. |
26440
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1518 |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1519 Returns the ``pulloperation`` created for this pull. |
85b992177d2a
exchange: add docstring to pull()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26428
diff
changeset
|
1520 """ |
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
|
1521 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
|
1522 opargs = {} |
39553
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1523 |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1524 # 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
|
1525 # flexibility for API consumers. |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1526 if includepats or excludepats: |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1527 includepats = includepats or set() |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1528 excludepats = excludepats or set() |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1529 else: |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1530 includepats, excludepats = repo.narrowpats |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1531 |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1532 narrowspec.validatepatterns(includepats) |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1533 narrowspec.validatepatterns(excludepats) |
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1534 |
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
|
1535 pullop = pulloperation(repo, remote, heads, force, bookmarks=bookmarks, |
35355
a119e97b6caf
py3: handle keyword arguments correctly in exchange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35347
diff
changeset
|
1536 streamclonerequested=streamclonerequested, |
39553
130e5df346d5
exchange: support defining narrow file patterns for pull
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39158
diff
changeset
|
1537 includepats=includepats, excludepats=excludepats, |
40331
ac59de55c8b4
exchange: support declaring pull depth
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39911
diff
changeset
|
1538 depth=depth, |
35355
a119e97b6caf
py3: handle keyword arguments correctly in exchange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35347
diff
changeset
|
1539 **pycompat.strkwargs(opargs)) |
33702
033484935391
exchange: access requirements on repo instead of peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33701
diff
changeset
|
1540 |
033484935391
exchange: access requirements on repo instead of peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33701
diff
changeset
|
1541 peerlocal = pullop.remote.local() |
033484935391
exchange: access requirements on repo instead of peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33701
diff
changeset
|
1542 if peerlocal: |
033484935391
exchange: access requirements on repo instead of peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33701
diff
changeset
|
1543 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
|
1544 if missing: |
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1545 msg = _("required features are not" |
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1546 " supported in the destination:" |
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1547 " %s") % (', '.join(sorted(missing))) |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26566
diff
changeset
|
1548 raise error.Abort(msg) |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1549 |
35578
86f9aabed67b
exchange: use context manager for locks and transaction in unbundle()
Martin von Zweigbergk <martinvonz@google.com>
parents:
35355
diff
changeset
|
1550 pullop.trmanager = transactionmanager(repo, 'pull', remote.url()) |
86f9aabed67b
exchange: use context manager for locks and transaction in unbundle()
Martin von Zweigbergk <martinvonz@google.com>
parents:
35355
diff
changeset
|
1551 with repo.wlock(), repo.lock(), pullop.trmanager: |
39629
a86d21e70b2b
exchangev2: start to implement pull with wire protocol v2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39553
diff
changeset
|
1552 # Use the modern wire protocol, if available. |
39630
9c2c77c73f23
wireprotov2: define and implement "changesetdata" command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39629
diff
changeset
|
1553 if remote.capable('command-changesetdata'): |
39629
a86d21e70b2b
exchangev2: start to implement pull with wire protocol v2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39553
diff
changeset
|
1554 exchangev2.pull(pullop) |
a86d21e70b2b
exchangev2: start to implement pull with wire protocol v2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39553
diff
changeset
|
1555 else: |
a86d21e70b2b
exchangev2: start to implement pull with wire protocol v2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39553
diff
changeset
|
1556 # This should ideally be in _pullbundle2(). However, it needs to run |
a86d21e70b2b
exchangev2: start to implement pull with wire protocol v2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39553
diff
changeset
|
1557 # before discovery to avoid extra work. |
a86d21e70b2b
exchangev2: start to implement pull with wire protocol v2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39553
diff
changeset
|
1558 _maybeapplyclonebundle(pullop) |
a86d21e70b2b
exchangev2: start to implement pull with wire protocol v2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39553
diff
changeset
|
1559 streamclone.maybeperformlegacystreamclone(pullop) |
a86d21e70b2b
exchangev2: start to implement pull with wire protocol v2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39553
diff
changeset
|
1560 _pulldiscovery(pullop) |
a86d21e70b2b
exchangev2: start to implement pull with wire protocol v2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39553
diff
changeset
|
1561 if pullop.canusebundle2: |
a86d21e70b2b
exchangev2: start to implement pull with wire protocol v2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39553
diff
changeset
|
1562 _fullpullbundle2(repo, pullop) |
a86d21e70b2b
exchangev2: start to implement pull with wire protocol v2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39553
diff
changeset
|
1563 _pullchangeset(pullop) |
a86d21e70b2b
exchangev2: start to implement pull with wire protocol v2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39553
diff
changeset
|
1564 _pullphase(pullop) |
a86d21e70b2b
exchangev2: start to implement pull with wire protocol v2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39553
diff
changeset
|
1565 _pullbookmarks(pullop) |
a86d21e70b2b
exchangev2: start to implement pull with wire protocol v2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39553
diff
changeset
|
1566 _pullobsolete(pullop) |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
1567 |
35236
5a62910948d2
remotenames: move function to pull remotenames from the remoterepo to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35041
diff
changeset
|
1568 # storing remotenames |
5a62910948d2
remotenames: move function to pull remotenames from the remoterepo to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35041
diff
changeset
|
1569 if repo.ui.configbool('experimental', 'remotenames'): |
35347
a29fe459fc49
remotenames: rename related file and storage dir to logexchange
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35305
diff
changeset
|
1570 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
|
1571 |
22693
68439b154063
exchange: have `pull` return the pulloperation object
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22666
diff
changeset
|
1572 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
|
1573 |
22936
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1574 # 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
|
1575 pulldiscoveryorder = [] |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1576 |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1577 # Mapping between step name and function |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1578 # |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1579 # 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
|
1580 pulldiscoverymapping = {} |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1581 |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1582 def pulldiscovery(stepname): |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1583 """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
|
1584 |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1585 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
|
1586 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
|
1587 may matter). |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1588 |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1589 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
|
1590 from an extension, change the pulldiscovery dictionary directly.""" |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1591 def dec(func): |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1592 assert stepname not in pulldiscoverymapping |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1593 pulldiscoverymapping[stepname] = func |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1594 pulldiscoveryorder.append(stepname) |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1595 return func |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1596 return dec |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1597 |
20900
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1598 def _pulldiscovery(pullop): |
22936
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1599 """Run all discovery steps""" |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1600 for stepname in pulldiscoveryorder: |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1601 step = pulldiscoverymapping[stepname] |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1602 step(pullop) |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1603 |
25369
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1604 @pulldiscovery('b1:bookmarks') |
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1605 def _pullbookmarkbundle1(pullop): |
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1606 """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
|
1607 |
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1608 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
|
1609 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
|
1610 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
|
1611 return |
26465
eda32ee9962f
exchange: expose bundle2 availability on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26464
diff
changeset
|
1612 if pullop.canusebundle2 and 'listkeys' in pullop.remotebundle2caps: |
25479
f00a63a43c4b
bundle2: pull bookmark the old way if no bundle2 listkeys support (issue4701)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25446
diff
changeset
|
1613 # 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
|
1614 # 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
|
1615 return |
37757
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
1616 books = listkeys(pullop.remote, 'bookmarks') |
35039
d7a4384d2d87
pull: store binary node in pullop.remotebookmarks
Boris Feld <boris.feld@octobus.net>
parents:
34910
diff
changeset
|
1617 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
|
1618 |
02defdb1b628
pull: only prefetch bookmarks when using bundle1
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25337
diff
changeset
|
1619 |
22936
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1620 @pulldiscovery('changegroup') |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
1621 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
|
1622 """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
|
1623 |
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1624 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
|
1625 at some point.""" |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1626 tmp = discovery.findcommonincoming(pullop.repo, |
20900
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1627 pullop.remote, |
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1628 heads=pullop.heads, |
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
1629 force=pullop.force) |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1630 common, fetch, rheads = tmp |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1631 nm = pullop.repo.unfiltered().changelog.nodemap |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1632 if fetch and rheads: |
34317
e45ec589f962
discovery: avoid dropping remote heads hidden locally
Boris Feld <boris.feld@octobus.net>
parents:
34221
diff
changeset
|
1633 # 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
|
1634 # |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1635 # 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
|
1636 # 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
|
1637 # 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
|
1638 # 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
|
1639 # |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1640 # 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
|
1641 # 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
|
1642 scommon = set(common) |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1643 for n in rheads: |
23975
3b7088a5c64c
discovery: properly exclude locally known but filtered heads
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23890
diff
changeset
|
1644 if n in nm: |
3b7088a5c64c
discovery: properly exclude locally known but filtered heads
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23890
diff
changeset
|
1645 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
|
1646 common.append(n) |
34317
e45ec589f962
discovery: avoid dropping remote heads hidden locally
Boris Feld <boris.feld@octobus.net>
parents:
34221
diff
changeset
|
1647 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
|
1648 fetch = [] |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1649 pullop.common = common |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1650 pullop.fetch = fetch |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
1651 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
|
1652 |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1653 def _pullbundle2(pullop): |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1654 """pull data using bundle2 |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1655 |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1656 For now, the only supported data are changegroup.""" |
35783
c97639ad6874
bundle2: specify what capabilities will be used for
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35765
diff
changeset
|
1657 kwargs = {'bundlecaps': caps20to10(pullop.repo, role='client')} |
26471
41dd7b2c7e15
exchange: add "streaming all changes" to bundle2 pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26465
diff
changeset
|
1658 |
35761
1908d360f977
pull: reorganize bundle2 argument bundling
Boris Feld <boris.feld@octobus.net>
parents:
35759
diff
changeset
|
1659 # make ui easier to access |
1908d360f977
pull: reorganize bundle2 argument bundling
Boris Feld <boris.feld@octobus.net>
parents:
35759
diff
changeset
|
1660 ui = pullop.repo.ui |
1908d360f977
pull: reorganize bundle2 argument bundling
Boris Feld <boris.feld@octobus.net>
parents:
35759
diff
changeset
|
1661 |
32257
205bd3936179
bundle2: don't check for whether we can do stream clones
Siddharth Agarwal <sid0@fb.com>
parents:
32222
diff
changeset
|
1662 # 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
|
1663 # 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
|
1664 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
|
1665 |
35761
1908d360f977
pull: reorganize bundle2 argument bundling
Boris Feld <boris.feld@octobus.net>
parents:
35759
diff
changeset
|
1666 # declare pull perimeters |
1908d360f977
pull: reorganize bundle2 argument bundling
Boris Feld <boris.feld@octobus.net>
parents:
35759
diff
changeset
|
1667 kwargs['common'] = pullop.common |
1908d360f977
pull: reorganize bundle2 argument bundling
Boris Feld <boris.feld@octobus.net>
parents:
35759
diff
changeset
|
1668 kwargs['heads'] = pullop.heads or pullop.rheads |
1908d360f977
pull: reorganize bundle2 argument bundling
Boris Feld <boris.feld@octobus.net>
parents:
35759
diff
changeset
|
1669 |
40492
440f5b65be57
exchange: pass includepats and excludepats as arguments to getbundle()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40352
diff
changeset
|
1670 # 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
|
1671 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
|
1672 if servernarrow and pullop.includepats: |
440f5b65be57
exchange: pass includepats and excludepats as arguments to getbundle()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40352
diff
changeset
|
1673 kwargs['includepats'] = pullop.includepats |
440f5b65be57
exchange: pass includepats and excludepats as arguments to getbundle()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40352
diff
changeset
|
1674 if servernarrow and pullop.excludepats: |
440f5b65be57
exchange: pass includepats and excludepats as arguments to getbundle()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40352
diff
changeset
|
1675 kwargs['excludepats'] = pullop.excludepats |
440f5b65be57
exchange: pass includepats and excludepats as arguments to getbundle()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40352
diff
changeset
|
1676 |
35763
7eedbd5d4880
streamclone: add support for bundle2 based stream clone
Boris Feld <boris.feld@octobus.net>
parents:
35762
diff
changeset
|
1677 if streaming: |
7eedbd5d4880
streamclone: add support for bundle2 based stream clone
Boris Feld <boris.feld@octobus.net>
parents:
35762
diff
changeset
|
1678 kwargs['cg'] = False |
7eedbd5d4880
streamclone: add support for bundle2 based stream clone
Boris Feld <boris.feld@octobus.net>
parents:
35762
diff
changeset
|
1679 kwargs['stream'] = True |
7eedbd5d4880
streamclone: add support for bundle2 based stream clone
Boris Feld <boris.feld@octobus.net>
parents:
35762
diff
changeset
|
1680 pullop.stepsdone.add('changegroup') |
35765
56c30b31afbe
streamclone: add support for cloning non append-only file
Boris Feld <boris.feld@octobus.net>
parents:
35763
diff
changeset
|
1681 pullop.stepsdone.add('phases') |
35763
7eedbd5d4880
streamclone: add support for bundle2 based stream clone
Boris Feld <boris.feld@octobus.net>
parents:
35762
diff
changeset
|
1682 |
7eedbd5d4880
streamclone: add support for bundle2 based stream clone
Boris Feld <boris.feld@octobus.net>
parents:
35762
diff
changeset
|
1683 else: |
35762
40df727b6f4f
pull: preindent some code
Boris Feld <boris.feld@octobus.net>
parents:
35761
diff
changeset
|
1684 # pulling changegroup |
40df727b6f4f
pull: preindent some code
Boris Feld <boris.feld@octobus.net>
parents:
35761
diff
changeset
|
1685 pullop.stepsdone.add('changegroup') |
21259
ab5040cd5749
bundle2: fix bundle2 pulling all revs on empty pulls
Durham Goode <durham@fb.com>
parents:
21258
diff
changeset
|
1686 |
35762
40df727b6f4f
pull: preindent some code
Boris Feld <boris.feld@octobus.net>
parents:
35761
diff
changeset
|
1687 kwargs['cg'] = pullop.fetch |
34322
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
1688 |
35765
56c30b31afbe
streamclone: add support for cloning non append-only file
Boris Feld <boris.feld@octobus.net>
parents:
35763
diff
changeset
|
1689 legacyphase = 'phases' in ui.configlist('devel', 'legacy.exchange') |
56c30b31afbe
streamclone: add support for cloning non append-only file
Boris Feld <boris.feld@octobus.net>
parents:
35763
diff
changeset
|
1690 hasbinaryphase = 'heads' in pullop.remotebundle2caps.get('phases', ()) |
56c30b31afbe
streamclone: add support for cloning non append-only file
Boris Feld <boris.feld@octobus.net>
parents:
35763
diff
changeset
|
1691 if (not legacyphase and hasbinaryphase): |
56c30b31afbe
streamclone: add support for cloning non append-only file
Boris Feld <boris.feld@octobus.net>
parents:
35763
diff
changeset
|
1692 kwargs['phases'] = True |
56c30b31afbe
streamclone: add support for cloning non append-only file
Boris Feld <boris.feld@octobus.net>
parents:
35763
diff
changeset
|
1693 pullop.stepsdone.add('phases') |
34322
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
1694 |
35765
56c30b31afbe
streamclone: add support for cloning non append-only file
Boris Feld <boris.feld@octobus.net>
parents:
35763
diff
changeset
|
1695 if 'listkeys' in pullop.remotebundle2caps: |
56c30b31afbe
streamclone: add support for cloning non append-only file
Boris Feld <boris.feld@octobus.net>
parents:
35763
diff
changeset
|
1696 if 'phases' not in pullop.stepsdone: |
56c30b31afbe
streamclone: add support for cloning non append-only file
Boris Feld <boris.feld@octobus.net>
parents:
35763
diff
changeset
|
1697 kwargs['listkeys'] = ['phases'] |
35761
1908d360f977
pull: reorganize bundle2 argument bundling
Boris Feld <boris.feld@octobus.net>
parents:
35759
diff
changeset
|
1698 |
35268
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1699 bookmarksrequested = False |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1700 legacybookmark = 'bookmarks' in ui.configlist('devel', 'legacy.exchange') |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1701 hasbinarybook = 'bookmarks' in pullop.remotebundle2caps |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1702 |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1703 if pullop.remotebookmarks is not None: |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1704 pullop.stepsdone.add('request-bookmarks') |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1705 |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1706 if ('request-bookmarks' not in pullop.stepsdone |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1707 and pullop.remotebookmarks is None |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1708 and not legacybookmark and hasbinarybook): |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1709 kwargs['bookmarks'] = True |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1710 bookmarksrequested = True |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1711 |
26464
9a7fc6d48898
exchange: expose bundle2 capabilities on pulloperation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26462
diff
changeset
|
1712 if 'listkeys' in pullop.remotebundle2caps: |
35268
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1713 if '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
|
1714 # 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
|
1715 # `hg incoming --bundle` to using this function. |
35268
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1716 pullop.stepsdone.add('request-bookmarks') |
34322
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
1717 kwargs.setdefault('listkeys', []).append('bookmarks') |
26690
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1718 |
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1719 # 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
|
1720 # 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
|
1721 # 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
|
1722 # 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
|
1723 # differently from those that don't. |
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1724 if (pullop.remote.capable('clonebundles') |
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1725 and pullop.heads is None and list(pullop.common) == [nullid]): |
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1726 kwargs['cbattempted'] = pullop.clonebundleattempted |
704818fb170d
exchange: advertise if a clone bundle was attempted
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26689
diff
changeset
|
1727 |
26471
41dd7b2c7e15
exchange: add "streaming all changes" to bundle2 pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26465
diff
changeset
|
1728 if streaming: |
41dd7b2c7e15
exchange: add "streaming all changes" to bundle2 pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26465
diff
changeset
|
1729 pullop.repo.ui.status(_('streaming all changes\n')) |
41dd7b2c7e15
exchange: add "streaming all changes" to bundle2 pulling
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26465
diff
changeset
|
1730 elif not pullop.fetch: |
21258
71931b789424
exchange: fix bad indentation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21257
diff
changeset
|
1731 pullop.repo.ui.status(_("no changes found\n")) |
71931b789424
exchange: fix bad indentation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21257
diff
changeset
|
1732 pullop.cgresult = 0 |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1733 else: |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1734 if pullop.heads is None and list(pullop.common) == [nullid]: |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1735 pullop.repo.ui.status(_("requesting all changes\n")) |
22953
b1d694d3975e
obsolete: add exchange option
Durham Goode <durham@fb.com>
parents:
22937
diff
changeset
|
1736 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
|
1737 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
|
1738 if obsolete.commonversion(remoteversions) is not None: |
a89add6c6b2f
bundle2: pull obsmarkers relevant to the pulled set through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22353
diff
changeset
|
1739 kwargs['obsmarkers'] = True |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1740 pullop.stepsdone.add('obsmarkers') |
21159
024f38f6d5f6
bundle2: allow extensions to extend the getbundle request
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21158
diff
changeset
|
1741 _pullbundle2extraprepare(pullop, kwargs) |
37648
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1742 |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1743 with pullop.remote.commandexecutor() as e: |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1744 args = dict(kwargs) |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1745 args['source'] = 'pull' |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1746 bundle = e.callcommand('getbundle', args).result() |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1747 |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1748 try: |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1749 op = bundle2.bundleoperation(pullop.repo, pullop.gettransaction, |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1750 source='pull') |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1751 op.modes['bookmarks'] = 'records' |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1752 bundle2.processbundle(pullop.repo, bundle, op=op) |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1753 except bundle2.AbortFromPart as exc: |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1754 pullop.repo.ui.status(_('remote: abort: %s\n') % exc) |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1755 raise error.Abort(_('pull failed on remote'), hint=exc.hint) |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1756 except error.BundleValueError as exc: |
8f3c6fb55369
exchange: use command executor for getbundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37647
diff
changeset
|
1757 raise error.Abort(_('missing support for %s') % exc) |
21259
ab5040cd5749
bundle2: fix bundle2 pulling all revs on empty pulls
Durham Goode <durham@fb.com>
parents:
21258
diff
changeset
|
1758 |
ab5040cd5749
bundle2: fix bundle2 pulling all revs on empty pulls
Durham Goode <durham@fb.com>
parents:
21258
diff
changeset
|
1759 if pullop.fetch: |
33037
d765ad56081f
bundle: make combinechangegroupresults() take a bundleoperation
Martin von Zweigbergk <martinvonz@google.com>
parents:
33036
diff
changeset
|
1760 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
|
1761 |
21658
0696ca0a685b
pull: when remote supports it, pull phase data alongside changesets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21657
diff
changeset
|
1762 # processing phases change |
0696ca0a685b
pull: when remote supports it, pull phase data alongside changesets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21657
diff
changeset
|
1763 for namespace, value in op.records['listkeys']: |
0696ca0a685b
pull: when remote supports it, pull phase data alongside changesets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21657
diff
changeset
|
1764 if namespace == 'phases': |
0696ca0a685b
pull: when remote supports it, pull phase data alongside changesets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21657
diff
changeset
|
1765 _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
|
1766 |
22656
c9276945eba3
pull: retrieve bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22655
diff
changeset
|
1767 # processing bookmark update |
35268
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1768 if bookmarksrequested: |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1769 books = {} |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1770 for record in op.records['bookmarks']: |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1771 books[record['bookmark']] = record["node"] |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1772 pullop.remotebookmarks = books |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1773 else: |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1774 for namespace, value in op.records['listkeys']: |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1775 if namespace == 'bookmarks': |
44b8b5ad30eb
pull: retrieve bookmarks through the binary part when possible
Boris Feld <boris.feld@octobus.net>
parents:
35267
diff
changeset
|
1776 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
|
1777 |
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
|
1778 # 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
|
1779 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
|
1780 _pullbookmarks(pullop) |
22656
c9276945eba3
pull: retrieve bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22655
diff
changeset
|
1781 |
21159
024f38f6d5f6
bundle2: allow extensions to extend the getbundle request
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21158
diff
changeset
|
1782 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
|
1783 """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
|
1784 |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1785 def _pullchangeset(pullop): |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1786 """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
|
1787 # 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
|
1788 # 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
|
1789 # rollback call |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1790 if 'changegroup' in pullop.stepsdone: |
22653
d94f5bec9c8e
pull: perform the todostep inside functions handling old way of pulling
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22651
diff
changeset
|
1791 return |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1792 pullop.stepsdone.add('changegroup') |
20899
d62319f91cb7
pull: move the cgresult logic in _pullchangeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20898
diff
changeset
|
1793 if not pullop.fetch: |
23217
2f12ac53b528
exchange: fix indentation in _pullchangeset
Mike Edgar <adgar@google.com>
parents:
23208
diff
changeset
|
1794 pullop.repo.ui.status(_("no changes found\n")) |
2f12ac53b528
exchange: fix indentation in _pullchangeset
Mike Edgar <adgar@google.com>
parents:
23208
diff
changeset
|
1795 pullop.cgresult = 0 |
2f12ac53b528
exchange: fix indentation in _pullchangeset
Mike Edgar <adgar@google.com>
parents:
23208
diff
changeset
|
1796 return |
32930
af31d531dda0
changegroup: let callers pass in transaction to apply() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
32927
diff
changeset
|
1797 tr = pullop.gettransaction() |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1798 if pullop.heads is None and list(pullop.common) == [nullid]: |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1799 pullop.repo.ui.status(_("requesting all changes\n")) |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1800 elif pullop.heads is None and pullop.remote.capable('changegroupsubset'): |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1801 # 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
|
1802 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
|
1803 |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1804 if pullop.remote.capable('getbundle'): |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1805 # TODO: get bundlecaps from remote |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1806 cg = pullop.remote.getbundle('pull', common=pullop.common, |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1807 heads=pullop.heads or pullop.rheads) |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1808 elif pullop.heads is None: |
37635
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37498
diff
changeset
|
1809 with pullop.remote.commandexecutor() as e: |
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37498
diff
changeset
|
1810 cg = e.callcommand('changegroup', { |
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37498
diff
changeset
|
1811 'nodes': pullop.fetch, |
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37498
diff
changeset
|
1812 'source': 'pull', |
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37498
diff
changeset
|
1813 }).result() |
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37498
diff
changeset
|
1814 |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1815 elif not pullop.remote.capable('changegroupsubset'): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26566
diff
changeset
|
1816 raise error.Abort(_("partial pull cannot be done because " |
21554
7bcf4adadd2d
exchange: fix indentation level
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21259
diff
changeset
|
1817 "other repository doesn't support " |
7bcf4adadd2d
exchange: fix indentation level
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21259
diff
changeset
|
1818 "changegroupsubset.")) |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1819 else: |
37635
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37498
diff
changeset
|
1820 with pullop.remote.commandexecutor() as e: |
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37498
diff
changeset
|
1821 cg = e.callcommand('changegroupsubset', { |
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37498
diff
changeset
|
1822 'bases': pullop.fetch, |
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37498
diff
changeset
|
1823 'heads': pullop.heads, |
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37498
diff
changeset
|
1824 'source': 'pull', |
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37498
diff
changeset
|
1825 }).result() |
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37498
diff
changeset
|
1826 |
33043
18c2489ac96d
bundle: make applybundle() delegate v1 bundles to applybundle1()
Martin von Zweigbergk <martinvonz@google.com>
parents:
33040
diff
changeset
|
1827 bundleop = bundle2.applybundle(pullop.repo, cg, tr, 'pull', |
18c2489ac96d
bundle: make applybundle() delegate v1 bundles to applybundle1()
Martin von Zweigbergk <martinvonz@google.com>
parents:
33040
diff
changeset
|
1828 pullop.remote.url()) |
33040
2baef42a2881
bundle: make applybundle1() return a bundleoperation
Martin von Zweigbergk <martinvonz@google.com>
parents:
33039
diff
changeset
|
1829 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
|
1830 |
20486
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1831 def _pullphase(pullop): |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1832 # Get remote phases data from remote |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1833 if 'phases' in pullop.stepsdone: |
22653
d94f5bec9c8e
pull: perform the todostep inside functions handling old way of pulling
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22651
diff
changeset
|
1834 return |
37757
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
1835 remotephases = listkeys(pullop.remote, 'phases') |
21654
ddf9a00c1239
pull: split remote phases retrieval from actual application
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21645
diff
changeset
|
1836 _pullapplyphases(pullop, remotephases) |
ddf9a00c1239
pull: split remote phases retrieval from actual application
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21645
diff
changeset
|
1837 |
ddf9a00c1239
pull: split remote phases retrieval from actual application
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21645
diff
changeset
|
1838 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
|
1839 """apply phase movement from observed remote state""" |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1840 if 'phases' in pullop.stepsdone: |
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1841 return |
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1842 pullop.stepsdone.add('phases') |
20486
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1843 publishing = bool(remotephases.get('publishing', False)) |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1844 if remotephases and not publishing: |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
30187
diff
changeset
|
1845 # remote is new and non-publishing |
20486
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1846 pheads, _dr = phases.analyzeremotephases(pullop.repo, |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1847 pullop.pulledsubset, |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1848 remotephases) |
22068
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1849 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
|
1850 else: |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1851 # 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
|
1852 # 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
|
1853 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
|
1854 dheads = [] |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1855 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
|
1856 phase = unfi._phasecache.phase |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1857 rev = unfi.changelog.nodemap.get |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1858 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
|
1859 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
|
1860 |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1861 # 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
|
1862 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
|
1863 if pheads: |
22069
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22068
diff
changeset
|
1864 tr = pullop.gettransaction() |
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22068
diff
changeset
|
1865 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
|
1866 |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1867 # 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
|
1868 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
|
1869 if dheads: |
22069
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22068
diff
changeset
|
1870 tr = pullop.gettransaction() |
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22068
diff
changeset
|
1871 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
|
1872 |
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1873 def _pullbookmarks(pullop): |
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1874 """process the remote bookmark information to update the local one""" |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1875 if 'bookmarks' in pullop.stepsdone: |
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1876 return |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1877 pullop.stepsdone.add('bookmarks') |
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1878 repo = pullop.repo |
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1879 remotebookmarks = pullop.remotebookmarks |
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1880 bookmod.updatefromremote(repo.ui, repo, remotebookmarks, |
22658
a8f0d8e4c80a
pull: gather explicit bookmark pulls with bookmark updates
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22656
diff
changeset
|
1881 pullop.remote.url(), |
22666
0f8120c1ecf5
pull: perform bookmark updates in the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22658
diff
changeset
|
1882 pullop.gettransaction, |
22658
a8f0d8e4c80a
pull: gather explicit bookmark pulls with bookmark updates
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22656
diff
changeset
|
1883 explicit=pullop.explicitbookmarks) |
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1884 |
20478
80628d4069be
push: feed pulloperation object to _pullobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20477
diff
changeset
|
1885 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
|
1886 """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
|
1887 |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1888 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
|
1889 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
|
1890 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
|
1891 |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1892 Exists mostly to allow overriding for experimentation purpose""" |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1893 if 'obsmarkers' in pullop.stepsdone: |
22653
d94f5bec9c8e
pull: perform the todostep inside functions handling old way of pulling
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22651
diff
changeset
|
1894 return |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1895 pullop.stepsdone.add('obsmarkers') |
20476
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1896 tr = None |
22953
b1d694d3975e
obsolete: add exchange option
Durham Goode <durham@fb.com>
parents:
22937
diff
changeset
|
1897 if obsolete.isenabled(pullop.repo, obsolete.exchangeopt): |
20478
80628d4069be
push: feed pulloperation object to _pullobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20477
diff
changeset
|
1898 pullop.repo.ui.debug('fetching remote obsolete markers\n') |
37757
2a8ad00b8aed
exchange: use command executor interface for calling listkeys
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37663
diff
changeset
|
1899 remoteobs = listkeys(pullop.remote, 'obsolete') |
20476
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1900 if 'dump0' in remoteobs: |
20478
80628d4069be
push: feed pulloperation object to _pullobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20477
diff
changeset
|
1901 tr = pullop.gettransaction() |
27558
b5b54825de6b
pull: make a single call to obsstore.add (issue5006)
Matt Mackall <mpm@selenic.com>
parents:
27523
diff
changeset
|
1902 markers = [] |
20476
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1903 for key in sorted(remoteobs, reverse=True): |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1904 if key.startswith('dump'): |
32201
4462a981e8df
base85: proxy through util module
Yuya Nishihara <yuya@tcha.org>
parents:
32166
diff
changeset
|
1905 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
|
1906 version, newmarks = obsolete._readmarkers(data) |
b5b54825de6b
pull: make a single call to obsstore.add (issue5006)
Matt Mackall <mpm@selenic.com>
parents:
27523
diff
changeset
|
1907 markers += newmarks |
b5b54825de6b
pull: make a single call to obsstore.add (issue5006)
Matt Mackall <mpm@selenic.com>
parents:
27523
diff
changeset
|
1908 if markers: |
b5b54825de6b
pull: make a single call to obsstore.add (issue5006)
Matt Mackall <mpm@selenic.com>
parents:
27523
diff
changeset
|
1909 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
|
1910 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
|
1911 return tr |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1912 |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1913 def applynarrowacl(repo, kwargs): |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1914 """Apply narrow fetch access control. |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1915 |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1916 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
|
1917 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
|
1918 """ |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1919 ui = repo.ui |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1920 # TODO this assumes existence of HTTP and is a layering violation. |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1921 username = ui.shortuser(ui.environ.get('REMOTE_USER') or ui.username()) |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1922 user_includes = ui.configlist( |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1923 _NARROWACL_SECTION, username + '.includes', |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1924 ui.configlist(_NARROWACL_SECTION, 'default.includes')) |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1925 user_excludes = ui.configlist( |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1926 _NARROWACL_SECTION, username + '.excludes', |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1927 ui.configlist(_NARROWACL_SECTION, 'default.excludes')) |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1928 if not user_includes: |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1929 raise error.Abort(_("{} configuration for user {} is empty") |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1930 .format(_NARROWACL_SECTION, username)) |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1931 |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1932 user_includes = [ |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1933 'path:.' if p == '*' else 'path:' + p for p in user_includes] |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1934 user_excludes = [ |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1935 'path:.' if p == '*' else 'path:' + p for p in user_excludes] |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1936 |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1937 req_includes = set(kwargs.get(r'includepats', [])) |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1938 req_excludes = set(kwargs.get(r'excludepats', [])) |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1939 |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1940 req_includes, req_excludes, invalid_includes = narrowspec.restrictpatterns( |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1941 req_includes, req_excludes, user_includes, user_excludes) |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1942 |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1943 if invalid_includes: |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1944 raise error.Abort( |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1945 _("The following includes are not accessible for {}: {}") |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1946 .format(username, invalid_includes)) |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1947 |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1948 new_args = {} |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1949 new_args.update(kwargs) |
38807
98df52d5042c
exchange: make narrow ACL presence imply narrow=True
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38792
diff
changeset
|
1950 new_args[r'narrow'] = True |
40337
cb516a854bc7
narrow: only send the narrowspecs back if ACL in play
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40331
diff
changeset
|
1951 new_args[r'narrow_acl'] = True |
38807
98df52d5042c
exchange: make narrow ACL presence imply narrow=True
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38792
diff
changeset
|
1952 new_args[r'includepats'] = req_includes |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1953 if req_excludes: |
38807
98df52d5042c
exchange: make narrow ACL presence imply narrow=True
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38792
diff
changeset
|
1954 new_args[r'excludepats'] = req_excludes |
98df52d5042c
exchange: make narrow ACL presence imply narrow=True
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38792
diff
changeset
|
1955 |
38790
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1956 return new_args |
3e7387337a3c
exchange: move narrow acl functionality into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38789
diff
changeset
|
1957 |
38791
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1958 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
|
1959 """Compute the shape of a narrowed DAG. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1960 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1961 Args: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1962 repo: The repository we're transferring. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1963 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
|
1964 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
|
1965 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
|
1966 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
|
1967 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
|
1968 most depth changesets away from one of heads. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1969 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1970 Returns: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1971 A tuple of (visitnodes, relevant_nodes, ellipsisroots) where: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1972 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1973 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
|
1974 need to be sent to the client. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1975 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
|
1976 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
|
1977 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
|
1978 narrowchangegroup to produce ellipsis nodes with the |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1979 correct parents. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1980 """ |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1981 cl = repo.changelog |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1982 mfl = repo.manifestlog |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1983 |
39158
b0c73866c9fb
exchange: don't use dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
1984 clrev = cl.rev |
b0c73866c9fb
exchange: don't use dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
1985 |
b0c73866c9fb
exchange: don't use dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
1986 commonrevs = {clrev(n) for n in common} | {nullrev} |
b0c73866c9fb
exchange: don't use dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
1987 headsrevs = {clrev(n) for n in heads} |
b0c73866c9fb
exchange: don't use dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
1988 |
38791
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1989 if depth: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1990 revdepth = {h: 0 for h in headsrevs} |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1991 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1992 ellipsisheads = collections.defaultdict(set) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1993 ellipsisroots = collections.defaultdict(set) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1994 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1995 def addroot(head, curchange): |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1996 """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
|
1997 ellipsisroots[head].add(curchange) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
1998 # 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
|
1999 # 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
|
2000 # 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
|
2001 # root of the head. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2002 while len(ellipsisroots[head]) > 2: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2003 child, roots = splithead(head) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2004 splitroots(head, child, roots) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2005 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
|
2006 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2007 def splitroots(head, child, roots): |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2008 ellipsisroots[head].difference_update(roots) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2009 ellipsisroots[head].add(child) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2010 ellipsisroots[child].update(roots) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2011 ellipsisroots[child].discard(child) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2012 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2013 def splithead(head): |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2014 r1, r2, r3 = sorted(ellipsisroots[head]) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2015 for nr1, nr2 in ((r2, r3), (r1, r3), (r1, r2)): |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2016 mid = repo.revs('sort(merge() & %d::%d & %d::%d, -rev)', |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2017 nr1, head, nr2, head) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2018 for j in mid: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2019 if j == nr2: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2020 return nr2, (nr1, nr2) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2021 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
|
2022 return j, (nr1, nr2) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2023 raise error.Abort(_('Failed to split up ellipsis node! head: %d, ' |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2024 'roots: %d %d %d') % (head, r1, r2, r3)) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2025 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2026 missing = list(cl.findmissingrevs(common=commonrevs, heads=headsrevs)) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2027 visit = reversed(missing) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2028 relevant_nodes = set() |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2029 visitnodes = [cl.node(m) for m in missing] |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2030 required = set(headsrevs) | known |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2031 for rev in visit: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2032 clrev = cl.changelogrevision(rev) |
39158
b0c73866c9fb
exchange: don't use dagutil
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
2033 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
|
2034 if depth is not None: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2035 curdepth = revdepth[rev] |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2036 for p in ps: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2037 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
|
2038 needed = False |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2039 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
|
2040 if shallow_enough: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2041 curmf = mfl[clrev.manifest].read() |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2042 if ps: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2043 # 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
|
2044 # 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
|
2045 # we trust it for the non-merge case? |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2046 p1mf = mfl[cl.changelogrevision(ps[0]).manifest].read() |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2047 needed = bool(curmf.diff(p1mf, match)) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2048 if not needed and len(ps) > 1: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2049 # 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
|
2050 # 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
|
2051 # 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
|
2052 # 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
|
2053 p2mf = mfl[cl.changelogrevision(ps[1]).manifest].read() |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2054 needed = bool(curmf.diff(p2mf, match)) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2055 else: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2056 # 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
|
2057 # files in the node match the narrowspec. |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2058 needed = any(curmf.walk(match)) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2059 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2060 if needed: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2061 for head in ellipsisheads[rev]: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2062 addroot(head, rev) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2063 for p in ps: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2064 required.add(p) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2065 relevant_nodes.add(cl.node(rev)) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2066 else: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2067 if not ps: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2068 ps = [nullrev] |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2069 if rev in required: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2070 for head in ellipsisheads[rev]: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2071 addroot(head, rev) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2072 for p in ps: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2073 ellipsisheads[p].add(rev) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2074 else: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2075 for p in ps: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2076 ellipsisheads[p] |= ellipsisheads[rev] |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2077 |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2078 # 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
|
2079 for c in commonrevs: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2080 for head in ellipsisheads[c]: |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2081 addroot(head, c) |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2082 return visitnodes, relevant_nodes, ellipsisroots |
7e66e7999bdd
exchange: move _computeellipsis() from narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38790
diff
changeset
|
2083 |
35783
c97639ad6874
bundle2: specify what capabilities will be used for
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35765
diff
changeset
|
2084 def caps20to10(repo, role): |
21645
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
2085 """return a set with appropriate options to use bundle20 during getbundle""" |
32291
bd872f64a8ba
cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents:
32287
diff
changeset
|
2086 caps = {'HG20'} |
35783
c97639ad6874
bundle2: specify what capabilities will be used for
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35765
diff
changeset
|
2087 capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo, role=role)) |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
2088 caps.add('bundle2=' + urlreq.quote(capsblob)) |
21645
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
2089 return caps |
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
2090 |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2091 # 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
|
2092 getbundle2partsorder = [] |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2093 |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2094 # Mapping between step name and function |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2095 # |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2096 # 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
|
2097 getbundle2partsmapping = {} |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2098 |
24732
8f70b529cb0c
bundle2: add an 'idx' argument to the 'getbundle2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24731
diff
changeset
|
2099 def getbundle2partsgenerator(stepname, idx=None): |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2100 """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
|
2101 |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2102 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
|
2103 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
|
2104 (this may matter). |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2105 |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2106 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
|
2107 from an extension, attack the getbundle2partsmapping dictionary directly.""" |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2108 def dec(func): |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2109 assert stepname not in getbundle2partsmapping |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2110 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
|
2111 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
|
2112 getbundle2partsorder.append(stepname) |
8f70b529cb0c
bundle2: add an 'idx' argument to the 'getbundle2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24731
diff
changeset
|
2113 else: |
8f70b529cb0c
bundle2: add an 'idx' argument to the 'getbundle2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24731
diff
changeset
|
2114 getbundle2partsorder.insert(idx, stepname) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2115 return func |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2116 return dec |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2117 |
27244
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
2118 def bundle2requested(bundlecaps): |
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
2119 if bundlecaps is not None: |
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
2120 return any(cap.startswith('HG2') for cap in bundlecaps) |
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
2121 return False |
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
2122 |
30187
3e86261bf110
exchange: refactor APIs to obtain bundle data (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30068
diff
changeset
|
2123 def getbundlechunks(repo, source, heads=None, common=None, bundlecaps=None, |
3e86261bf110
exchange: refactor APIs to obtain bundle data (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30068
diff
changeset
|
2124 **kwargs): |
3e86261bf110
exchange: refactor APIs to obtain bundle data (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30068
diff
changeset
|
2125 """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
|
2126 |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
2127 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
|
2128 passed. |
20954
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
2129 |
35785
ba15580e53d5
exchange: return bundle info from getbundlechunks() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35784
diff
changeset
|
2130 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
|
2131 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
|
2132 """ |
33016
4e6dc34b5d7a
py3: convert kwargs keys' back to bytes using pycompat.byteskwargs()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32991
diff
changeset
|
2133 kwargs = pycompat.byteskwargs(kwargs) |
35785
ba15580e53d5
exchange: return bundle info from getbundlechunks() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35784
diff
changeset
|
2134 info = {} |
27244
709977a4fc9d
exchange: standalone function to determine if bundle2 is requested
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26935
diff
changeset
|
2135 usebundle2 = bundle2requested(bundlecaps) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2136 # 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
|
2137 if not usebundle2: |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2138 if bundlecaps and not kwargs.get('cg', True): |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2139 raise ValueError(_('request for bundle10 must include changegroup')) |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2140 |
21656
36200dc6b3bd
getbundle: raise error if extra arguments are provided for bundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21654
diff
changeset
|
2141 if kwargs: |
36200dc6b3bd
getbundle: raise error if extra arguments are provided for bundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21654
diff
changeset
|
2142 raise ValueError(_('unsupported getbundle arguments: %s') |
36200dc6b3bd
getbundle: raise error if extra arguments are provided for bundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21654
diff
changeset
|
2143 % ', '.join(sorted(kwargs.keys()))) |
29808
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
2144 outgoing = _computeoutgoing(repo, heads, common) |
35785
ba15580e53d5
exchange: return bundle info from getbundlechunks() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35784
diff
changeset
|
2145 info['bundleversion'] = 1 |
ba15580e53d5
exchange: return bundle info from getbundlechunks() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35784
diff
changeset
|
2146 return info, changegroup.makestream(repo, outgoing, '01', source, |
ba15580e53d5
exchange: return bundle info from getbundlechunks() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35784
diff
changeset
|
2147 bundlecaps=bundlecaps) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2148 |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2149 # bundle20 case |
35785
ba15580e53d5
exchange: return bundle info from getbundlechunks() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35784
diff
changeset
|
2150 info['bundleversion'] = 2 |
21143
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
2151 b2caps = {} |
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
2152 for bcaps in bundlecaps: |
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
2153 if bcaps.startswith('bundle2='): |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
2154 blob = urlreq.unquote(bcaps[len('bundle2='):]) |
21143
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
2155 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
|
2156 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
|
2157 |
23218
0e78ea8e592a
exchange: prepare kwargs for bundle2 part generation exactly once
Mike Edgar <adgar@google.com>
parents:
23217
diff
changeset
|
2158 kwargs['heads'] = heads |
0e78ea8e592a
exchange: prepare kwargs for bundle2 part generation exactly once
Mike Edgar <adgar@google.com>
parents:
23217
diff
changeset
|
2159 kwargs['common'] = common |
0e78ea8e592a
exchange: prepare kwargs for bundle2 part generation exactly once
Mike Edgar <adgar@google.com>
parents:
23217
diff
changeset
|
2160 |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2161 for name in getbundle2partsorder: |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2162 func = getbundle2partsmapping[name] |
22543
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
2163 func(bundler, repo, source, bundlecaps=bundlecaps, b2caps=b2caps, |
33017
c31d45623304
py3: convert kwargs' keys' to str using pycompat.strkwargs()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
33016
diff
changeset
|
2164 **pycompat.strkwargs(kwargs)) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2165 |
35787
a84dbc87dae9
exchange: send bundle2 stream clones uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35785
diff
changeset
|
2166 info['prefercompressed'] = bundler.prefercompressed |
a84dbc87dae9
exchange: send bundle2 stream clones uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35785
diff
changeset
|
2167 |
35785
ba15580e53d5
exchange: return bundle info from getbundlechunks() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35784
diff
changeset
|
2168 return info, bundler.getchunks() |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2169 |
35788
b116a66bcc44
bundle2: move version of stream clone into part name
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35787
diff
changeset
|
2170 @getbundle2partsgenerator('stream2') |
37167
6f467adf9f05
bundle: add the possibility to bundle a stream v2 part
Boris Feld <boris.feld@octobus.net>
parents:
37165
diff
changeset
|
2171 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
|
2172 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
|
2173 |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2174 @getbundle2partsgenerator('changegroup') |
22543
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
2175 def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None, |
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
2176 b2caps=None, heads=None, common=None, **kwargs): |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2177 """add a changegroup part to the requested bundle""" |
38792
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2178 if not kwargs.get(r'cg', True): |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2179 return |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2180 |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2181 version = '01' |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2182 cgversions = b2caps.get('changegroup') |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2183 if cgversions: # 3.1 and 3.2 ship with an empty value |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2184 cgversions = [v for v in cgversions |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2185 if v in changegroup.supportedoutgoingversions(repo)] |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2186 if not cgversions: |
41704
3b0ba4575c8c
exchange: raise error.Abort instead of ValueError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41365
diff
changeset
|
2187 raise error.Abort(_('no common changegroup version')) |
38792
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2188 version = max(cgversions) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2189 |
38792
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2190 outgoing = _computeoutgoing(repo, heads, common) |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2191 if not outgoing.missing: |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2192 return |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2193 |
38808
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
2194 if kwargs.get(r'narrow', False): |
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
2195 include = sorted(filter(bool, kwargs.get(r'includepats', []))) |
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
2196 exclude = sorted(filter(bool, kwargs.get(r'excludepats', []))) |
40344
2c5835b4246b
narrow: when widening, don't include manifests the client already has
Martin von Zweigbergk <martinvonz@google.com>
parents:
40337
diff
changeset
|
2197 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
|
2198 else: |
40344
2c5835b4246b
narrow: when widening, don't include manifests the client already has
Martin von Zweigbergk <martinvonz@google.com>
parents:
40337
diff
changeset
|
2199 matcher = None |
38808
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
2200 |
38792
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2201 cgstream = changegroup.makestream(repo, outgoing, version, source, |
40344
2c5835b4246b
narrow: when widening, don't include manifests the client already has
Martin von Zweigbergk <martinvonz@google.com>
parents:
40337
diff
changeset
|
2202 bundlecaps=bundlecaps, matcher=matcher) |
38792
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2203 |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2204 part = bundler.newpart('changegroup', data=cgstream) |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2205 if cgversions: |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2206 part.addparam('version', version) |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2207 |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2208 part.addparam('nbchanges', '%d' % len(outgoing.missing), |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2209 mandatory=False) |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2210 |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2211 if 'treemanifest' in repo.requirements: |
afb442f58cbf
exchange: refactor control flow of _getbundlechangegrouppart()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38791
diff
changeset
|
2212 part.addparam('treemanifest', '1') |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2213 |
40352
dd816e5391f6
py3: add a r'' prefix in mercurial/exchange.py
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40344
diff
changeset
|
2214 if (kwargs.get(r'narrow', False) and kwargs.get(r'narrow_acl', False) |
40337
cb516a854bc7
narrow: only send the narrowspecs back if ACL in play
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40331
diff
changeset
|
2215 and (include or exclude)): |
38808
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
2216 narrowspecpart = bundler.newpart('narrow:spec') |
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
2217 if include: |
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
2218 narrowspecpart.addparam( |
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
2219 'include', '\n'.join(include), mandatory=True) |
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
2220 if exclude: |
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
2221 narrowspecpart.addparam( |
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
2222 'exclude', '\n'.join(exclude), mandatory=True) |
d99083996398
exchange: move simple narrow changegroup generation from extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38807
diff
changeset
|
2223 |
35267
cb4dcd7fabe7
getbundle: add support for 'bookmarks' boolean argument
Boris Feld <boris.feld@octobus.net>
parents:
35264
diff
changeset
|
2224 @getbundle2partsgenerator('bookmarks') |
cb4dcd7fabe7
getbundle: add support for 'bookmarks' boolean argument
Boris Feld <boris.feld@octobus.net>
parents:
35264
diff
changeset
|
2225 def _getbundlebookmarkpart(bundler, repo, source, bundlecaps=None, |
cb4dcd7fabe7
getbundle: add support for 'bookmarks' boolean argument
Boris Feld <boris.feld@octobus.net>
parents:
35264
diff
changeset
|
2226 b2caps=None, **kwargs): |
cb4dcd7fabe7
getbundle: add support for 'bookmarks' boolean argument
Boris Feld <boris.feld@octobus.net>
parents:
35264
diff
changeset
|
2227 """add a bookmark part to the requested bundle""" |
35355
a119e97b6caf
py3: handle keyword arguments correctly in exchange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35347
diff
changeset
|
2228 if not kwargs.get(r'bookmarks', False): |
35267
cb4dcd7fabe7
getbundle: add support for 'bookmarks' boolean argument
Boris Feld <boris.feld@octobus.net>
parents:
35264
diff
changeset
|
2229 return |
cb4dcd7fabe7
getbundle: add support for 'bookmarks' boolean argument
Boris Feld <boris.feld@octobus.net>
parents:
35264
diff
changeset
|
2230 if 'bookmarks' not in b2caps: |
41704
3b0ba4575c8c
exchange: raise error.Abort instead of ValueError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41365
diff
changeset
|
2231 raise error.Abort(_('no common bookmarks exchange method')) |
35267
cb4dcd7fabe7
getbundle: add support for 'bookmarks' boolean argument
Boris Feld <boris.feld@octobus.net>
parents:
35264
diff
changeset
|
2232 books = bookmod.listbinbookmarks(repo) |
cb4dcd7fabe7
getbundle: add support for 'bookmarks' boolean argument
Boris Feld <boris.feld@octobus.net>
parents:
35264
diff
changeset
|
2233 data = bookmod.binaryencode(books) |
cb4dcd7fabe7
getbundle: add support for 'bookmarks' boolean argument
Boris Feld <boris.feld@octobus.net>
parents:
35264
diff
changeset
|
2234 if data: |
cb4dcd7fabe7
getbundle: add support for 'bookmarks' boolean argument
Boris Feld <boris.feld@octobus.net>
parents:
35264
diff
changeset
|
2235 bundler.newpart('bookmarks', data=data) |
cb4dcd7fabe7
getbundle: add support for 'bookmarks' boolean argument
Boris Feld <boris.feld@octobus.net>
parents:
35264
diff
changeset
|
2236 |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2237 @getbundle2partsgenerator('listkeys') |
22543
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
2238 def _getbundlelistkeysparts(bundler, repo, source, bundlecaps=None, |
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
2239 b2caps=None, **kwargs): |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2240 """add parts containing listkeys namespaces to the requested bundle""" |
35355
a119e97b6caf
py3: handle keyword arguments correctly in exchange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35347
diff
changeset
|
2241 listkeys = kwargs.get(r'listkeys', ()) |
21657
0ff44e06275d
getbundle: support of listkeys argument when bundle2 is used
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21656
diff
changeset
|
2242 for namespace in listkeys: |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
2243 part = bundler.newpart('listkeys') |
21657
0ff44e06275d
getbundle: support of listkeys argument when bundle2 is used
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21656
diff
changeset
|
2244 part.addparam('namespace', namespace) |
0ff44e06275d
getbundle: support of listkeys argument when bundle2 is used
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21656
diff
changeset
|
2245 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
|
2246 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
|
2247 |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
2248 @getbundle2partsgenerator('obsmarkers') |
22543
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
2249 def _getbundleobsmarkerpart(bundler, repo, source, bundlecaps=None, |
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
2250 b2caps=None, heads=None, **kwargs): |
22541
4e1a80c022a4
bundle2: pass b2caps down to functions adding bundle2 parts for getbundle
Mike Hommey <mh@glandium.org>
parents:
22390
diff
changeset
|
2251 """add an obsolescence markers part to the requested bundle""" |
35355
a119e97b6caf
py3: handle keyword arguments correctly in exchange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35347
diff
changeset
|
2252 if kwargs.get(r'obsmarkers', False): |
22353
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
2253 if heads is None: |
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
2254 heads = repo.heads() |
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
2255 subset = [c.node() for c in repo.set('::%ln', heads)] |
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
2256 markers = repo.obsstore.relevantmarkers(subset) |
25118
e632a2429982
obsolete: sort obsmarkers during exchange
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24878
diff
changeset
|
2257 markers = sorted(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
|
2258 bundle2.buildobsmarkerspart(bundler, markers) |
22353
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
2259 |
34322
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2260 @getbundle2partsgenerator('phases') |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2261 def _getbundlephasespart(bundler, repo, source, bundlecaps=None, |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2262 b2caps=None, heads=None, **kwargs): |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2263 """add phase heads part to the requested bundle""" |
35355
a119e97b6caf
py3: handle keyword arguments correctly in exchange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35347
diff
changeset
|
2264 if kwargs.get(r'phases', False): |
34322
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2265 if not 'heads' in b2caps.get('phases'): |
41704
3b0ba4575c8c
exchange: raise error.Abort instead of ValueError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41365
diff
changeset
|
2266 raise error.Abort(_('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
|
2267 if heads is None: |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2268 heads = repo.heads() |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2269 |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2270 headsbyphase = collections.defaultdict(set) |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2271 if repo.publishing(): |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2272 headsbyphase[phases.public] = heads |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2273 else: |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2274 # 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
|
2275 |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2276 phase = repo._phasecache.phase |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2277 node = repo.changelog.node |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2278 rev = repo.changelog.rev |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2279 for h in heads: |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2280 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
|
2281 seenphases = list(headsbyphase.keys()) |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2282 |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2283 # 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
|
2284 if seenphases: |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2285 assert max(seenphases) <= phases.draft |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2286 |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2287 # 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
|
2288 # intermediate public heads. |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2289 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
|
2290 if draftheads: |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2291 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
|
2292 |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2293 revset = 'heads(only(%ln, %ln) and public())' |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2294 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
|
2295 for r in extraheads: |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2296 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
|
2297 |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2298 # transform data in a format used by the encoding function |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2299 phasemapping = [] |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2300 for phase in phases.allphases: |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2301 phasemapping.append(sorted(headsbyphase[phase])) |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2302 |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2303 # generate the actual part |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2304 phasedata = phases.binaryencode(phasemapping) |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2305 bundler.newpart('phase-heads', data=phasedata) |
10e162bb9bf5
pull: use 'phase-heads' to retrieve phase information
Boris Feld <boris.feld@octobus.net>
parents:
34317
diff
changeset
|
2306 |
25402
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2307 @getbundle2partsgenerator('hgtagsfnodes') |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2308 def _getbundletagsfnodes(bundler, repo, source, bundlecaps=None, |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2309 b2caps=None, heads=None, common=None, |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2310 **kwargs): |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2311 """Transfer the .hgtags filenodes mapping. |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2312 |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2313 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
|
2314 |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2315 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
|
2316 filenodes raw values. |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2317 """ |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2318 # Don't send unless: |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2319 # - changeset are being exchanged, |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2320 # - the client supports it. |
35355
a119e97b6caf
py3: handle keyword arguments correctly in exchange.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35347
diff
changeset
|
2321 if not (kwargs.get(r'cg', True) and 'hgtagsfnodes' in b2caps): |
25402
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2322 return |
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2323 |
29808
8d226db31f20
computeoutgoing: move the function from 'changegroup' to 'exchange'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
29807
diff
changeset
|
2324 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
|
2325 bundle2.addparttagsfnodescache(repo, bundler, outgoing) |
25402
0c2ded041d10
exchange: support transferring .hgtags fnodes mapping
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25369
diff
changeset
|
2326 |
36966
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2327 @getbundle2partsgenerator('cache:rev-branch-cache') |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2328 def _getbundlerevbranchcache(bundler, repo, source, bundlecaps=None, |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2329 b2caps=None, heads=None, common=None, |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2330 **kwargs): |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2331 """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
|
2332 |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2333 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
|
2334 |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2335 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
|
2336 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
|
2337 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
|
2338 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
|
2339 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
|
2340 """ |
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2341 # 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
|
2342 # - 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
|
2343 # - 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
|
2344 # - narrow bundle isn't in play (not currently compatible). |
9b64b73d702b
exchange: move disabling of rev-branch-cache bundle part out of narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38614
diff
changeset
|
2345 if (not kwargs.get(r'cg', True) |
9b64b73d702b
exchange: move disabling of rev-branch-cache bundle part out of narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38614
diff
changeset
|
2346 or 'rev-branch-cache' not in b2caps |
9b64b73d702b
exchange: move disabling of rev-branch-cache bundle part out of narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38614
diff
changeset
|
2347 or kwargs.get(r'narrow', False) |
9b64b73d702b
exchange: move disabling of rev-branch-cache bundle part out of narrow
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38614
diff
changeset
|
2348 or repo.ui.has_section(_NARROWACL_SECTION)): |
36966
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2349 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
|
2350 |
36966
c0e90df1ab1e
revbranchcache: add the necessary bit to send 'rbc' data over bundle2
Boris Feld <boris.feld@octobus.net>
parents:
36938
diff
changeset
|
2351 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
|
2352 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
|
2353 |
20967
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
2354 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
|
2355 """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
|
2356 |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
2357 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
|
2358 """ |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
2359 heads = repo.heads() |
29341
0d83ad967bf8
cleanup: replace uses of util.(md5|sha1|sha256|sha512) with hashlib.\1
Augie Fackler <raf@durin42.com>
parents:
29064
diff
changeset
|
2360 heads_hash = hashlib.sha1(''.join(sorted(heads))).digest() |
20967
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
2361 if not (their_heads == ['force'] or their_heads == heads or |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
2362 their_heads == ['hashed', heads_hash]): |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
2363 # 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
|
2364 # were transferring data |
21184
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21182
diff
changeset
|
2365 raise error.PushRaced('repository changed while %s - ' |
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21182
diff
changeset
|
2366 'please try again' % context) |
20968
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
2367 |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
2368 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
|
2369 """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
|
2370 |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
2371 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
|
2372 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
|
2373 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
|
2374 |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
2375 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
|
2376 r = 0 |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
2377 # 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
|
2378 # [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
|
2379 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
|
2380 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
|
2381 # quick fix for output mismatch with bundle2 in 3.4 |
33499
0407a51b9d8c
codemod: register core configitems using a script
Jun Wu <quark@fb.com>
parents:
33138
diff
changeset
|
2382 captureoutput = repo.ui.configbool('experimental', 'bundle2-output-capture') |
25423
525fbf24b51b
bundle2: stop capturing output for ssh again
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25404
diff
changeset
|
2383 if url.startswith('remote:http:') or url.startswith('remote:https:'): |
24878
e530cde6d115
bundle2: disable ouput capture unless we use http (issue4613 issue4615)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24851
diff
changeset
|
2384 captureoutput = True |
20968
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
2385 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
|
2386 # 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
|
2387 # 'check_heads' call wil be a no-op |
20968
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
2388 check_heads(repo, heads, 'uploading changes') |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
2389 # 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
|
2390 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
|
2391 # legacy case: bundle1 (changegroup 01) |
32927
febd6bfa770d
exchange: create transaction for bundle1 unbundling earlier
Martin von Zweigbergk <martinvonz@google.com>
parents:
32896
diff
changeset
|
2392 txnname = "\n".join([source, util.hidepassword(url)]) |
32930
af31d531dda0
changegroup: let callers pass in transaction to apply() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
32927
diff
changeset
|
2393 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
|
2394 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
|
2395 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
|
2396 else: |
24795
f9aa4cb8f2dd
bundle2: store the salvaged output on the exception object
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24754
diff
changeset
|
2397 r = None |
21187
bcfd44abad93
bundle2: gracefully handle hook abort
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
2398 try: |
26566
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2399 def gettransaction(): |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2400 if not lockandtr[2]: |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2401 lockandtr[0] = repo.wlock() |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2402 lockandtr[1] = repo.lock() |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2403 lockandtr[2] = repo.transaction(source) |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2404 lockandtr[2].hookargs['source'] = source |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2405 lockandtr[2].hookargs['url'] = url |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2406 lockandtr[2].hookargs['bundle2'] = '1' |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2407 return lockandtr[2] |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2408 |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2409 # 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
|
2410 # locking. |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2411 if not repo.ui.configbool('experimental', 'bundle2lazylocking'): |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2412 gettransaction() |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2413 |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2414 op = bundle2.bundleoperation(repo, gettransaction, |
37237
f7d3915d5b3a
bundleoperation: pass the source argument from all the users
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37170
diff
changeset
|
2415 captureoutput=captureoutput, |
f7d3915d5b3a
bundleoperation: pass the source argument from all the users
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37170
diff
changeset
|
2416 source='push') |
24851
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
2417 try: |
25896
6805a4f76cda
exchange: fix dead assignment
Martin von Zweigbergk <martinvonz@google.com>
parents:
25895
diff
changeset
|
2418 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
|
2419 finally: |
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
2420 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
|
2421 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
|
2422 repo.ui.pushbuffer(error=True, subproc=True) |
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
2423 def recordout(output): |
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
2424 r.newpart('output', data=output, mandatory=False) |
26566
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2425 if lockandtr[2] is not None: |
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2426 lockandtr[2].close() |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25640
diff
changeset
|
2427 except BaseException as exc: |
21187
bcfd44abad93
bundle2: gracefully handle hook abort
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
2428 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
|
2429 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
|
2430 parts = exc._bundle2salvagedoutput = r.salvageoutput() |
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
2431 def recordout(output): |
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
2432 part = bundle2.bundlepart('output', data=output, |
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
2433 mandatory=False) |
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
2434 parts.append(part) |
21187
bcfd44abad93
bundle2: gracefully handle hook abort
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
2435 raise |
20968
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
2436 finally: |
26566
58880acd2369
bundle2: allow lazily acquiring the lock
Durham Goode <durham@fb.com>
parents:
26471
diff
changeset
|
2437 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
|
2438 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
|
2439 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
|
2440 return r |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2441 |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2442 def _maybeapplyclonebundle(pullop): |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2443 """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
|
2444 |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2445 repo = pullop.repo |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2446 remote = pullop.remote |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2447 |
33499
0407a51b9d8c
codemod: register core configitems using a script
Jun Wu <quark@fb.com>
parents:
33138
diff
changeset
|
2448 if not repo.ui.configbool('ui', 'clonebundles'): |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2449 return |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2450 |
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
|
2451 # 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
|
2452 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
|
2453 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
|
2454 |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2455 if pullop.heads: |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2456 return |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2457 |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2458 if not remote.capable('clonebundles'): |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2459 return |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2460 |
37649
a168799687e5
wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37648
diff
changeset
|
2461 with remote.commandexecutor() as e: |
a168799687e5
wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37648
diff
changeset
|
2462 res = e.callcommand('clonebundles', {}).result() |
26689
2c9f15366982
exchange: record that we attempted to fetch a clone bundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26688
diff
changeset
|
2463 |
2c9f15366982
exchange: record that we attempted to fetch a clone bundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26688
diff
changeset
|
2464 # 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
|
2465 # attempt. |
2c9f15366982
exchange: record that we attempted to fetch a clone bundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26688
diff
changeset
|
2466 pullop.clonebundleattempted = True |
2c9f15366982
exchange: record that we attempted to fetch a clone bundle
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26688
diff
changeset
|
2467 |
26647
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
2468 entries = parseclonebundlesmanifest(repo, res) |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2469 if not entries: |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2470 repo.ui.note(_('no clone bundles available on remote; ' |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2471 'falling back to regular clone\n')) |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2472 return |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2473 |
34364
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2474 entries = filterclonebundleentries( |
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2475 repo, entries, streamclonerequested=pullop.streamclonerequested) |
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2476 |
26644
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2477 if not entries: |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2478 # 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
|
2479 # 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
|
2480 # 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
|
2481 # 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
|
2482 # clone! |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2483 repo.ui.warn(_('no compatible clone bundles available on server; ' |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2484 'falling back to regular clone\n')) |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2485 repo.ui.warn(_('(you may want to report this to the server ' |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2486 'operator)\n')) |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2487 return |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2488 |
26648
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2489 entries = sortclonebundleentries(repo.ui, entries) |
26644
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2490 |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2491 url = entries[0]['URL'] |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2492 repo.ui.status(_('applying clone bundle from %s\n') % url) |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2493 if trypullbundlefromurl(repo.ui, repo, url): |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2494 repo.ui.status(_('finished applying clone bundle\n')) |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2495 # Bundle failed. |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2496 # |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2497 # 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
|
2498 # 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
|
2499 # clone load to be offloaded. |
33499
0407a51b9d8c
codemod: register core configitems using a script
Jun Wu <quark@fb.com>
parents:
33138
diff
changeset
|
2500 elif repo.ui.configbool('ui', 'clonebundlefallback'): |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2501 repo.ui.warn(_('falling back to normal clone\n')) |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2502 else: |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2503 raise error.Abort(_('error applying bundle'), |
26688
7394536338bb
exchange: provide hint on how to disable clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26687
diff
changeset
|
2504 hint=_('if this error persists, consider contacting ' |
7394536338bb
exchange: provide hint on how to disable clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26687
diff
changeset
|
2505 'the server operator or disable clone ' |
7394536338bb
exchange: provide hint on how to disable clone bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26687
diff
changeset
|
2506 'bundles via ' |
27738
a0e783d26e81
exchange: make clone bundles non-experimental and enabled by default
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27737
diff
changeset
|
2507 '"--config ui.clonebundles=false"')) |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2508 |
26647
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
2509 def parseclonebundlesmanifest(repo, s): |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2510 """Parses the raw text of a clone bundles manifest. |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2511 |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2512 Returns a list of dicts. The dicts have a ``URL`` key corresponding |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2513 to the URL and other keys are the attributes for the entry. |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2514 """ |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2515 m = [] |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2516 for line in s.splitlines(): |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2517 fields = line.split() |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2518 if not fields: |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2519 continue |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2520 attrs = {'URL': fields[0]} |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2521 for rawattr in fields[1:]: |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2522 key, value = rawattr.split('=', 1) |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
2523 key = urlreq.unquote(key) |
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28876
diff
changeset
|
2524 value = urlreq.unquote(value) |
26647
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
2525 attrs[key] = value |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
2526 |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
2527 # Parse BUNDLESPEC into components. This makes client-side |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
2528 # preferences easier to specify since you can prefer a single |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
2529 # component of the BUNDLESPEC. |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
2530 if key == 'BUNDLESPEC': |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
2531 try: |
37768
5527aa808dea
bundlespec: drop externalnames flag
Joerg Sonnenberger <joerg@bec.de>
parents:
37757
diff
changeset
|
2532 bundlespec = parsebundlespec(repo, value) |
37164
b229fd9adeae
bundlespec: introduce an attr-based class for bundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37084
diff
changeset
|
2533 attrs['COMPRESSION'] = bundlespec.compression |
b229fd9adeae
bundlespec: introduce an attr-based class for bundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37084
diff
changeset
|
2534 attrs['VERSION'] = bundlespec.version |
26647
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
2535 except error.InvalidBundleSpecification: |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
2536 pass |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
2537 except error.UnsupportedBundleSpecification: |
62b0fa0d8787
exchange: extract bundle specification components into own attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26646
diff
changeset
|
2538 pass |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2539 |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2540 m.append(attrs) |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2541 |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2542 return m |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2543 |
37170
b837655c1509
streamclonebundle: make sure we accept new stream clone bundle spec
Boris Feld <boris.feld@octobus.net>
parents:
37168
diff
changeset
|
2544 def isstreamclonespec(bundlespec): |
b837655c1509
streamclonebundle: make sure we accept new stream clone bundle spec
Boris Feld <boris.feld@octobus.net>
parents:
37168
diff
changeset
|
2545 # Stream clone v1 |
37768
5527aa808dea
bundlespec: drop externalnames flag
Joerg Sonnenberger <joerg@bec.de>
parents:
37757
diff
changeset
|
2546 if (bundlespec.wirecompression == 'UN' and bundlespec.wireversion == 's1'): |
37170
b837655c1509
streamclonebundle: make sure we accept new stream clone bundle spec
Boris Feld <boris.feld@octobus.net>
parents:
37168
diff
changeset
|
2547 return True |
b837655c1509
streamclonebundle: make sure we accept new stream clone bundle spec
Boris Feld <boris.feld@octobus.net>
parents:
37168
diff
changeset
|
2548 |
b837655c1509
streamclonebundle: make sure we accept new stream clone bundle spec
Boris Feld <boris.feld@octobus.net>
parents:
37168
diff
changeset
|
2549 # Stream clone v2 |
41759
aaad36b88298
cleanup: use () to wrap long lines instead of \
Augie Fackler <augie@google.com>
parents:
41704
diff
changeset
|
2550 if (bundlespec.wirecompression == 'UN' and |
aaad36b88298
cleanup: use () to wrap long lines instead of \
Augie Fackler <augie@google.com>
parents:
41704
diff
changeset
|
2551 bundlespec.wireversion == '02' and |
37170
b837655c1509
streamclonebundle: make sure we accept new stream clone bundle spec
Boris Feld <boris.feld@octobus.net>
parents:
37168
diff
changeset
|
2552 bundlespec.contentopts.get('streamv2')): |
b837655c1509
streamclonebundle: make sure we accept new stream clone bundle spec
Boris Feld <boris.feld@octobus.net>
parents:
37168
diff
changeset
|
2553 return True |
b837655c1509
streamclonebundle: make sure we accept new stream clone bundle spec
Boris Feld <boris.feld@octobus.net>
parents:
37168
diff
changeset
|
2554 |
b837655c1509
streamclonebundle: make sure we accept new stream clone bundle spec
Boris Feld <boris.feld@octobus.net>
parents:
37168
diff
changeset
|
2555 return False |
b837655c1509
streamclonebundle: make sure we accept new stream clone bundle spec
Boris Feld <boris.feld@octobus.net>
parents:
37168
diff
changeset
|
2556 |
34364
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2557 def filterclonebundleentries(repo, entries, streamclonerequested=False): |
26687
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
2558 """Remove incompatible clone bundle manifest entries. |
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
2559 |
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
2560 Accepts a list of entries parsed with ``parseclonebundlesmanifest`` |
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
2561 and returns a new list consisting of only the entries that this client |
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
2562 should be able to apply. |
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
2563 |
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
2564 There is no guarantee we'll be able to apply all returned entries because |
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
2565 the metadata we use to filter on may be missing or wrong. |
6a854f558926
exchange: document filterclonebundleentries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26672
diff
changeset
|
2566 """ |
26644
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2567 newentries = [] |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2568 for entry in entries: |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2569 spec = entry.get('BUNDLESPEC') |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2570 if spec: |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2571 try: |
37164
b229fd9adeae
bundlespec: introduce an attr-based class for bundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37084
diff
changeset
|
2572 bundlespec = parsebundlespec(repo, spec, strict=True) |
34364
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2573 |
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2574 # If a stream clone was requested, filter out non-streamclone |
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2575 # entries. |
37170
b837655c1509
streamclonebundle: make sure we accept new stream clone bundle spec
Boris Feld <boris.feld@octobus.net>
parents:
37168
diff
changeset
|
2576 if streamclonerequested and not isstreamclonespec(bundlespec): |
34364
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2577 repo.ui.debug('filtering %s because not a stream clone\n' % |
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2578 entry['URL']) |
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2579 continue |
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2580 |
26644
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2581 except error.InvalidBundleSpecification as e: |
37663
fc114a16a484
py3: use stringutil.forcebytestr() instead of str()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
37649
diff
changeset
|
2582 repo.ui.debug(stringutil.forcebytestr(e) + '\n') |
26644
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2583 continue |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2584 except error.UnsupportedBundleSpecification as e: |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2585 repo.ui.debug('filtering %s because unsupported bundle ' |
36422
04c319a07c7b
py3: hunt down str(exception) instances and use util.forcebytestr
Augie Fackler <augie@google.com>
parents:
35813
diff
changeset
|
2586 'spec: %s\n' % ( |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36966
diff
changeset
|
2587 entry['URL'], stringutil.forcebytestr(e))) |
26644
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2588 continue |
34364
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2589 # If we don't have a spec and requested a stream clone, we don't know |
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2590 # what the entry is so don't attempt to apply it. |
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2591 elif streamclonerequested: |
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2592 repo.ui.debug('filtering %s because cannot determine if a stream ' |
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2593 'clone bundle\n' % entry['URL']) |
ff406f3e57b2
exchange: perform stream clone with clone bundle with --uncompressed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34323
diff
changeset
|
2594 continue |
26644
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2595 |
26645
2faa7671a4b3
clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26644
diff
changeset
|
2596 if 'REQUIRESNI' in entry and not sslutil.hassni: |
2faa7671a4b3
clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26644
diff
changeset
|
2597 repo.ui.debug('filtering %s because SNI not supported\n' % |
2faa7671a4b3
clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26644
diff
changeset
|
2598 entry['URL']) |
2faa7671a4b3
clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26644
diff
changeset
|
2599 continue |
2faa7671a4b3
clonebundles: filter on SNI requirement
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26644
diff
changeset
|
2600 |
26644
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2601 newentries.append(entry) |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2602 |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2603 return newentries |
74de1c59f71c
clonebundles: filter on bundle specification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26643
diff
changeset
|
2604 |
30685
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2605 class clonebundleentry(object): |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2606 """Represents an item in a clone bundles manifest. |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2607 |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2608 This rich class is needed to support sorting since sorted() in Python 3 |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2609 doesn't support ``cmp`` and our comparison is complex enough that ``key=`` |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2610 won't work. |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2611 """ |
26648
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2612 |
30685
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2613 def __init__(self, value, prefers): |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2614 self.value = value |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2615 self.prefers = prefers |
26648
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2616 |
30685
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2617 def _cmp(self, other): |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2618 for prefkey, prefvalue in self.prefers: |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2619 avalue = self.value.get(prefkey) |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2620 bvalue = other.value.get(prefkey) |
26648
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2621 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2622 # Special case for b missing attribute and a matches exactly. |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2623 if avalue is not None and bvalue is None and avalue == prefvalue: |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2624 return -1 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2625 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2626 # Special case for a missing attribute and b matches exactly. |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2627 if bvalue is not None and avalue is None and bvalue == prefvalue: |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2628 return 1 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2629 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2630 # We can't compare unless attribute present on both. |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2631 if avalue is None or bvalue is None: |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2632 continue |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2633 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2634 # Same values should fall back to next attribute. |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2635 if avalue == bvalue: |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2636 continue |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2637 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2638 # Exact matches come first. |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2639 if avalue == prefvalue: |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2640 return -1 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2641 if bvalue == prefvalue: |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2642 return 1 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2643 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2644 # Fall back to next attribute. |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2645 continue |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2646 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2647 # If we got here we couldn't sort by attributes and prefers. Fall |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2648 # back to index order. |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2649 return 0 |
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2650 |
30685
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2651 def __lt__(self, other): |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2652 return self._cmp(other) < 0 |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2653 |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2654 def __gt__(self, other): |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2655 return self._cmp(other) > 0 |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2656 |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2657 def __eq__(self, other): |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2658 return self._cmp(other) == 0 |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2659 |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2660 def __le__(self, other): |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2661 return self._cmp(other) <= 0 |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2662 |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2663 def __ge__(self, other): |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2664 return self._cmp(other) >= 0 |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2665 |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2666 def __ne__(self, other): |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2667 return self._cmp(other) != 0 |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2668 |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2669 def sortclonebundleentries(ui, entries): |
32991
03608e8d09e9
configitems: register 'ui.clonebundleprefers' as example for 'configlist'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32957
diff
changeset
|
2670 prefers = ui.configlist('ui', 'clonebundleprefers') |
30685
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2671 if not prefers: |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2672 return list(entries) |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2673 |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2674 prefers = [p.split('=', 1) for p in prefers] |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2675 |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2676 items = sorted(clonebundleentry(v, prefers) for v in entries) |
95325386cd1a
exchange: use rich class for sorting clone bundle entries
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30583
diff
changeset
|
2677 return [i.value for i in items] |
26648
c347d532bb56
exchange: support sorting URLs by client-side preferences
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26647
diff
changeset
|
2678 |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2679 def trypullbundlefromurl(ui, repo, url): |
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2680 """Attempt to apply a bundle from a URL.""" |
32843
a470bbb4e3af
clonebundle: use context managers for lock and transaction
Martin von Zweigbergk <martinvonz@google.com>
parents:
32709
diff
changeset
|
2681 with repo.lock(), repo.transaction('bundleurl') as tr: |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2682 try: |
32843
a470bbb4e3af
clonebundle: use context managers for lock and transaction
Martin von Zweigbergk <martinvonz@google.com>
parents:
32709
diff
changeset
|
2683 fh = urlmod.open(ui, url) |
a470bbb4e3af
clonebundle: use context managers for lock and transaction
Martin von Zweigbergk <martinvonz@google.com>
parents:
32709
diff
changeset
|
2684 cg = readbundle(ui, fh, 'stream') |
26643
d2e16419d3f4
clonebundle: support bundle2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26640
diff
changeset
|
2685 |
33043
18c2489ac96d
bundle: make applybundle() delegate v1 bundles to applybundle1()
Martin von Zweigbergk <martinvonz@google.com>
parents:
33040
diff
changeset
|
2686 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
|
2687 cg.apply(repo) |
a470bbb4e3af
clonebundle: use context managers for lock and transaction
Martin von Zweigbergk <martinvonz@google.com>
parents:
32709
diff
changeset
|
2688 else: |
33043
18c2489ac96d
bundle: make applybundle() delegate v1 bundles to applybundle1()
Martin von Zweigbergk <martinvonz@google.com>
parents:
33040
diff
changeset
|
2689 bundle2.applybundle(repo, cg, tr, 'clonebundles', url) |
32843
a470bbb4e3af
clonebundle: use context managers for lock and transaction
Martin von Zweigbergk <martinvonz@google.com>
parents:
32709
diff
changeset
|
2690 return True |
a470bbb4e3af
clonebundle: use context managers for lock and transaction
Martin von Zweigbergk <martinvonz@google.com>
parents:
32709
diff
changeset
|
2691 except urlerr.httperror as e: |
36422
04c319a07c7b
py3: hunt down str(exception) instances and use util.forcebytestr
Augie Fackler <augie@google.com>
parents:
35813
diff
changeset
|
2692 ui.warn(_('HTTP error fetching bundle: %s\n') % |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36966
diff
changeset
|
2693 stringutil.forcebytestr(e)) |
32843
a470bbb4e3af
clonebundle: use context managers for lock and transaction
Martin von Zweigbergk <martinvonz@google.com>
parents:
32709
diff
changeset
|
2694 except urlerr.urlerror as e: |
36488
724ddf2444a7
py3: use util.forcebytestr to convert str to bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36423
diff
changeset
|
2695 ui.warn(_('error fetching bundle: %s\n') % |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36966
diff
changeset
|
2696 stringutil.forcebytestr(e.reason)) |
26623
5a95fe44121d
clonebundles: support for seeding clones from pre-generated bundles
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
2697 |
32843
a470bbb4e3af
clonebundle: use context managers for lock and transaction
Martin von Zweigbergk <martinvonz@google.com>
parents:
32709
diff
changeset
|
2698 return False |