Show More
@@ -0,0 +1,344 | |||
|
1 | Testing the case when there is no infinitepush extension present on the client | |
|
2 | side and the server routes each push to bundlestore. This case is very much | |
|
3 | similar to CI use case. | |
|
4 | ||
|
5 | Setup | |
|
6 | ----- | |
|
7 | ||
|
8 | $ . "$TESTDIR/library-infinitepush.sh" | |
|
9 | $ cat >> $HGRCPATH <<EOF | |
|
10 | > [alias] | |
|
11 | > glog = log -GT "{rev}:{node|short} {desc}\n{phase}" | |
|
12 | > EOF | |
|
13 | $ cp $HGRCPATH $TESTTMP/defaulthgrc | |
|
14 | $ hg init repo | |
|
15 | $ cd repo | |
|
16 | $ setupserver | |
|
17 | $ echo "pushtobundlestore = True" >> .hg/hgrc | |
|
18 | $ echo "[extensions]" >> .hg/hgrc | |
|
19 | $ echo "infinitepush=" >> .hg/hgrc | |
|
20 | $ echo initialcommit > initialcommit | |
|
21 | $ hg ci -Aqm "initialcommit" | |
|
22 | $ hg phase --public . | |
|
23 | ||
|
24 | $ cd .. | |
|
25 | $ hg clone repo client -q | |
|
26 | $ cd client | |
|
27 | ||
|
28 | Pushing a new commit from the client to the server | |
|
29 | ----------------------------------------------------- | |
|
30 | ||
|
31 | $ echo foobar > a | |
|
32 | $ hg ci -Aqm "added a" | |
|
33 | $ hg glog | |
|
34 | @ 1:6cb0989601f1 added a | |
|
35 | | draft | |
|
36 | o 0:67145f466344 initialcommit | |
|
37 | public | |
|
38 | ||
|
39 | $ hg push | |
|
40 | pushing to $TESTTMP/repo | |
|
41 | searching for changes | |
|
42 | storing changesets on the bundlestore | |
|
43 | pushing 1 commit: | |
|
44 | 6cb0989601f1 added a | |
|
45 | ||
|
46 | $ scratchnodes | |
|
47 | 6cb0989601f1fb5805238edfb16f3606713d9a0b a4c202c147a9c4bb91bbadb56321fc5f3950f7f2 | |
|
48 | ||
|
49 | Understanding how data is stored on the bundlestore in server | |
|
50 | ------------------------------------------------------------- | |
|
51 | ||
|
52 | There are two things, filebundlestore and index | |
|
53 | $ ls ../repo/.hg/scratchbranches | |
|
54 | filebundlestore | |
|
55 | index | |
|
56 | ||
|
57 | filebundlestore stores the bundles | |
|
58 | $ ls ../repo/.hg/scratchbranches/filebundlestore/a4/c2/ | |
|
59 | a4c202c147a9c4bb91bbadb56321fc5f3950f7f2 | |
|
60 | ||
|
61 | index/nodemap stores a map of node id and file in which bundle is stored in filebundlestore | |
|
62 | $ ls ../repo/.hg/scratchbranches/index/ | |
|
63 | nodemap | |
|
64 | $ ls ../repo/.hg/scratchbranches/index/nodemap/ | |
|
65 | 6cb0989601f1fb5805238edfb16f3606713d9a0b | |
|
66 | ||
|
67 | $ cd ../repo | |
|
68 | ||
|
69 | Checking that the commit was not applied to revlog on the server | |
|
70 | ------------------------------------------------------------------ | |
|
71 | ||
|
72 | $ hg glog | |
|
73 | @ 0:67145f466344 initialcommit | |
|
74 | public | |
|
75 | ||
|
76 | Applying the changeset from the bundlestore | |
|
77 | -------------------------------------------- | |
|
78 | ||
|
79 | $ hg unbundle .hg/scratchbranches/filebundlestore/a4/c2/a4c202c147a9c4bb91bbadb56321fc5f3950f7f2 | |
|
80 | adding changesets | |
|
81 | adding manifests | |
|
82 | adding file changes | |
|
83 | added 1 changesets with 1 changes to 1 files | |
|
84 | new changesets 6cb0989601f1 | |
|
85 | (run 'hg update' to get a working copy) | |
|
86 | ||
|
87 | $ hg glog | |
|
88 | o 1:6cb0989601f1 added a | |
|
89 | | public | |
|
90 | @ 0:67145f466344 initialcommit | |
|
91 | public | |
|
92 | ||
|
93 | Pushing more changesets from the local repo | |
|
94 | -------------------------------------------- | |
|
95 | ||
|
96 | $ cd ../client | |
|
97 | $ echo b > b | |
|
98 | $ hg ci -Aqm "added b" | |
|
99 | $ echo c > c | |
|
100 | $ hg ci -Aqm "added c" | |
|
101 | $ hg glog | |
|
102 | @ 3:bf8a6e3011b3 added c | |
|
103 | | draft | |
|
104 | o 2:eaba929e866c added b | |
|
105 | | draft | |
|
106 | o 1:6cb0989601f1 added a | |
|
107 | | public | |
|
108 | o 0:67145f466344 initialcommit | |
|
109 | public | |
|
110 | ||
|
111 | $ hg push | |
|
112 | pushing to $TESTTMP/repo | |
|
113 | searching for changes | |
|
114 | storing changesets on the bundlestore | |
|
115 | pushing 2 commits: | |
|
116 | eaba929e866c added b | |
|
117 | bf8a6e3011b3 added c | |
|
118 | ||
|
119 | Checking that changesets are not applied on the server | |
|
120 | ------------------------------------------------------ | |
|
121 | ||
|
122 | $ hg glog -R ../repo | |
|
123 | o 1:6cb0989601f1 added a | |
|
124 | | public | |
|
125 | @ 0:67145f466344 initialcommit | |
|
126 | public | |
|
127 | ||
|
128 | Both of the new changesets are stored in a single bundle-file | |
|
129 | $ scratchnodes | |
|
130 | 6cb0989601f1fb5805238edfb16f3606713d9a0b a4c202c147a9c4bb91bbadb56321fc5f3950f7f2 | |
|
131 | bf8a6e3011b345146bbbedbcb1ebd4837571492a ee41a41cefb7817cbfb235b4f6e9f27dbad6ca1f | |
|
132 | eaba929e866c59bc9a6aada5a9dd2f6990db83c0 ee41a41cefb7817cbfb235b4f6e9f27dbad6ca1f | |
|
133 | ||
|
134 | Pushing more changesets to the server | |
|
135 | ------------------------------------- | |
|
136 | ||
|
137 | $ echo d > d | |
|
138 | $ hg ci -Aqm "added d" | |
|
139 | $ echo e > e | |
|
140 | $ hg ci -Aqm "added e" | |
|
141 | ||
|
142 | XXX: we should have pushed only the parts which are not in bundlestore | |
|
143 | $ hg push | |
|
144 | pushing to $TESTTMP/repo | |
|
145 | searching for changes | |
|
146 | storing changesets on the bundlestore | |
|
147 | pushing 4 commits: | |
|
148 | eaba929e866c added b | |
|
149 | bf8a6e3011b3 added c | |
|
150 | 1bb96358eda2 added d | |
|
151 | b4e4bce66051 added e | |
|
152 | ||
|
153 | Sneak peek into the bundlestore at the server | |
|
154 | $ scratchnodes | |
|
155 | 1bb96358eda285b536c6d1c66846a7cdb2336cea 57e00c0d4f26e2a2a72b751b63d9abc4f3eb28e7 | |
|
156 | 6cb0989601f1fb5805238edfb16f3606713d9a0b a4c202c147a9c4bb91bbadb56321fc5f3950f7f2 | |
|
157 | b4e4bce660512ad3e71189e14588a70ac8e31fef 57e00c0d4f26e2a2a72b751b63d9abc4f3eb28e7 | |
|
158 | bf8a6e3011b345146bbbedbcb1ebd4837571492a 57e00c0d4f26e2a2a72b751b63d9abc4f3eb28e7 | |
|
159 | eaba929e866c59bc9a6aada5a9dd2f6990db83c0 57e00c0d4f26e2a2a72b751b63d9abc4f3eb28e7 | |
|
160 | ||
|
161 | Checking if `hg pull` pulls something or `hg incoming` shows something | |
|
162 | ----------------------------------------------------------------------- | |
|
163 | ||
|
164 | $ hg incoming | |
|
165 | comparing with $TESTTMP/repo | |
|
166 | searching for changes | |
|
167 | no changes found | |
|
168 | [1] | |
|
169 | ||
|
170 | $ hg pull | |
|
171 | pulling from $TESTTMP/repo | |
|
172 | searching for changes | |
|
173 | no changes found | |
|
174 | ||
|
175 | Checking storage of phase information with the bundle on bundlestore | |
|
176 | --------------------------------------------------------------------- | |
|
177 | ||
|
178 | creating a draft commit | |
|
179 | $ cat >> $HGRCPATH <<EOF | |
|
180 | > [phases] | |
|
181 | > publish = False | |
|
182 | > EOF | |
|
183 | $ echo f > f | |
|
184 | $ hg ci -Aqm "added f" | |
|
185 | $ hg glog -r '.^::' | |
|
186 | @ 6:9b42578d4447 added f | |
|
187 | | draft | |
|
188 | o 5:b4e4bce66051 added e | |
|
189 | | public | |
|
190 | ~ | |
|
191 | ||
|
192 | $ hg push | |
|
193 | pushing to $TESTTMP/repo | |
|
194 | searching for changes | |
|
195 | storing changesets on the bundlestore | |
|
196 | pushing 5 commits: | |
|
197 | eaba929e866c added b | |
|
198 | bf8a6e3011b3 added c | |
|
199 | 1bb96358eda2 added d | |
|
200 | b4e4bce66051 added e | |
|
201 | 9b42578d4447 added f | |
|
202 | ||
|
203 | XXX: the phase of 9b42578d4447 should not be changed here | |
|
204 | $ hg glog -r . | |
|
205 | @ 6:9b42578d4447 added f | |
|
206 | | public | |
|
207 | ~ | |
|
208 | ||
|
209 | applying the bundle on the server to check preservation of phase-information | |
|
210 | ||
|
211 | $ cd ../repo | |
|
212 | $ scratchnodes | |
|
213 | 1bb96358eda285b536c6d1c66846a7cdb2336cea 0a6e70ecd5b98d22382f69b93909f557ac6a9927 | |
|
214 | 6cb0989601f1fb5805238edfb16f3606713d9a0b a4c202c147a9c4bb91bbadb56321fc5f3950f7f2 | |
|
215 | 9b42578d44473575994109161430d65dd147d16d 0a6e70ecd5b98d22382f69b93909f557ac6a9927 | |
|
216 | b4e4bce660512ad3e71189e14588a70ac8e31fef 0a6e70ecd5b98d22382f69b93909f557ac6a9927 | |
|
217 | bf8a6e3011b345146bbbedbcb1ebd4837571492a 0a6e70ecd5b98d22382f69b93909f557ac6a9927 | |
|
218 | eaba929e866c59bc9a6aada5a9dd2f6990db83c0 0a6e70ecd5b98d22382f69b93909f557ac6a9927 | |
|
219 | ||
|
220 | $ hg unbundle .hg/scratchbranches/filebundlestore/0a/6e/0a6e70ecd5b98d22382f69b93909f557ac6a9927 | |
|
221 | adding changesets | |
|
222 | adding manifests | |
|
223 | adding file changes | |
|
224 | added 5 changesets with 5 changes to 5 files | |
|
225 | new changesets eaba929e866c:9b42578d4447 | |
|
226 | (run 'hg update' to get a working copy) | |
|
227 | ||
|
228 | $ hg glog | |
|
229 | o 6:9b42578d4447 added f | |
|
230 | | draft | |
|
231 | o 5:b4e4bce66051 added e | |
|
232 | | public | |
|
233 | o 4:1bb96358eda2 added d | |
|
234 | | public | |
|
235 | o 3:bf8a6e3011b3 added c | |
|
236 | | public | |
|
237 | o 2:eaba929e866c added b | |
|
238 | | public | |
|
239 | o 1:6cb0989601f1 added a | |
|
240 | | public | |
|
241 | @ 0:67145f466344 initialcommit | |
|
242 | public | |
|
243 | ||
|
244 | Checking storage of obsmarkers in the bundlestore | |
|
245 | -------------------------------------------------- | |
|
246 | ||
|
247 | enabling obsmarkers and rebase extension | |
|
248 | ||
|
249 | $ cat >> $HGRCPATH << EOF | |
|
250 | > [experimental] | |
|
251 | > evolution = all | |
|
252 | > [extensions] | |
|
253 | > rebase = | |
|
254 | > EOF | |
|
255 | ||
|
256 | $ cd ../client | |
|
257 | ||
|
258 | $ hg phase -r . --draft --force | |
|
259 | $ hg rebase -r 6 -d 3 | |
|
260 | rebasing 6:9b42578d4447 "added f" (tip) | |
|
261 | ||
|
262 | $ hg glog | |
|
263 | @ 7:99949238d9ac added f | |
|
264 | | draft | |
|
265 | | o 5:b4e4bce66051 added e | |
|
266 | | | public | |
|
267 | | o 4:1bb96358eda2 added d | |
|
268 | |/ public | |
|
269 | o 3:bf8a6e3011b3 added c | |
|
270 | | public | |
|
271 | o 2:eaba929e866c added b | |
|
272 | | public | |
|
273 | o 1:6cb0989601f1 added a | |
|
274 | | public | |
|
275 | o 0:67145f466344 initialcommit | |
|
276 | public | |
|
277 | ||
|
278 | $ hg push -f | |
|
279 | pushing to $TESTTMP/repo | |
|
280 | searching for changes | |
|
281 | storing changesets on the bundlestore | |
|
282 | pushing 1 commit: | |
|
283 | 99949238d9ac added f | |
|
284 | ||
|
285 | XXX: the phase should not have changed here | |
|
286 | $ hg glog -r . | |
|
287 | @ 7:99949238d9ac added f | |
|
288 | | public | |
|
289 | ~ | |
|
290 | ||
|
291 | Unbundling on server to see obsmarkers being applied | |
|
292 | ||
|
293 | $ cd ../repo | |
|
294 | ||
|
295 | $ scratchnodes | |
|
296 | 1bb96358eda285b536c6d1c66846a7cdb2336cea 0a6e70ecd5b98d22382f69b93909f557ac6a9927 | |
|
297 | 6cb0989601f1fb5805238edfb16f3606713d9a0b a4c202c147a9c4bb91bbadb56321fc5f3950f7f2 | |
|
298 | 99949238d9ac7f2424a33a46dface6f866afd059 090a24fe63f31d3b4bee714447f835c8c362ff57 | |
|
299 | 9b42578d44473575994109161430d65dd147d16d 0a6e70ecd5b98d22382f69b93909f557ac6a9927 | |
|
300 | b4e4bce660512ad3e71189e14588a70ac8e31fef 0a6e70ecd5b98d22382f69b93909f557ac6a9927 | |
|
301 | bf8a6e3011b345146bbbedbcb1ebd4837571492a 0a6e70ecd5b98d22382f69b93909f557ac6a9927 | |
|
302 | eaba929e866c59bc9a6aada5a9dd2f6990db83c0 0a6e70ecd5b98d22382f69b93909f557ac6a9927 | |
|
303 | ||
|
304 | $ hg glog | |
|
305 | o 6:9b42578d4447 added f | |
|
306 | | draft | |
|
307 | o 5:b4e4bce66051 added e | |
|
308 | | public | |
|
309 | o 4:1bb96358eda2 added d | |
|
310 | | public | |
|
311 | o 3:bf8a6e3011b3 added c | |
|
312 | | public | |
|
313 | o 2:eaba929e866c added b | |
|
314 | | public | |
|
315 | o 1:6cb0989601f1 added a | |
|
316 | | public | |
|
317 | @ 0:67145f466344 initialcommit | |
|
318 | public | |
|
319 | ||
|
320 | $ hg unbundle .hg/scratchbranches/filebundlestore/09/0a/090a24fe63f31d3b4bee714447f835c8c362ff57 | |
|
321 | adding changesets | |
|
322 | adding manifests | |
|
323 | adding file changes | |
|
324 | added 1 changesets with 0 changes to 1 files (+1 heads) | |
|
325 | 1 new obsolescence markers | |
|
326 | obsoleted 1 changesets | |
|
327 | new changesets 99949238d9ac | |
|
328 | (run 'hg heads' to see heads, 'hg merge' to merge) | |
|
329 | ||
|
330 | $ hg glog | |
|
331 | o 7:99949238d9ac added f | |
|
332 | | draft | |
|
333 | | o 5:b4e4bce66051 added e | |
|
334 | | | public | |
|
335 | | o 4:1bb96358eda2 added d | |
|
336 | |/ public | |
|
337 | o 3:bf8a6e3011b3 added c | |
|
338 | | public | |
|
339 | o 2:eaba929e866c added b | |
|
340 | | public | |
|
341 | o 1:6cb0989601f1 added a | |
|
342 | | public | |
|
343 | @ 0:67145f466344 initialcommit | |
|
344 | public |
@@ -72,6 +72,9 | |||
|
72 | 72 | # bundle for storage. Defaults to False. |
|
73 | 73 | storeallparts = True |
|
74 | 74 | |
|
75 | # routes each incoming push to the bundlestore. defaults to False | |
|
76 | pushtobundlestore = True | |
|
77 | ||
|
75 | 78 | [remotenames] |
|
76 | 79 | # Client-side option |
|
77 | 80 | # This option should be set only if remotenames extension is enabled. |
@@ -163,6 +166,9 configitem('scratchbranch', 'storepath', | |||
|
163 | 166 | configitem('infinitepush', 'branchpattern', |
|
164 | 167 | default='', |
|
165 | 168 | ) |
|
169 | configitem('infinitepush', 'pushtobundlestore', | |
|
170 | default=False, | |
|
171 | ) | |
|
166 | 172 | configitem('experimental', 'server-bundlestore-bookmark', |
|
167 | 173 | default='', |
|
168 | 174 | ) |
@@ -868,6 +874,56 def _getorcreateinfinitepushlogger(op): | |||
|
868 | 874 | logger = logger[0] |
|
869 | 875 | return logger |
|
870 | 876 | |
|
877 | def storetobundlestore(orig, repo, op, unbundler): | |
|
878 | """stores the incoming bundle coming from push command to the bundlestore | |
|
879 | instead of applying on the revlogs""" | |
|
880 | ||
|
881 | repo.ui.status(_("storing changesets on the bundlestore\n")) | |
|
882 | bundler = bundle2.bundle20(repo.ui) | |
|
883 | ||
|
884 | # processing each part and storing it in bundler | |
|
885 | with bundle2.partiterator(repo, op, unbundler) as parts: | |
|
886 | for part in parts: | |
|
887 | bundlepart = None | |
|
888 | if part.type == 'replycaps': | |
|
889 | # This configures the current operation to allow reply parts. | |
|
890 | bundle2._processpart(op, part) | |
|
891 | else: | |
|
892 | bundlepart = bundle2.bundlepart(part.type, data=part.read()) | |
|
893 | for key, value in part.params.iteritems(): | |
|
894 | bundlepart.addparam(key, value) | |
|
895 | ||
|
896 | # Certain parts require a response | |
|
897 | if part.type in ('pushkey', 'changegroup'): | |
|
898 | if op.reply is not None: | |
|
899 | rpart = op.reply.newpart('reply:%s' % part.type) | |
|
900 | rpart.addparam('in-reply-to', str(part.id), | |
|
901 | mandatory=False) | |
|
902 | rpart.addparam('return', '1', mandatory=False) | |
|
903 | ||
|
904 | op.records.add(part.type, { | |
|
905 | 'return': 1, | |
|
906 | }) | |
|
907 | if bundlepart: | |
|
908 | bundler.addpart(bundlepart) | |
|
909 | ||
|
910 | # storing the bundle in the bundlestore | |
|
911 | buf = util.chunkbuffer(bundler.getchunks()) | |
|
912 | fd, bundlefile = tempfile.mkstemp() | |
|
913 | try: | |
|
914 | try: | |
|
915 | fp = os.fdopen(fd, 'wb') | |
|
916 | fp.write(buf.read()) | |
|
917 | finally: | |
|
918 | fp.close() | |
|
919 | storebundle(op, {}, bundlefile) | |
|
920 | finally: | |
|
921 | try: | |
|
922 | os.unlink(bundlefile) | |
|
923 | except Exception: | |
|
924 | # we would rather see the original exception | |
|
925 | pass | |
|
926 | ||
|
871 | 927 | def processparts(orig, repo, op, unbundler): |
|
872 | 928 | |
|
873 | 929 | # make sure we don't wrap processparts in case of `hg unbundle` |
@@ -876,6 +932,10 def processparts(orig, repo, op, unbundl | |||
|
876 | 932 | if tr.names[0].startswith('unbundle'): |
|
877 | 933 | return orig(repo, op, unbundler) |
|
878 | 934 | |
|
935 | # this server routes each push to bundle store | |
|
936 | if repo.ui.configbool('infinitepush', 'pushtobundlestore'): | |
|
937 | return storetobundlestore(orig, repo, op, unbundler) | |
|
938 | ||
|
879 | 939 | if unbundler.params.get('infinitepush') != 'True': |
|
880 | 940 | return orig(repo, op, unbundler) |
|
881 | 941 |
General Comments 0
You need to be logged in to leave comments.
Login now