Mercurial > hg
annotate mercurial/exchange.py @ 24970:33055069e465
dockerlib: fix initcontainer for boot2docker users
This allows me to build rpm packages using boot2docker on my Mac. It's
probably a very fragile hack, but it seems to work well enough for now
that I felt it was worth sharing.
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 06 May 2015 14:36:17 -0400 |
parents | e530cde6d115 |
children | e632a2429982 36111f98f23d |
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 |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
8 from i18n import _ |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
9 from node import hex, nullid |
21141
d8dd19e09ed4
bundle2: advertise bundle2 caps in server capabilities
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21130
diff
changeset
|
10 import errno, urllib |
21184
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21182
diff
changeset
|
11 import util, scmutil, changegroup, base85, error |
22622
ce6b9edee725
exchange: import bookmarks as bookmod
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22616
diff
changeset
|
12 import discovery, phases, obsolete, bookmarks as bookmod, bundle2, pushkey |
24752
5640efd1b160
unbundle: acquire 'wlock' when processing bundle2 (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24738
diff
changeset
|
13 import lock as lockmod |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
14 |
21064
4d9d490d7bbe
bundle2: add a ui argument to readbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21063
diff
changeset
|
15 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
|
16 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
|
17 |
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
|
18 alg = None |
21063
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
19 if not fname: |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
20 fname = "stream" |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
21 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
|
22 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
|
23 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
|
24 alg = 'UN' |
21063
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
25 elif vfs: |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
26 fname = vfs.join(fname) |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
27 |
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
|
28 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
|
29 |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
30 if magic != 'HG': |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
31 raise util.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
|
32 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
|
33 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
|
34 alg = changegroup.readexactly(fh, 2) |
22390
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22354
diff
changeset
|
35 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
|
36 elif version.startswith('2'): |
24641
60fecc5b14a4
unbundle20: retrieve unbundler instances through a factory function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24638
diff
changeset
|
37 return bundle2.getunbundler(ui, fh, header=magic + version) |
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
|
38 else: |
21063
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
39 raise util.Abort(_('%s: unknown bundle version %s') % (fname, version)) |
7ca4f2049d3b
bundle2: move `readbundle` into the `exchange` module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21062
diff
changeset
|
40 |
22346
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
41 def buildobsmarkerspart(bundler, markers): |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
42 """add an obsmarker part to the bundler with <markers> |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
43 |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
44 No part is created if markers is empty. |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
45 Raises ValueError if the bundler doesn't support any known obsmarker format. |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
46 """ |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
47 if markers: |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
48 remoteversions = bundle2.obsmarkersversion(bundler.capabilities) |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
49 version = obsolete.commonversion(remoteversions) |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
50 if version is None: |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
51 raise ValueError('bundler do not support common obsmarker format') |
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
52 stream = obsolete.encodemarkers(markers, True, version=version) |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
53 return bundler.newpart('obsmarkers', data=stream) |
22346
a76660f85200
exchange: add a `buildobsmarkerpart` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22342
diff
changeset
|
54 return None |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
55 |
24650
b83a8f512a80
exchange: introduce a '_canusebundle2' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24649
diff
changeset
|
56 def _canusebundle2(op): |
b83a8f512a80
exchange: introduce a '_canusebundle2' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24649
diff
changeset
|
57 """return true if a pull/push can use bundle2 |
b83a8f512a80
exchange: introduce a '_canusebundle2' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24649
diff
changeset
|
58 |
b83a8f512a80
exchange: introduce a '_canusebundle2' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24649
diff
changeset
|
59 Feel free to nuke this function when we drop the experimental option""" |
b83a8f512a80
exchange: introduce a '_canusebundle2' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24649
diff
changeset
|
60 return (op.repo.ui.configbool('experimental', 'bundle2-exp', False) |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
61 and op.remote.capable('bundle2')) |
24650
b83a8f512a80
exchange: introduce a '_canusebundle2' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24649
diff
changeset
|
62 |
b83a8f512a80
exchange: introduce a '_canusebundle2' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24649
diff
changeset
|
63 |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
64 class pushoperation(object): |
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
65 """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
|
66 |
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
67 It purpose is to carry push related state and very common operation. |
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
68 |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
69 A new should be created at the beginning of each push and discarded |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
70 afterward. |
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
71 """ |
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
72 |
22623
cd7e17aa6040
push: pass list of bookmark to `exchange.push`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22622
diff
changeset
|
73 def __init__(self, repo, remote, force=False, revs=None, newbranch=False, |
cd7e17aa6040
push: pass list of bookmark to `exchange.push`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22622
diff
changeset
|
74 bookmarks=()): |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
75 # repo we push from |
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
76 self.repo = repo |
20347
3ec5f833348e
push: ease access to current ui object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20346
diff
changeset
|
77 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
|
78 # 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
|
79 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
|
80 # force option provided |
89f90457979e
push: move `force` argument into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20348
diff
changeset
|
81 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
|
82 # 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
|
83 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
|
84 # bookmark explicitly pushed |
cd7e17aa6040
push: pass list of bookmark to `exchange.push`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22622
diff
changeset
|
85 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
|
86 # 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
|
87 self.newbranch = newbranch |
20436
2f2e8d1c4856
push: move local lock logic in pushoperation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20435
diff
changeset
|
88 # did a local lock get acquired? |
2f2e8d1c4856
push: move local lock logic in pushoperation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20435
diff
changeset
|
89 self.locallocked = None |
21901
8612c4ab7f54
push: add a ``pushop.stepsdone`` attribute
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21899
diff
changeset
|
90 # step already performed |
8612c4ab7f54
push: add a ``pushop.stepsdone`` attribute
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21899
diff
changeset
|
91 # (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
|
92 self.stepsdone = set() |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
93 # 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
|
94 # - 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
|
95 # - 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
|
96 # - 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
|
97 # 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
|
98 # - 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
|
99 self.cgresult = None |
22624
eef31f9a4c0f
push: add `pushoperation.bkresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22623
diff
changeset
|
100 # Boolean value for the bookmark push |
eef31f9a4c0f
push: add `pushoperation.bkresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22623
diff
changeset
|
101 self.bkresult = None |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
102 # 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
|
103 self.outgoing = None |
20462
0031ef5df586
push: move `remoteheads` into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20441
diff
changeset
|
104 # all remote heads before the push |
0031ef5df586
push: move `remoteheads` into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20441
diff
changeset
|
105 self.remoteheads = None |
20464
d032417db243
push: move `incoming` into the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20463
diff
changeset
|
106 # 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
|
107 self.incoming = None |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
108 # 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
|
109 self.outdatedphases = None |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
110 # 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
|
111 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
|
112 # outgoing obsmarkers |
22035
24bb01f42e82
push: introduce a discovery step for obsmarker
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22034
diff
changeset
|
113 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
|
114 # outgoing bookmarks |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
115 self.outbookmarks = [] |
23437
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
116 # transaction manager |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
117 self.trmanager = None |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
118 |
22014
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
119 @util.propertycache |
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
120 def futureheads(self): |
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
121 """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
|
122 return self.outgoing.missingheads |
71083b020b4a
push: extract future heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21989
diff
changeset
|
123 |
22015
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
124 @util.propertycache |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
125 def fallbackheads(self): |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
126 """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
|
127 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
|
128 # 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
|
129 return self.outgoing.commonheads |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
130 unfi = self.repo.unfiltered() |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
131 # 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
|
132 # (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
|
133 # |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
134 # 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
|
135 # cheads = ( (missingheads and ::commonheads) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
136 # + (commonheads and ::missingheads))" |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
137 # ) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
138 # |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
139 # 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
|
140 # common = (::commonheads) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
141 # missing = ((commonheads::missingheads) - commonheads) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
142 # |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
143 # We can pick: |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
144 # * missingheads part of common (::commonheads) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
145 common = set(self.outgoing.common) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
146 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
|
147 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
|
148 # and |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
149 # * commonheads parents on missing |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
150 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
|
151 self.outgoing.commonheads, |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
152 self.outgoing.missing) |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
153 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
|
154 return cheads |
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
155 |
22016
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
156 @property |
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
157 def commonheads(self): |
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
158 """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
|
159 if self.cgresult: |
22016
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
160 return self.futureheads |
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
161 else: |
7d976d71684c
push: move common heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22015
diff
changeset
|
162 return self.fallbackheads |
22015
c478031deba2
push: extract fallback heads computation into pushop
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22014
diff
changeset
|
163 |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
164 # 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
|
165 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
|
166 _('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
|
167 '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
|
168 _('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
|
169 '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
|
170 _('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
|
171 } |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
172 |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
173 |
22623
cd7e17aa6040
push: pass list of bookmark to `exchange.push`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22622
diff
changeset
|
174 def push(repo, remote, force=False, revs=None, newbranch=False, bookmarks=()): |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
175 '''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
|
176 repository to remote. Return an integer: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
177 - None means nothing to push |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
178 - 0 means HTTP error |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
179 - 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
|
180 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
|
181 - other values as described by addchangegroup() |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
182 ''' |
22623
cd7e17aa6040
push: pass list of bookmark to `exchange.push`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22622
diff
changeset
|
183 pushop = pushoperation(repo, remote, force, revs, newbranch, bookmarks) |
20348
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
184 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
|
185 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
|
186 - pushop.remote.local().supported) |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
187 if missing: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
188 msg = _("required features are not" |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
189 " supported in the destination:" |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
190 " %s") % (', '.join(sorted(missing))) |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
191 raise util.Abort(msg) |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
192 |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
193 # there are two ways to push to remote repo: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
194 # |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
195 # addchangegroup assumes local user can lock remote |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
196 # repo (local filesystem, old ssh servers). |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
197 # |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
198 # unbundle assumes local user cannot lock remote repo (new ssh |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
199 # servers, http servers). |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
200 |
20348
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
201 if not pushop.remote.canpush(): |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
202 raise util.Abort(_("destination does not support push")) |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
203 # get local lock as we might write phase data |
24754
5dc5cd7abbf5
push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24752
diff
changeset
|
204 localwlock = locallock = None |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
205 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
|
206 # 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
|
207 # 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
|
208 maypushback = pushop.ui.configbool('experimental', 'bundle2.pushback') |
5dc5cd7abbf5
push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24752
diff
changeset
|
209 if _canusebundle2(pushop) and maypushback: |
5dc5cd7abbf5
push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24752
diff
changeset
|
210 localwlock = pushop.repo.wlock() |
20346
42df1fe32552
push: introduce a pushoperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20345
diff
changeset
|
211 locallock = pushop.repo.lock() |
20436
2f2e8d1c4856
push: move local lock logic in pushoperation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20435
diff
changeset
|
212 pushop.locallocked = True |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
213 except IOError, err: |
20436
2f2e8d1c4856
push: move local lock logic in pushoperation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20435
diff
changeset
|
214 pushop.locallocked = False |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
215 if err.errno != errno.EACCES: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
216 raise |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
217 # source repo cannot be locked. |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
218 # 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
|
219 # synchronisation. |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
220 msg = 'cannot lock source repository: %s\n' % err |
20347
3ec5f833348e
push: ease access to current ui object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20346
diff
changeset
|
221 pushop.ui.debug(msg) |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
222 try: |
23437
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
223 if pushop.locallocked: |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
224 pushop.trmanager = transactionmanager(repo, |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
225 'push-response', |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
226 pushop.remote.url()) |
20924
e10000369b47
push: pass a `pushoperation` object to localrepo.checkpush
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20901
diff
changeset
|
227 pushop.repo.checkpush(pushop) |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
228 lock = None |
20348
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
229 unbundle = pushop.remote.capable('unbundle') |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
230 if not unbundle: |
20348
d64c904db55a
push: move `remote` argument in the push object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20347
diff
changeset
|
231 lock = pushop.remote.lock() |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
232 try: |
20466
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
233 _pushdiscovery(pushop) |
24650
b83a8f512a80
exchange: introduce a '_canusebundle2' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24649
diff
changeset
|
234 if _canusebundle2(pushop): |
21903
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
235 _pushbundle2(pushop) |
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
236 _pushchangeset(pushop) |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
237 _pushsyncphase(pushop) |
20433
6af248474224
push: feed pushoperation object to _pushobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20432
diff
changeset
|
238 _pushobsolete(pushop) |
22224
f713de1d3916
push: update bookmarks within the remote lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22069
diff
changeset
|
239 _pushbookmark(pushop) |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
240 finally: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
241 if lock is not None: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
242 lock.release() |
23437
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
243 if pushop.trmanager: |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
244 pushop.trmanager.close() |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
245 finally: |
23437
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
246 if pushop.trmanager: |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
247 pushop.trmanager.release() |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
248 if locallock is not None: |
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
249 locallock.release() |
24754
5dc5cd7abbf5
push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24752
diff
changeset
|
250 if localwlock is not None: |
5dc5cd7abbf5
push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24752
diff
changeset
|
251 localwlock.release() |
20345
8567b4ea76ac
exchange: extract push function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
252 |
22616
cda85cfc8252
push: `exchange.push` now returns the `pushoperation` object
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22615
diff
changeset
|
253 return pushop |
20352
58300f61b139
push: move bookmarks exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20351
diff
changeset
|
254 |
22018
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
255 # 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
|
256 pushdiscoveryorder = [] |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
257 |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
258 # Mapping between step name and function |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
259 # |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
260 # 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
|
261 pushdiscoverymapping = {} |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
262 |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
263 def pushdiscovery(stepname): |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
264 """decorator for function performing discovery before push |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
265 |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
266 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
|
267 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
|
268 may matter). |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
269 |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
270 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
|
271 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
|
272 def dec(func): |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
273 assert stepname not in pushdiscoverymapping |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
274 pushdiscoverymapping[stepname] = func |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
275 pushdiscoveryorder.append(stepname) |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
276 return func |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
277 return dec |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
278 |
20466
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
279 def _pushdiscovery(pushop): |
22018
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
280 """Run all discovery steps""" |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
281 for stepname in pushdiscoveryorder: |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
282 step = pushdiscoverymapping[stepname] |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
283 step(pushop) |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
284 |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
285 @pushdiscovery('changeset') |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
286 def _pushdiscoverychangeset(pushop): |
ddb56e7e1b92
push: make discovery extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22017
diff
changeset
|
287 """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
|
288 fci = discovery.findcommonincoming |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
289 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
|
290 common, inc, remoteheads = commoninc |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
291 fco = discovery.findcommonoutgoing |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
292 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
|
293 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
|
294 pushop.outgoing = outgoing |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
295 pushop.remoteheads = remoteheads |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
296 pushop.incoming = inc |
233623d58c9a
push: move discovery in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20465
diff
changeset
|
297 |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
298 @pushdiscovery('phase') |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
299 def _pushdiscoveryphase(pushop): |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
300 """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
|
301 |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
302 (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
|
303 outgoing = pushop.outgoing |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
304 unfi = pushop.repo.unfiltered() |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
305 remotephases = pushop.remote.listkeys('phases') |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
306 publishing = remotephases.get('publishing', False) |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
307 ana = phases.analyzeremotephases(pushop.repo, |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
308 pushop.fallbackheads, |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
309 remotephases) |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
310 pheads, droots = ana |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
311 extracond = '' |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
312 if not publishing: |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
313 extracond = ' and public()' |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
314 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
|
315 # 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
|
316 # 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
|
317 # 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
|
318 fallback = list(unfi.set(revset, droots, pushop.fallbackheads)) |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
319 if not outgoing.missing: |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
320 future = fallback |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
321 else: |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
322 # 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
|
323 # |
23139
e53f6b72a0e4
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23082
diff
changeset
|
324 # 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
|
325 # 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
|
326 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
|
327 outgoing.missing, droots)) |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
328 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
|
329 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
|
330 pushop.outdatedphases = future |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
331 pushop.fallbackoutdatedphases = fallback |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
332 |
22035
24bb01f42e82
push: introduce a discovery step for obsmarker
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22034
diff
changeset
|
333 @pushdiscovery('obsmarker') |
24bb01f42e82
push: introduce a discovery step for obsmarker
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22034
diff
changeset
|
334 def _pushdiscoveryobsmarkers(pushop): |
22953
b1d694d3975e
obsolete: add exchange option
Durham Goode <durham@fb.com>
parents:
22937
diff
changeset
|
335 if (obsolete.isenabled(pushop.repo, obsolete.exchangeopt) |
22269
03cc81a28228
push: check if local and remote support evolution during discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22244
diff
changeset
|
336 and pushop.repo.obsstore |
03cc81a28228
push: check if local and remote support evolution during discovery
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22244
diff
changeset
|
337 and 'obsolete' in pushop.remote.listkeys('namespaces')): |
22350
6d113cc7a31a
push: only push obsmarkers relevant to the "pushed subset"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22347
diff
changeset
|
338 repo = pushop.repo |
6d113cc7a31a
push: only push obsmarkers relevant to the "pushed subset"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22347
diff
changeset
|
339 # very naive computation, that can be quite expensive on big repo. |
6d113cc7a31a
push: only push obsmarkers relevant to the "pushed subset"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22347
diff
changeset
|
340 # However: evolution is currently slow on them anyway. |
6d113cc7a31a
push: only push obsmarkers relevant to the "pushed subset"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22347
diff
changeset
|
341 nodes = (c.node() for c in repo.set('::%ln', pushop.futureheads)) |
6d113cc7a31a
push: only push obsmarkers relevant to the "pushed subset"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22347
diff
changeset
|
342 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
|
343 |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
344 @pushdiscovery('bookmarks') |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
345 def _pushdiscoverybookmarks(pushop): |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
346 ui = pushop.ui |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
347 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
|
348 remote = pushop.remote |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
349 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
|
350 ancestors = () |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
351 if pushop.revs: |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
352 revnums = map(repo.changelog.rev, pushop.revs) |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
353 ancestors = repo.changelog.ancestors(revnums, inclusive=True) |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
354 remotebookmark = remote.listkeys('bookmarks') |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
355 |
22651
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
356 explicit = set(pushop.bookmarks) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
357 |
22622
ce6b9edee725
exchange: import bookmarks as bookmod
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22616
diff
changeset
|
358 comp = bookmod.compare(repo, repo._bookmarks, remotebookmark, srchex=hex) |
23081
e62c330a044f
bookmarks: explicitly track identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23047
diff
changeset
|
359 addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = comp |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
360 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
|
361 if b in explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
362 explicit.remove(b) |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
363 if not ancestors or repo[scid].rev() in ancestors: |
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
364 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
|
365 # search added bookmark |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
366 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
|
367 if b in explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
368 explicit.remove(b) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
369 pushop.outbookmarks.append((b, '', scid)) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
370 # search for overwritten bookmark |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
371 for b, scid, dcid in advdst + diverge + differ: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
372 if b in explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
373 explicit.remove(b) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
374 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
|
375 # search for bookmark to delete |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
376 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
|
377 if b in explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
378 explicit.remove(b) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
379 # treat as "deleted locally" |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
380 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
|
381 # 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
|
382 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
|
383 if b in explicit: |
0fc4686de1d7
exchange: don't report failure from identical bookmarks
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23081
diff
changeset
|
384 explicit.remove(b) |
22651
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
385 |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
386 if explicit: |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
387 explicit = sorted(explicit) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
388 # we should probably list all of them |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
389 ui.warn(_('bookmark %s does not exist on the local ' |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
390 'or remote repository!\n') % explicit[0]) |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
391 pushop.bkresult = 2 |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
392 |
b901645a8784
push: gather all bookmark decisions together
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22650
diff
changeset
|
393 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
|
394 |
20465
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
395 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
|
396 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
|
397 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
|
398 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
|
399 # 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
|
400 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
|
401 return False |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
402 # 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
|
403 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
|
404 # 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
|
405 # 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
|
406 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
|
407 # 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
|
408 mso = _("push includes obsolete changeset: %s!") |
22628
2805d23e1f88
exchange: remove a broken i18n abuse
Matt Mackall <mpm@selenic.com>
parents:
22625
diff
changeset
|
409 mst = {"unstable": _("push includes unstable changeset: %s!"), |
2805d23e1f88
exchange: remove a broken i18n abuse
Matt Mackall <mpm@selenic.com>
parents:
22625
diff
changeset
|
410 "bumped": _("push includes bumped changeset: %s!"), |
2805d23e1f88
exchange: remove a broken i18n abuse
Matt Mackall <mpm@selenic.com>
parents:
22625
diff
changeset
|
411 "divergent": _("push includes divergent changeset: %s!")} |
20465
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
412 # 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
|
413 # 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
|
414 # 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
|
415 # 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
|
416 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
|
417 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
|
418 if ctx.obsolete(): |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
419 raise util.Abort(mso % ctx) |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
420 elif ctx.troubled(): |
22628
2805d23e1f88
exchange: remove a broken i18n abuse
Matt Mackall <mpm@selenic.com>
parents:
22625
diff
changeset
|
421 raise util.Abort(mst[ctx.troubles()[0]] % ctx) |
20465
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
422 newbm = pushop.ui.configlist('bookmarks', 'pushing') |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
423 discovery.checkheads(unfi, pushop.remote, outgoing, |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
424 pushop.remoteheads, |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
425 pushop.newbranch, |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
426 bool(pushop.incoming), |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
427 newbm) |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
428 return True |
170f71061069
push: move outgoing check logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20464
diff
changeset
|
429 |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
430 # 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
|
431 b2partsgenorder = [] |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
432 |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
433 # Mapping between step name and function |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
434 # |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
435 # 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
|
436 b2partsgenmapping = {} |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
437 |
24731
88a36edefea5
bundle2: add an 'idx' argument to the 'b2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24697
diff
changeset
|
438 def b2partsgenerator(stepname, idx=None): |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
439 """decorator for function generating bundle2 part |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
440 |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
441 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
|
442 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
|
443 (this may matter). |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
444 |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
445 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
|
446 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
|
447 def dec(func): |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
448 assert stepname not in b2partsgenmapping |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
449 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
|
450 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
|
451 b2partsgenorder.append(stepname) |
88a36edefea5
bundle2: add an 'idx' argument to the 'b2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24697
diff
changeset
|
452 else: |
88a36edefea5
bundle2: add an 'idx' argument to the 'b2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24697
diff
changeset
|
453 b2partsgenorder.insert(idx, stepname) |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
454 return func |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
455 return dec |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
456 |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
457 @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
|
458 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
|
459 """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
|
460 |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
461 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
|
462 """ |
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
|
463 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
|
464 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
|
465 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
|
466 # 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
|
467 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
|
468 return |
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
469 pushop.repo.prepushoutgoinghooks(pushop.repo, |
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
470 pushop.remote, |
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
471 pushop.outgoing) |
21899
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
472 if not pushop.force: |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
473 bundler.newpart('check:heads', data=iter(pushop.remoteheads)) |
23180
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
474 b2caps = bundle2.bundle2caps(pushop.remote) |
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
475 version = None |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
476 cgversions = b2caps.get('changegroup') |
23208
f606e07fa148
bundle2: handle empty 'b2x:changegroup' value in push and pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23203
diff
changeset
|
477 if not cgversions: # 3.1 and 3.2 ship with an empty value |
23180
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
478 cg = changegroup.getlocalchangegroupraw(pushop.repo, 'push', |
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
479 pushop.outgoing) |
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
480 else: |
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
481 cgversions = [v for v in cgversions if v in changegroup.packermap] |
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
482 if not cgversions: |
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
483 raise ValueError(_('no common changegroup version')) |
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
484 version = max(cgversions) |
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
485 cg = changegroup.getlocalchangegroupraw(pushop.repo, 'push', |
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
486 pushop.outgoing, |
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
487 version=version) |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
488 cgpart = bundler.newpart('changegroup', data=cg) |
23180
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
489 if version is not None: |
116b80d63815
push: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23179
diff
changeset
|
490 cgpart.addparam('version', version) |
21899
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
491 def handlereply(op): |
23139
e53f6b72a0e4
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23082
diff
changeset
|
492 """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
|
493 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
|
494 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
|
495 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
|
496 return handlereply |
52ab44b979f4
bundle2-push: extract changegroup logic in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21898
diff
changeset
|
497 |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
498 @b2partsgenerator('phase') |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
499 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
|
500 """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
|
501 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
|
502 return |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
503 b2caps = bundle2.bundle2caps(pushop.remote) |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
504 if not 'pushkey' in b2caps: |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
505 return |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
506 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
|
507 part2node = [] |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
508 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
|
509 for newremotehead in pushop.outdatedphases: |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
510 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
|
511 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
|
512 part.addparam('key', enc(newremotehead.hex())) |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
513 part.addparam('old', enc(str(phases.draft))) |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
514 part.addparam('new', enc(str(phases.public))) |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
515 part2node.append((part.id, newremotehead)) |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
516 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
|
517 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
|
518 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
|
519 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
|
520 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
|
521 msg = None |
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
522 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
|
523 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
|
524 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
|
525 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
|
526 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
|
527 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
|
528 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
|
529 |
22347
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
530 @b2partsgenerator('obsmarkers') |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
531 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
|
532 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
|
533 return |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
534 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
|
535 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
|
536 return |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
537 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
|
538 if pushop.outobsmarkers: |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
539 buildobsmarkerspart(bundler, pushop.outobsmarkers) |
7198cb9b56b9
push: use bundle2 to push obsmarkers when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22346
diff
changeset
|
540 |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
541 @b2partsgenerator('bookmarks') |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
542 def _pushb2bookmarks(pushop, bundler): |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
543 """handle phase push through bundle2""" |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
544 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
|
545 return |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
546 b2caps = bundle2.bundle2caps(pushop.remote) |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
547 if 'pushkey' not in b2caps: |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
548 return |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
549 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
|
550 part2book = [] |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
551 enc = pushkey.encode |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
552 for book, old, new in pushop.outbookmarks: |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
553 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
|
554 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
|
555 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
|
556 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
|
557 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
|
558 action = 'update' |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
559 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
|
560 action = 'export' |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
561 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
|
562 action = 'delete' |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
563 part2book.append((part.id, book, action)) |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
564 |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
565 |
22242
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
566 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
|
567 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
|
568 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
|
569 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
|
570 results = partrep['pushkey'] |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
571 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
|
572 if not results: |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
573 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
|
574 else: |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
575 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
|
576 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
|
577 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
|
578 else: |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
579 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
|
580 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
|
581 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
|
582 return handlereply |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
583 |
ed222ebd61be
push: add bookmarks to the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22240
diff
changeset
|
584 |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
585 def _pushbundle2(pushop): |
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
586 """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
|
587 |
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
588 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
|
589 evolve in the future.""" |
21644
17755dd8c509
bundle2: introduce a bundle2caps function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21643
diff
changeset
|
590 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
|
591 pushback = (pushop.trmanager |
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
592 and pushop.ui.configbool('experimental', 'bundle2.pushback')) |
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
593 |
21142
15039ce3e4a3
bundle2: include client capabilities in the pushed bundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21141
diff
changeset
|
594 # create reply capability |
23439
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
595 capsblob = bundle2.encodecaps(bundle2.getrepocaps(pushop.repo, |
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
596 allowpushback=pushback)) |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
597 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
|
598 replyhandlers = [] |
22017
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
599 for partgenname in b2partsgenorder: |
7986e99bb69a
push: rework the bundle2partsgenerators logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22016
diff
changeset
|
600 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
|
601 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
|
602 if callable(ret): |
dab31290c7eb
bundle2: only use callable return as reply handler
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21906
diff
changeset
|
603 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
|
604 # 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
|
605 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
|
606 return |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
607 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
|
608 try: |
08c84fd99aac
bundle2: catch UnknownPartError during local push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21181
diff
changeset
|
609 reply = pushop.remote.unbundle(stream, ['force'], 'push') |
21618
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21617
diff
changeset
|
610 except error.BundleValueError, exc: |
21182
08c84fd99aac
bundle2: catch UnknownPartError during local push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21181
diff
changeset
|
611 raise util.Abort('missing support for %s' % exc) |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
612 try: |
23439
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
613 trgetter = None |
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
614 if pushback: |
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
615 trgetter = pushop.trmanager.transaction |
743736fc7c41
bundle2-push: provide transaction to reply unbundler
Eric Sumner <ericsumner@fb.com>
parents:
23437
diff
changeset
|
616 op = bundle2.processbundle(pushop.repo, reply, trgetter) |
21618
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21617
diff
changeset
|
617 except error.BundleValueError, exc: |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
618 raise util.Abort('missing support for %s' % exc) |
21904
5fbccbcc07ea
bundle2-push: introduce a list of part generating functions
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21903
diff
changeset
|
619 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
|
620 rephand(op) |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
621 |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
622 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
|
623 """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
|
624 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
|
625 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
|
626 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
|
627 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
|
628 return |
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
629 pushop.repo.prepushoutgoinghooks(pushop.repo, |
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
630 pushop.remote, |
48f61cfb7576
bundle2-push: move changegroup push validation inside _pushb2ctx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21902
diff
changeset
|
631 pushop.outgoing) |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
632 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
|
633 unbundle = pushop.remote.capable('unbundle') |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
634 # 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
|
635 bundlecaps = None |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
636 # 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
|
637 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
|
638 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
|
639 # push everything, |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
640 # use the fast path, no race possible on push |
22390
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22354
diff
changeset
|
641 bundler = changegroup.cg1packer(pushop.repo, bundlecaps) |
20925
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20924
diff
changeset
|
642 cg = changegroup.getsubset(pushop.repo, |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20924
diff
changeset
|
643 outgoing, |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20924
diff
changeset
|
644 bundler, |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20924
diff
changeset
|
645 'push', |
5174c48ed8d8
localrepo: move the _changegroupsubset method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20924
diff
changeset
|
646 fastpath=True) |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
647 else: |
22390
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22354
diff
changeset
|
648 cg = changegroup.getlocalchangegroup(pushop.repo, 'push', outgoing, |
20928
91b47139d0cb
localrepo: move the getlocalbundle method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20925
diff
changeset
|
649 bundlecaps) |
20463
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
650 |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
651 # apply changegroup to remote |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
652 if unbundle: |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
653 # local repo finds heads on server, finds out what |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
654 # revs it must push. once revs transferred, if server |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
655 # finds it has different heads (someone else won |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
656 # commit/push race), server aborts. |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
657 if pushop.force: |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
658 remoteheads = ['force'] |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
659 else: |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
660 remoteheads = pushop.remoteheads |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
661 # ssh: return remote's addchangegroup() |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
662 # http: return remote's addchangegroup() or 0 for error |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
663 pushop.cgresult = pushop.remote.unbundle(cg, remoteheads, |
21761
b2dc026a9bd2
push: restore contents of HG_URL for hooks (issue4268)
Matt Mackall <mpm@selenic.com>
parents:
21259
diff
changeset
|
664 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
|
665 else: |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
666 # we return an integer indicating remote head count |
f1b532a310e4
push: move changeset push logic in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20462
diff
changeset
|
667 # change |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
668 pushop.cgresult = pushop.remote.addchangegroup(cg, 'push', |
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
669 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
|
670 |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
671 def _pushsyncphase(pushop): |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
672 """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
|
673 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
|
674 # even when we don't push, exchanging phase data is useful |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
675 remotephases = pushop.remote.listkeys('phases') |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
676 if (pushop.ui.configbool('ui', '_usedassubrepo', False) |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
677 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
|
678 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
|
679 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
|
680 # When: |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
681 # - 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
|
682 # - 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
|
683 # - 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
|
684 # - 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
|
685 # 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
|
686 # 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
|
687 # 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
|
688 # 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
|
689 remotephases = {'publishing': 'True'} |
21012
c827a0028e6f
exchange: restore truncated comment
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21005
diff
changeset
|
690 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
|
691 _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
|
692 # 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
|
693 else: |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
694 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
|
695 remotephases) |
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
696 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
|
697 ### 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
|
698 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
|
699 _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
|
700 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
|
701 _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
|
702 _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
|
703 ### 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
|
704 |
22615
4f14303e8954
push: rename `pushop.ret` to `pushop.cgresult`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22543
diff
changeset
|
705 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
|
706 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
|
707 # 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
|
708 return |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
709 outdated = pushop.outdatedphases |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
710 else: |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
711 outdated = pushop.fallbackoutdatedphases |
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
712 |
22020
311979b773fb
push: include phase push in the unified bundle2 push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22019
diff
changeset
|
713 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
|
714 |
22019
9fcf772f15ff
push: perform phases discovery before the push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22018
diff
changeset
|
715 # 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
|
716 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
|
717 # 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
|
718 for newremotehead in outdated: |
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
719 r = pushop.remote.pushkey('phases', |
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
720 newremotehead.hex(), |
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
721 str(phases.draft), |
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
722 str(phases.public)) |
2e65da5f80df
push: stop independent usage of bundle2 in syncphase (issue4454)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23082
diff
changeset
|
723 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
|
724 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
|
725 % newremotehead) |
20441
eca9d5375606
push: move phases synchronisation function in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20440
diff
changeset
|
726 |
20438
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
727 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
|
728 """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
|
729 if pushop.trmanager: |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
730 phases.advanceboundary(pushop.repo, |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
731 pushop.trmanager.transaction(), |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
732 phase, |
94e2862dbcfb
push: elevate phase transaction to cover entire operation
Eric Sumner <ericsumner@fb.com>
parents:
23436
diff
changeset
|
733 nodes) |
20438
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
734 else: |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
735 # 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
|
736 # 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
|
737 # applicable. |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
738 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
|
739 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
|
740 if actualmoves: |
2b5ab0d11327
push: move local phase move in a normal function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20437
diff
changeset
|
741 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
|
742 '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
|
743 |
20433
6af248474224
push: feed pushoperation object to _pushobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20432
diff
changeset
|
744 def _pushobsolete(pushop): |
20434
e009e59e4566
push: drop now outdated comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20433
diff
changeset
|
745 """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
|
746 if 'obsmarkers' in pushop.stepsdone: |
f1528ef123f4
push: use stepsdone for obsmarkers push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22035
diff
changeset
|
747 return |
20435
46ede894d5a4
push: move obsolescence related message into _pushobsolescence function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20434
diff
changeset
|
748 pushop.ui.debug('try to push obsolete markers to remote\n') |
20433
6af248474224
push: feed pushoperation object to _pushobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20432
diff
changeset
|
749 repo = pushop.repo |
6af248474224
push: feed pushoperation object to _pushobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20432
diff
changeset
|
750 remote = pushop.remote |
22036
f1528ef123f4
push: use stepsdone for obsmarkers push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22035
diff
changeset
|
751 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
|
752 if 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
|
753 rslts = [] |
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
|
754 remotedata = obsolete._pushkeyescape(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
|
755 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
|
756 # 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
|
757 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
|
758 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
|
759 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
|
760 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
|
761 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
|
762 |
20431
bebf8b8479f3
push: feed pushoperation object to _pushbookmark function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20352
diff
changeset
|
763 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
|
764 """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
|
765 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
|
766 return |
22240
d092f4b68fb6
push: use stepsdone to control bookmark push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22239
diff
changeset
|
767 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
|
768 ui = pushop.ui |
bebf8b8479f3
push: feed pushoperation object to _pushbookmark function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20352
diff
changeset
|
769 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
|
770 |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
771 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
|
772 action = 'update' |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
773 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
|
774 action = 'export' |
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
775 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
|
776 action = 'delete' |
22239
0688010ee38f
push: move bookmark discovery with other discovery steps
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22238
diff
changeset
|
777 if remote.pushkey('bookmarks', b, old, new): |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
778 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
|
779 else: |
22650
36952c91e6c3
push: prepare the issue of multiple kinds of messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22649
diff
changeset
|
780 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
|
781 # 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
|
782 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
|
783 pushop.bkresult = 1 |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
784 |
20472
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
785 class pulloperation(object): |
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
786 """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
|
787 |
23219
61cd79ac4b99
exchange: swap "push" for "pull" in pulloperation docstring
Mike Edgar <adgar@google.com>
parents:
23218
diff
changeset
|
788 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
|
789 |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
790 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
|
791 afterward. |
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
792 """ |
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
793 |
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
794 def __init__(self, repo, remote, heads=None, force=False, bookmarks=()): |
20596
004a1744088d
exchange: fix docs for pulloperation
Siddharth Agarwal <sid0@fb.com>
parents:
20489
diff
changeset
|
795 # repo we pull into |
20472
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
796 self.repo = repo |
20596
004a1744088d
exchange: fix docs for pulloperation
Siddharth Agarwal <sid0@fb.com>
parents:
20489
diff
changeset
|
797 # 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
|
798 self.remote = remote |
20474
c9bceafc61be
pull: move `heads` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20473
diff
changeset
|
799 # 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
|
800 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
|
801 # bookmark pulled explicitly |
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
802 self.explicitbookmarks = bookmarks |
20475
b79b405583af
pull: move `force` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20474
diff
changeset
|
803 # do we force pull? |
b79b405583af
pull: move `force` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20474
diff
changeset
|
804 self.force = force |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
805 # transaction manager |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
806 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
|
807 # 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
|
808 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
|
809 # 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
|
810 self.rheads = None |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
811 # 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
|
812 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
|
813 # remote bookmarks data |
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
814 self.remotebookmarks = None |
21024
7731a2281cf0
spelling: fixes from spell checker
Mads Kiilerich <madski@unity3d.com>
parents:
21012
diff
changeset
|
815 # 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
|
816 self.cgresult = None |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
817 # list of step already done |
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
818 self.stepsdone = set() |
20487
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
819 |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
820 @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
|
821 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
|
822 """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
|
823 # 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
|
824 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
|
825 # 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
|
826 # 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
|
827 c = set(self.common) |
09e7118715eb
pull: prevent duplicated entry in `op.pulledsubset`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20596
diff
changeset
|
828 ret = list(self.common) |
09e7118715eb
pull: prevent duplicated entry in `op.pulledsubset`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20596
diff
changeset
|
829 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
|
830 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
|
831 ret.append(n) |
09e7118715eb
pull: prevent duplicated entry in `op.pulledsubset`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20596
diff
changeset
|
832 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
|
833 else: |
f715cc0b5107
pull: make pulled subset a propertycache of the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20486
diff
changeset
|
834 # 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
|
835 # 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
|
836 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
|
837 |
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
838 def gettransaction(self): |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
839 # deprecated; talk to trmanager directly |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
840 return self.trmanager.transaction() |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
841 |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
842 class transactionmanager(object): |
23543
4dd8a6a1240d
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23439
diff
changeset
|
843 """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
|
844 |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
845 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
|
846 closing the transaction.""" |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
847 def __init__(self, repo, source, url): |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
848 self.repo = repo |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
849 self.source = source |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
850 self.url = url |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
851 self._tr = None |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
852 |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
853 def transaction(self): |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
854 """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
|
855 if not self._tr: |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
856 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
|
857 self._tr = self.repo.transaction(trname) |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
858 self._tr.hookargs['source'] = self.source |
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
859 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
|
860 return self._tr |
2607a21bb40b
pull: move transaction logic into the pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20476
diff
changeset
|
861 |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
862 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
|
863 """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
|
864 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
|
865 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
|
866 |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
867 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
|
868 """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
|
869 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
|
870 self._tr.release() |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
871 |
22645
6e431e1635b6
pull: move bookmark movements inside the `exchange.pull`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22628
diff
changeset
|
872 def pull(repo, remote, heads=None, force=False, bookmarks=()): |
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
873 pullop = pulloperation(repo, remote, heads, force, bookmarks=bookmarks) |
20473
1516daaca632
pull: move `remote` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20472
diff
changeset
|
874 if pullop.remote.local(): |
1516daaca632
pull: move `remote` argument into pull object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20472
diff
changeset
|
875 missing = set(pullop.remote.requirements) - pullop.repo.supported |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
876 if missing: |
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
877 msg = _("required features are not" |
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
878 " supported in the destination:" |
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
879 " %s") % (', '.join(sorted(missing))) |
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
880 raise util.Abort(msg) |
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
881 |
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
882 pullop.remotebookmarks = remote.listkeys('bookmarks') |
20472
b97a453b8c27
pull: introduce a pulloperation object
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20469
diff
changeset
|
883 lock = pullop.repo.lock() |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
884 try: |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
885 pullop.trmanager = transactionmanager(repo, 'pull', remote.url()) |
20900
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
886 _pulldiscovery(pullop) |
24650
b83a8f512a80
exchange: introduce a '_canusebundle2' function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24649
diff
changeset
|
887 if _canusebundle2(pullop): |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
888 _pullbundle2(pullop) |
22653
d94f5bec9c8e
pull: perform the todostep inside functions handling old way of pulling
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22651
diff
changeset
|
889 _pullchangeset(pullop) |
d94f5bec9c8e
pull: perform the todostep inside functions handling old way of pulling
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22651
diff
changeset
|
890 _pullphase(pullop) |
22655
f48ac29c2a9e
pull: retrieve bookmarks before obsmarkers
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22654
diff
changeset
|
891 _pullbookmarks(pullop) |
22653
d94f5bec9c8e
pull: perform the todostep inside functions handling old way of pulling
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22651
diff
changeset
|
892 _pullobsolete(pullop) |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
893 pullop.trmanager.close() |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
894 finally: |
23436
52db731b964d
pull: extract transaction logic into separate object
Eric Sumner <ericsumner@fb.com>
parents:
23382
diff
changeset
|
895 pullop.trmanager.release() |
20469
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
896 lock.release() |
6b4c789d618d
exchange: extract pull function from localrepo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20468
diff
changeset
|
897 |
22693
68439b154063
exchange: have `pull` return the pulloperation object
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22666
diff
changeset
|
898 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
|
899 |
22936
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
900 # 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
|
901 pulldiscoveryorder = [] |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
902 |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
903 # Mapping between step name and function |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
904 # |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
905 # 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
|
906 pulldiscoverymapping = {} |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
907 |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
908 def pulldiscovery(stepname): |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
909 """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
|
910 |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
911 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
|
912 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
|
913 may matter). |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
914 |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
915 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
|
916 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
|
917 def dec(func): |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
918 assert stepname not in pulldiscoverymapping |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
919 pulldiscoverymapping[stepname] = func |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
920 pulldiscoveryorder.append(stepname) |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
921 return func |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
922 return dec |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
923 |
20900
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
924 def _pulldiscovery(pullop): |
22936
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
925 """Run all discovery steps""" |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
926 for stepname in pulldiscoveryorder: |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
927 step = pulldiscoverymapping[stepname] |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
928 step(pullop) |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
929 |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
930 @pulldiscovery('changegroup') |
dae236906fb2
pull: make discovery phase extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22693
diff
changeset
|
931 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
|
932 """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
|
933 |
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
934 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
|
935 at some point.""" |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
936 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
|
937 pullop.remote, |
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
938 heads=pullop.heads, |
cb37fb91bc5a
pull: put discovery step in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20899
diff
changeset
|
939 force=pullop.force) |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
940 common, fetch, rheads = tmp |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
941 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
|
942 if fetch and rheads: |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
943 # If a remote heads in filtered locally, lets drop it from the unknown |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
944 # remote heads and put in back in common. |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
945 # |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
946 # 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
|
947 # 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
|
948 # 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
|
949 # 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
|
950 # |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
951 # 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
|
952 # 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
|
953 scommon = set(common) |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
954 filteredrheads = [] |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
955 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
|
956 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
|
957 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
|
958 common.append(n) |
23848
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
959 else: |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
960 filteredrheads.append(n) |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
961 if not filteredrheads: |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
962 fetch = [] |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
963 rheads = filteredrheads |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
964 pullop.common = common |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
965 pullop.fetch = fetch |
c5456b64eb07
discovery: run discovery on filtered repository
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23591
diff
changeset
|
966 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
|
967 |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
968 def _pullbundle2(pullop): |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
969 """pull data using bundle2 |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
970 |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
971 For now, the only supported data are changegroup.""" |
21658
0696ca0a685b
pull: when remote supports it, pull phase data alongside changesets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21657
diff
changeset
|
972 remotecaps = bundle2.bundle2caps(pullop.remote) |
21645
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
973 kwargs = {'bundlecaps': caps20to10(pullop.repo)} |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
974 # pulling changegroup |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
975 pullop.stepsdone.add('changegroup') |
21259
ab5040cd5749
bundle2: fix bundle2 pulling all revs on empty pulls
Durham Goode <durham@fb.com>
parents:
21258
diff
changeset
|
976 |
ab5040cd5749
bundle2: fix bundle2 pulling all revs on empty pulls
Durham Goode <durham@fb.com>
parents:
21258
diff
changeset
|
977 kwargs['common'] = pullop.common |
ab5040cd5749
bundle2: fix bundle2 pulling all revs on empty pulls
Durham Goode <durham@fb.com>
parents:
21258
diff
changeset
|
978 kwargs['heads'] = pullop.heads or pullop.rheads |
22352
dc371d1f0de1
pull: use the "cg" argument when pulling a bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22350
diff
changeset
|
979 kwargs['cg'] = pullop.fetch |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
980 if 'listkeys' in remotecaps: |
22656
c9276945eba3
pull: retrieve bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22655
diff
changeset
|
981 kwargs['listkeys'] = ['phase', 'bookmarks'] |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
982 if not pullop.fetch: |
21258
71931b789424
exchange: fix bad indentation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21257
diff
changeset
|
983 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
|
984 pullop.cgresult = 0 |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
985 else: |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
986 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
|
987 pullop.repo.ui.status(_("requesting all changes\n")) |
22953
b1d694d3975e
obsolete: add exchange option
Durham Goode <durham@fb.com>
parents:
22937
diff
changeset
|
988 if obsolete.isenabled(pullop.repo, obsolete.exchangeopt): |
22354
a89add6c6b2f
bundle2: pull obsmarkers relevant to the pulled set through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22353
diff
changeset
|
989 remoteversions = bundle2.obsmarkersversion(remotecaps) |
a89add6c6b2f
bundle2: pull obsmarkers relevant to the pulled set through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22353
diff
changeset
|
990 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
|
991 kwargs['obsmarkers'] = True |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
992 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
|
993 _pullbundle2extraprepare(pullop, kwargs) |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
994 bundle = pullop.remote.getbundle('pull', **kwargs) |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
995 try: |
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
996 op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction) |
21618
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21617
diff
changeset
|
997 except error.BundleValueError, exc: |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
998 raise util.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
|
999 |
ab5040cd5749
bundle2: fix bundle2 pulling all revs on empty pulls
Durham Goode <durham@fb.com>
parents:
21258
diff
changeset
|
1000 if pullop.fetch: |
23890
7817059917d0
pullbundle2: extract addchangegroup result combining into its own function
Eric Sumner <ericsumner@fb.com>
parents:
23848
diff
changeset
|
1001 results = [cg['return'] for cg in op.records['changegroup']] |
7817059917d0
pullbundle2: extract addchangegroup result combining into its own function
Eric Sumner <ericsumner@fb.com>
parents:
23848
diff
changeset
|
1002 pullop.cgresult = changegroup.combineresults(results) |
20955
12f161f08d74
bundle2: allow pulling changegroups using bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20954
diff
changeset
|
1003 |
21658
0696ca0a685b
pull: when remote supports it, pull phase data alongside changesets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21657
diff
changeset
|
1004 # 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
|
1005 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
|
1006 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
|
1007 _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
|
1008 |
22656
c9276945eba3
pull: retrieve bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22655
diff
changeset
|
1009 # processing bookmark update |
c9276945eba3
pull: retrieve bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22655
diff
changeset
|
1010 for namespace, value in op.records['listkeys']: |
c9276945eba3
pull: retrieve bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22655
diff
changeset
|
1011 if namespace == 'bookmarks': |
c9276945eba3
pull: retrieve bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22655
diff
changeset
|
1012 pullop.remotebookmarks = value |
c9276945eba3
pull: retrieve bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22655
diff
changeset
|
1013 _pullbookmarks(pullop) |
c9276945eba3
pull: retrieve bookmarks through bundle2
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22655
diff
changeset
|
1014 |
21159
024f38f6d5f6
bundle2: allow extensions to extend the getbundle request
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21158
diff
changeset
|
1015 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
|
1016 """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
|
1017 pass |
024f38f6d5f6
bundle2: allow extensions to extend the getbundle request
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21158
diff
changeset
|
1018 |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1019 def _pullchangeset(pullop): |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1020 """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
|
1021 # 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
|
1022 # 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
|
1023 # rollback call |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1024 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
|
1025 return |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1026 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
|
1027 if not pullop.fetch: |
23217
2f12ac53b528
exchange: fix indentation in _pullchangeset
Mike Edgar <adgar@google.com>
parents:
23208
diff
changeset
|
1028 pullop.repo.ui.status(_("no changes found\n")) |
2f12ac53b528
exchange: fix indentation in _pullchangeset
Mike Edgar <adgar@google.com>
parents:
23208
diff
changeset
|
1029 pullop.cgresult = 0 |
2f12ac53b528
exchange: fix indentation in _pullchangeset
Mike Edgar <adgar@google.com>
parents:
23208
diff
changeset
|
1030 return |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1031 pullop.gettransaction() |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1032 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
|
1033 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
|
1034 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
|
1035 # 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
|
1036 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
|
1037 |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1038 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
|
1039 # 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
|
1040 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
|
1041 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
|
1042 elif pullop.heads is None: |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1043 cg = pullop.remote.changegroup(pullop.fetch, 'pull') |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1044 elif not 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
|
1045 raise util.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
|
1046 "other repository doesn't support " |
7bcf4adadd2d
exchange: fix indentation level
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21259
diff
changeset
|
1047 "changegroupsubset.")) |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1048 else: |
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1049 cg = pullop.remote.changegroupsubset(pullop.fetch, pullop.heads, 'pull') |
20933
d3775db748a0
localrepo: move the addchangegroup method in changegroup module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20928
diff
changeset
|
1050 pullop.cgresult = changegroup.addchangegroup(pullop.repo, cg, 'pull', |
20899
d62319f91cb7
pull: move the cgresult logic in _pullchangeset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20898
diff
changeset
|
1051 pullop.remote.url()) |
20489
7b5ec1c7e8e2
pull: move changeset pulling in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20488
diff
changeset
|
1052 |
20486
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1053 def _pullphase(pullop): |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1054 # 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
|
1055 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
|
1056 return |
21654
ddf9a00c1239
pull: split remote phases retrieval from actual application
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21645
diff
changeset
|
1057 remotephases = pullop.remote.listkeys('phases') |
ddf9a00c1239
pull: split remote phases retrieval from actual application
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21645
diff
changeset
|
1058 _pullapplyphases(pullop, remotephases) |
ddf9a00c1239
pull: split remote phases retrieval from actual application
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21645
diff
changeset
|
1059 |
ddf9a00c1239
pull: split remote phases retrieval from actual application
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21645
diff
changeset
|
1060 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
|
1061 """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
|
1062 if 'phases' in pullop.stepsdone: |
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1063 return |
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1064 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
|
1065 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
|
1066 if remotephases and not publishing: |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1067 # remote is new and unpublishing |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1068 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
|
1069 pullop.pulledsubset, |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1070 remotephases) |
22068
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1071 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
|
1072 else: |
0c469df6e914
pull: move phases synchronisation in its own function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20485
diff
changeset
|
1073 # 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
|
1074 # 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
|
1075 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
|
1076 dheads = [] |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1077 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
|
1078 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
|
1079 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
|
1080 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
|
1081 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
|
1082 |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1083 # 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
|
1084 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
|
1085 if pheads: |
22069
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22068
diff
changeset
|
1086 tr = pullop.gettransaction() |
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22068
diff
changeset
|
1087 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
|
1088 |
d34058dd3246
pull: pre-filter remote phases before moving local ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22059
diff
changeset
|
1089 # 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
|
1090 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
|
1091 if dheads: |
22069
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22068
diff
changeset
|
1092 tr = pullop.gettransaction() |
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22068
diff
changeset
|
1093 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
|
1094 |
22654
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1095 def _pullbookmarks(pullop): |
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1096 """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
|
1097 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
|
1098 return |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1099 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
|
1100 repo = pullop.repo |
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1101 remotebookmarks = pullop.remotebookmarks |
02e0a574bcd3
pull: move bookmark pulling into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22653
diff
changeset
|
1102 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
|
1103 pullop.remote.url(), |
22666
0f8120c1ecf5
pull: perform bookmark updates in the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22658
diff
changeset
|
1104 pullop.gettransaction, |
22658
a8f0d8e4c80a
pull: gather explicit bookmark pulls with bookmark updates
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22656
diff
changeset
|
1105 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
|
1106 |
20478
80628d4069be
push: feed pulloperation object to _pullobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20477
diff
changeset
|
1107 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
|
1108 """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
|
1109 |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1110 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
|
1111 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
|
1112 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
|
1113 |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1114 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
|
1115 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
|
1116 return |
22937
92bf9abc4deb
pull: use `stepsdone` instead of `todosteps`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22936
diff
changeset
|
1117 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
|
1118 tr = None |
22953
b1d694d3975e
obsolete: add exchange option
Durham Goode <durham@fb.com>
parents:
22937
diff
changeset
|
1119 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
|
1120 pullop.repo.ui.debug('fetching remote obsolete markers\n') |
80628d4069be
push: feed pulloperation object to _pullobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20477
diff
changeset
|
1121 remoteobs = pullop.remote.listkeys('obsolete') |
20476
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1122 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
|
1123 tr = pullop.gettransaction() |
20476
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1124 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
|
1125 if key.startswith('dump'): |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1126 data = base85.b85decode(remoteobs[key]) |
20478
80628d4069be
push: feed pulloperation object to _pullobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20477
diff
changeset
|
1127 pullop.repo.obsstore.mergemarkers(tr, data) |
80628d4069be
push: feed pulloperation object to _pullobsolete function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20477
diff
changeset
|
1128 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
|
1129 return tr |
1180c6ec5695
pull: move obsolescence marker exchange in the exchange module
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20475
diff
changeset
|
1130 |
21645
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
1131 def caps20to10(repo): |
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
1132 """return a set with appropriate options to use bundle20 during getbundle""" |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
1133 caps = set(['HG20']) |
22342
262c5cc126c1
bundle2: introduce a `getrepocaps` to retrieve the bundle2 caps of a repo
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22341
diff
changeset
|
1134 capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo)) |
21645
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
1135 caps.add('bundle2=' + urllib.quote(capsblob)) |
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
1136 return caps |
aed14bb165f3
bundle2: introduce a ``caps20to10`` function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21644
diff
changeset
|
1137 |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1138 # 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
|
1139 getbundle2partsorder = [] |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1140 |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1141 # Mapping between step name and function |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1142 # |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1143 # 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
|
1144 getbundle2partsmapping = {} |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1145 |
24732
8f70b529cb0c
bundle2: add an 'idx' argument to the 'getbundle2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24731
diff
changeset
|
1146 def getbundle2partsgenerator(stepname, idx=None): |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1147 """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
|
1148 |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1149 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
|
1150 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
|
1151 (this may matter). |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1152 |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1153 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
|
1154 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
|
1155 def dec(func): |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1156 assert stepname not in getbundle2partsmapping |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1157 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
|
1158 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
|
1159 getbundle2partsorder.append(stepname) |
8f70b529cb0c
bundle2: add an 'idx' argument to the 'getbundle2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24731
diff
changeset
|
1160 else: |
8f70b529cb0c
bundle2: add an 'idx' argument to the 'getbundle2partsgenerator'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24731
diff
changeset
|
1161 getbundle2partsorder.insert(idx, stepname) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1162 return func |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1163 return dec |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1164 |
21157
60ad2ea5b106
getbundle: pass arbitrary arguments all along the call chain
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21156
diff
changeset
|
1165 def getbundle(repo, source, heads=None, common=None, bundlecaps=None, |
60ad2ea5b106
getbundle: pass arbitrary arguments all along the call chain
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21156
diff
changeset
|
1166 **kwargs): |
20954
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1167 """return a full bundle (with potentially multiple kind of parts) |
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1168 |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
1169 Could be a bundle HG10 or a bundle HG20 depending on bundlecaps |
20954
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1170 passed. For now, the bundle can contain only changegroup, but this will |
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1171 changes when more part type will be available for bundle2. |
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1172 |
22390
e2806b8613ca
changegroup: rename bundle-related functions and classes
Sune Foldager <cryo@cyanite.org>
parents:
22354
diff
changeset
|
1173 This is different from changegroup.getchangegroup that only returns an HG10 |
20954
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1174 changegroup bundle. They may eventually get reunited in the future when we |
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1175 have a clearer idea of the API we what to query different data. |
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1176 |
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1177 The implementation is at a very early stage and will get massive rework |
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1178 when the API of bundle is refined. |
dba91f8060eb
bundle2: add an exchange.getbundle function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20933
diff
changeset
|
1179 """ |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1180 # 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
|
1181 usebundle2 = False |
2d15c59a001b
bundle2: detect bundle2 stream/request on /HG2./ instead of /HG2Y/
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24641
diff
changeset
|
1182 if bundlecaps is not None: |
2d15c59a001b
bundle2: detect bundle2 stream/request on /HG2./ instead of /HG2Y/
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24641
diff
changeset
|
1183 usebundle2 = util.any((cap.startswith('HG2') for cap in bundlecaps)) |
2d15c59a001b
bundle2: detect bundle2 stream/request on /HG2./ instead of /HG2Y/
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24641
diff
changeset
|
1184 if not usebundle2: |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1185 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
|
1186 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
|
1187 |
21656
36200dc6b3bd
getbundle: raise error if extra arguments are provided for bundle10
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21654
diff
changeset
|
1188 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
|
1189 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
|
1190 % ', '.join(sorted(kwargs.keys()))) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1191 return changegroup.getchangegroup(repo, source, heads=heads, |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1192 common=common, bundlecaps=bundlecaps) |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1193 |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1194 # bundle20 case |
21143
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
1195 b2caps = {} |
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
1196 for bcaps in bundlecaps: |
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
1197 if bcaps.startswith('bundle2='): |
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
1198 blob = urllib.unquote(bcaps[len('bundle2='):]) |
5bb5d4ba14e5
bundle2: transmit capabilities to getbundle during pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21142
diff
changeset
|
1199 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
|
1200 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
|
1201 |
23218
0e78ea8e592a
exchange: prepare kwargs for bundle2 part generation exactly once
Mike Edgar <adgar@google.com>
parents:
23217
diff
changeset
|
1202 kwargs['heads'] = heads |
0e78ea8e592a
exchange: prepare kwargs for bundle2 part generation exactly once
Mike Edgar <adgar@google.com>
parents:
23217
diff
changeset
|
1203 kwargs['common'] = common |
0e78ea8e592a
exchange: prepare kwargs for bundle2 part generation exactly once
Mike Edgar <adgar@google.com>
parents:
23217
diff
changeset
|
1204 |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1205 for name in getbundle2partsorder: |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1206 func = getbundle2partsmapping[name] |
22543
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
1207 func(bundler, repo, source, bundlecaps=bundlecaps, b2caps=b2caps, |
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
1208 **kwargs) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1209 |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1210 return util.chunkbuffer(bundler.getchunks()) |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1211 |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1212 @getbundle2partsgenerator('changegroup') |
22543
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
1213 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
|
1214 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
|
1215 """add a changegroup part to the requested bundle""" |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1216 cg = None |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1217 if kwargs.get('cg', True): |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1218 # build changegroup bundle here. |
23179
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1219 version = None |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
1220 cgversions = b2caps.get('changegroup') |
23208
f606e07fa148
bundle2: handle empty 'b2x:changegroup' value in push and pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23203
diff
changeset
|
1221 if not cgversions: # 3.1 and 3.2 ship with an empty value |
23179
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1222 cg = changegroup.getchangegroupraw(repo, source, heads=heads, |
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1223 common=common, |
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1224 bundlecaps=bundlecaps) |
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1225 else: |
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1226 cgversions = [v for v in cgversions if v in changegroup.packermap] |
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1227 if not cgversions: |
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1228 raise ValueError(_('no common changegroup version')) |
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1229 version = max(cgversions) |
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1230 cg = changegroup.getchangegroupraw(repo, source, heads=heads, |
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1231 common=common, |
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1232 bundlecaps=bundlecaps, |
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1233 version=version) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1234 |
21259
ab5040cd5749
bundle2: fix bundle2 pulling all revs on empty pulls
Durham Goode <durham@fb.com>
parents:
21258
diff
changeset
|
1235 if cg: |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
1236 part = bundler.newpart('changegroup', data=cg) |
23179
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1237 if version is not None: |
6bb9533fa8fa
getbundle: send highest changegroup format supported by both side
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23177
diff
changeset
|
1238 part.addparam('version', version) |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1239 |
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1240 @getbundle2partsgenerator('listkeys') |
22543
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
1241 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
|
1242 b2caps=None, **kwargs): |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1243 """add parts containing listkeys namespaces to the requested bundle""" |
21657
0ff44e06275d
getbundle: support of listkeys argument when bundle2 is used
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21656
diff
changeset
|
1244 listkeys = kwargs.get('listkeys', ()) |
0ff44e06275d
getbundle: support of listkeys argument when bundle2 is used
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21656
diff
changeset
|
1245 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
|
1246 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
|
1247 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
|
1248 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
|
1249 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
|
1250 |
22542
6b180a0c703e
bundle2: separate bundle10 and bundle2 cases in getbundle()
Mike Hommey <mh@glandium.org>
parents:
22541
diff
changeset
|
1251 @getbundle2partsgenerator('obsmarkers') |
22543
6a669d5a62b8
bundle2: remove heads and common arguments to getbundle parts generators
Mike Hommey <mh@glandium.org>
parents:
22542
diff
changeset
|
1252 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
|
1253 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
|
1254 """add an obsolescence markers part to the requested bundle""" |
22353
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
1255 if kwargs.get('obsmarkers', False): |
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
1256 if heads is None: |
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
1257 heads = repo.heads() |
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
1258 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
|
1259 markers = repo.obsstore.relevantmarkers(subset) |
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
1260 buildobsmarkerspart(bundler, markers) |
47e3420ae889
getbundle: add `obsmarkers` argument to getbundle
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22352
diff
changeset
|
1261 |
20967
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
1262 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
|
1263 """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
|
1264 |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
1265 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
|
1266 """ |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
1267 heads = repo.heads() |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
1268 heads_hash = util.sha1(''.join(sorted(heads))).digest() |
984850270acb
unbundle: extract checkheads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20956
diff
changeset
|
1269 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
|
1270 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
|
1271 # 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
|
1272 # were transferring data |
21184
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21182
diff
changeset
|
1273 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
|
1274 '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
|
1275 |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1276 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
|
1277 """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
|
1278 |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1279 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
|
1280 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
|
1281 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
|
1282 |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1283 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
|
1284 r = 0 |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1285 # need a transaction when processing a bundle2 stream |
24752
5640efd1b160
unbundle: acquire 'wlock' when processing bundle2 (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24738
diff
changeset
|
1286 wlock = lock = tr = None |
24847
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
1287 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
|
1288 # quick fix for output mismatch with bundle2 in 3.4 |
e530cde6d115
bundle2: disable ouput capture unless we use http (issue4613 issue4615)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24851
diff
changeset
|
1289 captureoutput = repo.ui.configbool('experimental', 'bundle2-output-capture', |
e530cde6d115
bundle2: disable ouput capture unless we use http (issue4613 issue4615)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24851
diff
changeset
|
1290 False) |
e530cde6d115
bundle2: disable ouput capture unless we use http (issue4613 issue4615)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24851
diff
changeset
|
1291 if url.startswith('remote:http:') or url.startswith('remote:https:'): |
e530cde6d115
bundle2: disable ouput capture unless we use http (issue4613 issue4615)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24851
diff
changeset
|
1292 captureoutput = True |
20968
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1293 try: |
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1294 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
|
1295 # push can proceed |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1296 if util.safehasattr(cg, 'params'): |
24795
f9aa4cb8f2dd
bundle2: store the salvaged output on the exception object
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24754
diff
changeset
|
1297 r = None |
21187
bcfd44abad93
bundle2: gracefully handle hook abort
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
1298 try: |
24752
5640efd1b160
unbundle: acquire 'wlock' when processing bundle2 (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24738
diff
changeset
|
1299 wlock = repo.wlock() |
5640efd1b160
unbundle: acquire 'wlock' when processing bundle2 (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24738
diff
changeset
|
1300 lock = repo.lock() |
24738
457e26da029b
bundle2: use unbundle source as transaction name
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24732
diff
changeset
|
1301 tr = repo.transaction(source) |
22971
3fe571c74b27
changegroup: store source and url in the `hookargs` dict
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22961
diff
changeset
|
1302 tr.hookargs['source'] = source |
3fe571c74b27
changegroup: store source and url in the `hookargs` dict
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22961
diff
changeset
|
1303 tr.hookargs['url'] = url |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24650
diff
changeset
|
1304 tr.hookargs['bundle2'] = '1' |
24878
e530cde6d115
bundle2: disable ouput capture unless we use http (issue4613 issue4615)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24851
diff
changeset
|
1305 op = bundle2.bundleoperation(repo, lambda: tr, |
e530cde6d115
bundle2: disable ouput capture unless we use http (issue4613 issue4615)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24851
diff
changeset
|
1306 captureoutput=captureoutput) |
24851
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
1307 try: |
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
1308 r = bundle2.processbundle(repo, cg, op=op) |
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
1309 finally: |
df0ce98c882f
bundle2: also save output when error happens during part processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24850
diff
changeset
|
1310 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
|
1311 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
|
1312 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
|
1313 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
|
1314 r.newpart('output', data=output, mandatory=False) |
23222
6b7e60fb0b38
exchange: use the postclose API on transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23219
diff
changeset
|
1315 tr.close() |
21187
bcfd44abad93
bundle2: gracefully handle hook abort
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
1316 except Exception, exc: |
bcfd44abad93
bundle2: gracefully handle hook abort
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
1317 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
|
1318 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
|
1319 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
|
1320 def recordout(output): |
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
1321 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
|
1322 mandatory=False) |
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
1323 parts.append(part) |
21187
bcfd44abad93
bundle2: gracefully handle hook abort
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
1324 raise |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1325 else: |
24752
5640efd1b160
unbundle: acquire 'wlock' when processing bundle2 (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24738
diff
changeset
|
1326 lock = repo.lock() |
21061
62d35f251c60
bundle2: allow using bundle2 for push
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21043
diff
changeset
|
1327 r = changegroup.addchangegroup(repo, cg, source, url) |
20968
33d5fdd9bd99
unbundle: extract the core logic in another function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20967
diff
changeset
|
1328 finally: |
24752
5640efd1b160
unbundle: acquire 'wlock' when processing bundle2 (BC) (issue4596)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24738
diff
changeset
|
1329 lockmod.release(tr, lock, wlock) |
24847
b705e5ab3b07
bundle2: capture transaction rollback message output (issue4614)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24795
diff
changeset
|
1330 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
|
1331 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
|
1332 return r |