Show More
@@ -0,0 +1,261 b'' | |||
|
1 | Create an extension to test bundle2 with multiple changegroups | |
|
2 | ||
|
3 | $ cat > bundle2.py <<EOF | |
|
4 | > """ | |
|
5 | > """ | |
|
6 | > from mercurial import changegroup, exchange | |
|
7 | > | |
|
8 | > def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None, | |
|
9 | > b2caps=None, heads=None, common=None, | |
|
10 | > **kwargs): | |
|
11 | > # Create two changegroups given the common changesets and heads for the | |
|
12 | > # changegroup part we are being requested. Use the parent of each head | |
|
13 | > # in 'heads' as intermediate heads for the first changegroup. | |
|
14 | > intermediates = [repo[r].p1().node() for r in heads] | |
|
15 | > cg = changegroup.getchangegroup(repo, source, heads=intermediates, | |
|
16 | > common=common, bundlecaps=bundlecaps) | |
|
17 | > bundler.newpart('b2x:output', data='changegroup1') | |
|
18 | > bundler.newpart('b2x:changegroup', data=cg.getchunks()) | |
|
19 | > cg = changegroup.getchangegroup(repo, source, heads=heads, | |
|
20 | > common=common + intermediates, | |
|
21 | > bundlecaps=bundlecaps) | |
|
22 | > bundler.newpart('b2x:output', data='changegroup2') | |
|
23 | > bundler.newpart('b2x:changegroup', data=cg.getchunks()) | |
|
24 | > | |
|
25 | > def _pull(repo, *args, **kwargs): | |
|
26 | > pullop = _orig_pull(repo, *args, **kwargs) | |
|
27 | > repo.ui.write('pullop.cgresult is %d\n' % pullop.cgresult) | |
|
28 | > return pullop | |
|
29 | > | |
|
30 | > _orig_pull = exchange.pull | |
|
31 | > exchange.pull = _pull | |
|
32 | > exchange.getbundle2partsmapping['changegroup'] = _getbundlechangegrouppart | |
|
33 | > EOF | |
|
34 | ||
|
35 | $ cat >> $HGRCPATH << EOF | |
|
36 | > [experimental] | |
|
37 | > bundle2-exp=True | |
|
38 | > [ui] | |
|
39 | > logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline} | |
|
40 | > EOF | |
|
41 | ||
|
42 | Start with a simple repository with a single commit | |
|
43 | ||
|
44 | $ hg init repo | |
|
45 | $ cd repo | |
|
46 | $ cat > .hg/hgrc << EOF | |
|
47 | > [extensions] | |
|
48 | > bundle2=$TESTTMP/bundle2.py | |
|
49 | > EOF | |
|
50 | ||
|
51 | $ echo A > A | |
|
52 | $ hg commit -A -m A -q | |
|
53 | $ cd .. | |
|
54 | ||
|
55 | Clone | |
|
56 | ||
|
57 | $ hg clone -q repo clone | |
|
58 | ||
|
59 | Add two linear commits | |
|
60 | ||
|
61 | $ cd repo | |
|
62 | $ echo B > B | |
|
63 | $ hg commit -A -m B -q | |
|
64 | $ echo C > C | |
|
65 | $ hg commit -A -m C -q | |
|
66 | ||
|
67 | $ cd ../clone | |
|
68 | $ cat >> .hg/hgrc <<EOF | |
|
69 | > [hooks] | |
|
70 | > pretxnchangegroup = sh -c "python \"$TESTDIR/printenv.py\" pretxnchangegroup" | |
|
71 | > changegroup = sh -c "python \"$TESTDIR/printenv.py\" changegroup" | |
|
72 | > incoming = sh -c "python \"$TESTDIR/printenv.py\" incoming" | |
|
73 | > EOF | |
|
74 | ||
|
75 | Pull the new commits in the clone | |
|
76 | ||
|
77 | $ hg pull | |
|
78 | pulling from $TESTTMP/repo (glob) | |
|
79 | searching for changes | |
|
80 | remote: changegroup1 | |
|
81 | adding changesets | |
|
82 | adding manifests | |
|
83 | adding file changes | |
|
84 | added 1 changesets with 1 changes to 1 files | |
|
85 | pretxnchangegroup hook: HG_NODE=27547f69f25460a52fff66ad004e58da7ad3fb56 HG_PENDING=$TESTTMP/clone HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
86 | remote: changegroup2 | |
|
87 | adding changesets | |
|
88 | adding manifests | |
|
89 | adding file changes | |
|
90 | added 1 changesets with 1 changes to 1 files | |
|
91 | pretxnchangegroup hook: HG_NODE=f838bfaca5c7226600ebcfd84f3c3c13a28d3757 HG_PENDING=$TESTTMP/clone HG_PHASES_MOVED=1 HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
92 | changegroup hook: HG_NODE=27547f69f25460a52fff66ad004e58da7ad3fb56 HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
93 | incoming hook: HG_NODE=27547f69f25460a52fff66ad004e58da7ad3fb56 HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
94 | changegroup hook: HG_NODE=f838bfaca5c7226600ebcfd84f3c3c13a28d3757 HG_PHASES_MOVED=1 HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
95 | incoming hook: HG_NODE=f838bfaca5c7226600ebcfd84f3c3c13a28d3757 HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
96 | pullop.cgresult is 1 | |
|
97 | (run 'hg update' to get a working copy) | |
|
98 | $ hg update | |
|
99 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
100 | $ hg log -G | |
|
101 | @ 2:f838bfaca5c7 public test C | |
|
102 | | | |
|
103 | o 1:27547f69f254 public test B | |
|
104 | | | |
|
105 | o 0:4a2df7238c3b public test A | |
|
106 | ||
|
107 | Add more changesets with multiple heads to the original repository | |
|
108 | ||
|
109 | $ cd ../repo | |
|
110 | $ echo D > D | |
|
111 | $ hg commit -A -m D -q | |
|
112 | $ hg up -r 1 | |
|
113 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
|
114 | $ echo E > E | |
|
115 | $ hg commit -A -m E -q | |
|
116 | $ echo F > F | |
|
117 | $ hg commit -A -m F -q | |
|
118 | $ hg up -r 1 | |
|
119 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
|
120 | $ echo G > G | |
|
121 | $ hg commit -A -m G -q | |
|
122 | $ hg up -r 3 | |
|
123 | 2 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
|
124 | $ echo H > H | |
|
125 | $ hg commit -A -m H -q | |
|
126 | $ hg log -G | |
|
127 | @ 7:5cd59d311f65 draft test H | |
|
128 | | | |
|
129 | | o 6:1d14c3ce6ac0 draft test G | |
|
130 | | | | |
|
131 | | | o 5:7f219660301f draft test F | |
|
132 | | | | | |
|
133 | | | o 4:8a5212ebc852 draft test E | |
|
134 | | |/ | |
|
135 | o | 3:b3325c91a4d9 draft test D | |
|
136 | | | | |
|
137 | o | 2:f838bfaca5c7 draft test C | |
|
138 | |/ | |
|
139 | o 1:27547f69f254 draft test B | |
|
140 | | | |
|
141 | o 0:4a2df7238c3b draft test A | |
|
142 | ||
|
143 | New heads are reported during transfer and properly accounted for in | |
|
144 | pullop.cgresult | |
|
145 | ||
|
146 | $ cd ../clone | |
|
147 | $ hg pull | |
|
148 | pulling from $TESTTMP/repo (glob) | |
|
149 | searching for changes | |
|
150 | remote: changegroup1 | |
|
151 | adding changesets | |
|
152 | adding manifests | |
|
153 | adding file changes | |
|
154 | added 2 changesets with 2 changes to 2 files (+1 heads) | |
|
155 | pretxnchangegroup hook: HG_NODE=b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e HG_PENDING=$TESTTMP/clone HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
156 | remote: changegroup2 | |
|
157 | adding changesets | |
|
158 | adding manifests | |
|
159 | adding file changes | |
|
160 | added 3 changesets with 3 changes to 3 files (+1 heads) | |
|
161 | pretxnchangegroup hook: HG_NODE=7f219660301fe4c8a116f714df5e769695cc2b46 HG_PENDING=$TESTTMP/clone HG_PHASES_MOVED=1 HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
162 | changegroup hook: HG_NODE=b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
163 | incoming hook: HG_NODE=b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
164 | incoming hook: HG_NODE=8a5212ebc8527f9fb821601504794e3eb11a1ed3 HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
165 | changegroup hook: HG_NODE=7f219660301fe4c8a116f714df5e769695cc2b46 HG_PHASES_MOVED=1 HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
166 | incoming hook: HG_NODE=7f219660301fe4c8a116f714df5e769695cc2b46 HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
167 | incoming hook: HG_NODE=1d14c3ce6ac0582d2809220d33e8cd7a696e0156 HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
168 | incoming hook: HG_NODE=5cd59d311f6508b8e0ed28a266756c859419c9f1 HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
169 | pullop.cgresult is 3 | |
|
170 | (run 'hg heads' to see heads, 'hg merge' to merge) | |
|
171 | $ hg log -G | |
|
172 | o 7:5cd59d311f65 public test H | |
|
173 | | | |
|
174 | | o 6:1d14c3ce6ac0 public test G | |
|
175 | | | | |
|
176 | | | o 5:7f219660301f public test F | |
|
177 | | | | | |
|
178 | | | o 4:8a5212ebc852 public test E | |
|
179 | | |/ | |
|
180 | o | 3:b3325c91a4d9 public test D | |
|
181 | | | | |
|
182 | @ | 2:f838bfaca5c7 public test C | |
|
183 | |/ | |
|
184 | o 1:27547f69f254 public test B | |
|
185 | | | |
|
186 | o 0:4a2df7238c3b public test A | |
|
187 | ||
|
188 | Removing a head from the original repository by merging it | |
|
189 | ||
|
190 | $ cd ../repo | |
|
191 | $ hg merge -r 6 -q | |
|
192 | $ hg commit -m Merge | |
|
193 | $ echo I > I | |
|
194 | $ hg commit -A -m H -q | |
|
195 | $ hg log -G | |
|
196 | @ 9:9d18e5bd9ab0 draft test H | |
|
197 | | | |
|
198 | o 8:71bd7b46de72 draft test Merge | |
|
199 | |\ | |
|
200 | | o 7:5cd59d311f65 draft test H | |
|
201 | | | | |
|
202 | o | 6:1d14c3ce6ac0 draft test G | |
|
203 | | | | |
|
204 | | | o 5:7f219660301f draft test F | |
|
205 | | | | | |
|
206 | +---o 4:8a5212ebc852 draft test E | |
|
207 | | | | |
|
208 | | o 3:b3325c91a4d9 draft test D | |
|
209 | | | | |
|
210 | | o 2:f838bfaca5c7 draft test C | |
|
211 | |/ | |
|
212 | o 1:27547f69f254 draft test B | |
|
213 | | | |
|
214 | o 0:4a2df7238c3b draft test A | |
|
215 | ||
|
216 | Removed heads are reported during transfer and properly accounted for in | |
|
217 | pullop.cgresult | |
|
218 | ||
|
219 | $ cd ../clone | |
|
220 | $ hg pull | |
|
221 | pulling from $TESTTMP/repo (glob) | |
|
222 | searching for changes | |
|
223 | remote: changegroup1 | |
|
224 | adding changesets | |
|
225 | adding manifests | |
|
226 | adding file changes | |
|
227 | added 1 changesets with 0 changes to 0 files (-1 heads) | |
|
228 | pretxnchangegroup hook: HG_NODE=71bd7b46de72e69a32455bf88d04757d542e6cf4 HG_PENDING=$TESTTMP/clone HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
229 | remote: changegroup2 | |
|
230 | adding changesets | |
|
231 | adding manifests | |
|
232 | adding file changes | |
|
233 | added 1 changesets with 1 changes to 1 files | |
|
234 | pretxnchangegroup hook: HG_NODE=9d18e5bd9ab09337802595d49f1dad0c98df4d84 HG_PENDING=$TESTTMP/clone HG_PHASES_MOVED=1 HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
235 | changegroup hook: HG_NODE=71bd7b46de72e69a32455bf88d04757d542e6cf4 HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
236 | incoming hook: HG_NODE=71bd7b46de72e69a32455bf88d04757d542e6cf4 HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
237 | changegroup hook: HG_NODE=9d18e5bd9ab09337802595d49f1dad0c98df4d84 HG_PHASES_MOVED=1 HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
238 | incoming hook: HG_NODE=9d18e5bd9ab09337802595d49f1dad0c98df4d84 HG_SOURCE=bundle2 HG_URL=bundle2 | |
|
239 | pullop.cgresult is -2 | |
|
240 | (run 'hg update' to get a working copy) | |
|
241 | $ hg log -G | |
|
242 | o 9:9d18e5bd9ab0 public test H | |
|
243 | | | |
|
244 | o 8:71bd7b46de72 public test Merge | |
|
245 | |\ | |
|
246 | | o 7:5cd59d311f65 public test H | |
|
247 | | | | |
|
248 | o | 6:1d14c3ce6ac0 public test G | |
|
249 | | | | |
|
250 | | | o 5:7f219660301f public test F | |
|
251 | | | | | |
|
252 | +---o 4:8a5212ebc852 public test E | |
|
253 | | | | |
|
254 | | o 3:b3325c91a4d9 public test D | |
|
255 | | | | |
|
256 | | @ 2:f838bfaca5c7 public test C | |
|
257 | |/ | |
|
258 | o 1:27547f69f254 public test B | |
|
259 | | | |
|
260 | o 0:4a2df7238c3b public test A | |
|
261 |
@@ -944,8 +944,22 b' def _pullbundle2(pullop):' | |||
|
944 | 944 | raise util.Abort('missing support for %s' % exc) |
|
945 | 945 | |
|
946 | 946 | if pullop.fetch: |
|
947 | assert len(op.records['changegroup']) == 1 | |
|
948 | pullop.cgresult = op.records['changegroup'][0]['return'] | |
|
947 | changedheads = 0 | |
|
948 | pullop.cgresult = 1 | |
|
949 | for cg in op.records['changegroup']: | |
|
950 | ret = cg['return'] | |
|
951 | # If any changegroup result is 0, return 0 | |
|
952 | if ret == 0: | |
|
953 | pullop.cgresult = 0 | |
|
954 | break | |
|
955 | if ret < -1: | |
|
956 | changedheads += ret + 1 | |
|
957 | elif ret > 1: | |
|
958 | changedheads += ret - 1 | |
|
959 | if changedheads > 0: | |
|
960 | pullop.cgresult = 1 + changedheads | |
|
961 | elif changedheads < 0: | |
|
962 | pullop.cgresult = -1 + changedheads | |
|
949 | 963 | |
|
950 | 964 | # processing phases change |
|
951 | 965 | for namespace, value in op.records['listkeys']: |
General Comments 0
You need to be logged in to leave comments.
Login now