comparison tests/test-infinitepush.t @ 37187:03ff17a4bf53

infinitepush: move the extension to core from fb-hgext This patch moves the infinitepush extension from fb-hgext to core. The extension is used to store incoming bundles during a push in bundlestore rather than applying them to the revlog. The extension was copied from the repository revision at f27f094e91553d3cae5167c0b1c42ae940f888d5 and following changes were made: * added `from __future__ import absolute_import` where missing * fixed module imports to follow the core style * minor fixes for test-check-code.t * registered the configs * adding the testedwith value to match core's convention * removed double newlines to make test-check-commit.t happy * added one line doc about extension and marked it as experimental Only one test file test-infinitepush-bundlestore.t is moved to core and following changes are made to file: * remove dependency of library.sh * split the tests into two tests i.e. test-infinitepush.t and test-infinitepush-bundlestore.t * removed testing related to other facebook's extensions pushrebase, inhibit, fbamend library-infinitepush.sh is also copied from fb-hgext from the same revision and following changes are made: * change the path to infinitepush extension as it's in core with this patch * removed sql handling from the file as we are not testing that initially Currently at this revision, test-check-module-imports.t does not pass as there is import of a module from fb/hgext in one the of the file which will be removed in the next patch. This extension right now has a lot of things which we don't require in core like `--to`, `--create` flags to `hg bookmark`, logic related to remotenames extension and another facebook's extensions, custom bundle2parts which can be prevented by using bookmarks bundle part and also logic related to sql store which is probably we don't want initially. The next patches in this series will remove all the unwanted and unrequired things from the extension and will make this a nice one. The end goal is to have a very lighweight extension with no or very less wrapping on the client side. Differential Revision: https://phab.mercurial-scm.org/D2096
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 09 Feb 2018 13:39:15 +0530
parents
children 78c2e9418278
comparison
equal deleted inserted replaced
37186:6d43b39fbaa0 37187:03ff17a4bf53
1 Testing infinipush extension and the confi options provided by it
2
3 Setup
4
5 $ . "$TESTDIR/library-infinitepush.sh"
6 $ cp $HGRCPATH $TESTTMP/defaulthgrc
7 $ setupcommon
8 $ hg init repo
9 $ cd repo
10 $ setupserver
11 $ echo initialcommit > initialcommit
12 $ hg ci -Aqm "initialcommit"
13 $ hg phase --public .
14
15 $ cd ..
16 $ hg clone ssh://user@dummy/repo client -q
17
18 Create two heads. Push first head alone, then two heads together. Make sure that
19 multihead push works.
20 $ cd client
21 $ echo multihead1 > multihead1
22 $ hg add multihead1
23 $ hg ci -m "multihead1"
24 $ hg up null
25 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
26 $ echo multihead2 > multihead2
27 $ hg ci -Am "multihead2"
28 adding multihead2
29 created new head
30 $ hg push -r . --bundle-store
31 pushing to ssh://user@dummy/repo
32 searching for changes
33 remote: pushing 1 commit:
34 remote: ee4802bf6864 multihead2
35 $ hg push -r '1:2' --bundle-store
36 pushing to ssh://user@dummy/repo
37 searching for changes
38 remote: pushing 2 commits:
39 remote: bc22f9a30a82 multihead1
40 remote: ee4802bf6864 multihead2
41 $ scratchnodes
42 bc22f9a30a821118244deacbd732e394ed0b686c ab1bc557aa090a9e4145512c734b6e8a828393a5
43 ee4802bf6864326a6b3dcfff5a03abc2a0a69b8f ab1bc557aa090a9e4145512c734b6e8a828393a5
44
45 Create two new scratch bookmarks
46 $ hg up 0
47 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
48 $ echo scratchfirstpart > scratchfirstpart
49 $ hg ci -Am "scratchfirstpart"
50 adding scratchfirstpart
51 created new head
52 $ hg push -r . --to scratch/firstpart --create
53 pushing to ssh://user@dummy/repo
54 searching for changes
55 remote: pushing 1 commit:
56 remote: 176993b87e39 scratchfirstpart
57 $ hg up 0
58 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
59 $ echo scratchsecondpart > scratchsecondpart
60 $ hg ci -Am "scratchsecondpart"
61 adding scratchsecondpart
62 created new head
63 $ hg push -r . --to scratch/secondpart --create
64 pushing to ssh://user@dummy/repo
65 searching for changes
66 remote: pushing 1 commit:
67 remote: 8db3891c220e scratchsecondpart
68
69 Pull two bookmarks from the second client
70 $ cd ..
71 $ hg clone ssh://user@dummy/repo client2 -q
72 $ cd client2
73 $ hg pull -B scratch/firstpart -B scratch/secondpart
74 pulling from ssh://user@dummy/repo
75 searching for changes
76 adding changesets
77 adding manifests
78 adding file changes
79 added 1 changesets with 1 changes to 1 files
80 adding changesets
81 adding manifests
82 adding file changes
83 added 1 changesets with 1 changes to 1 files (+1 heads)
84 new changesets * (glob)
85 (run 'hg heads' to see heads, 'hg merge' to merge)
86 $ hg log -r scratch/secondpart -T '{node}'
87 8db3891c220e216f6da214e8254bd4371f55efca (no-eol)
88 $ hg log -r scratch/firstpart -T '{node}'
89 176993b87e39bd88d66a2cccadabe33f0b346339 (no-eol)
90 Make two commits to the scratch branch
91
92 $ echo testpullbycommithash1 > testpullbycommithash1
93 $ hg ci -Am "testpullbycommithash1"
94 adding testpullbycommithash1
95 created new head
96 $ hg log -r '.' -T '{node}\n' > ../testpullbycommithash1
97 $ echo testpullbycommithash2 > testpullbycommithash2
98 $ hg ci -Aqm "testpullbycommithash2"
99 $ hg push -r . --to scratch/mybranch --create -q
100
101 Create third client and pull by commit hash.
102 Make sure testpullbycommithash2 has not fetched
103 $ cd ..
104 $ hg clone ssh://user@dummy/repo client3 -q
105 $ cd client3
106 $ hg pull -r `cat ../testpullbycommithash1`
107 pulling from ssh://user@dummy/repo
108 searching for changes
109 adding changesets
110 adding manifests
111 adding file changes
112 added 1 changesets with 1 changes to 1 files
113 new changesets 33910bfe6ffe
114 (run 'hg update' to get a working copy)
115 $ hg log -G -T '{desc} {phase} {bookmarks}'
116 o testpullbycommithash1 draft
117 |
118 @ initialcommit public
119
120 Make public commit in the repo and pull it.
121 Make sure phase on the client is public.
122 $ cd ../repo
123 $ echo publiccommit > publiccommit
124 $ hg ci -Aqm "publiccommit"
125 $ hg phase --public .
126 $ cd ../client3
127 $ hg pull
128 pulling from ssh://user@dummy/repo
129 searching for changes
130 adding changesets
131 adding manifests
132 adding file changes
133 added 1 changesets with 1 changes to 1 files (+1 heads)
134 new changesets a79b6597f322
135 (run 'hg heads' to see heads, 'hg merge' to merge)
136 $ hg log -G -T '{desc} {phase} {bookmarks} {node|short}'
137 o publiccommit public a79b6597f322
138 |
139 | o testpullbycommithash1 draft 33910bfe6ffe
140 |/
141 @ initialcommit public 67145f466344
142
143 $ hg up a79b6597f322
144 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
145 $ echo scratchontopofpublic > scratchontopofpublic
146 $ hg ci -Aqm "scratchontopofpublic"
147 $ hg push -r . --to scratch/scratchontopofpublic --create
148 pushing to ssh://user@dummy/repo
149 searching for changes
150 remote: pushing 1 commit:
151 remote: c70aee6da07d scratchontopofpublic
152 $ cd ../client2
153 $ hg pull -B scratch/scratchontopofpublic
154 pulling from ssh://user@dummy/repo
155 searching for changes
156 adding changesets
157 adding manifests
158 adding file changes
159 added 1 changesets with 1 changes to 1 files (+1 heads)
160 adding changesets
161 adding manifests
162 adding file changes
163 added 1 changesets with 1 changes to 1 files
164 new changesets a79b6597f322:c70aee6da07d
165 (run 'hg heads .' to see heads, 'hg merge' to merge)
166 $ hg log -r scratch/scratchontopofpublic -T '{phase}'
167 draft (no-eol)
168 Strip scratchontopofpublic commit and do hg update
169 $ hg log -r tip -T '{node}\n'
170 c70aee6da07d7cdb9897375473690df3a8563339
171 $ echo "[extensions]" >> .hg/hgrc
172 $ echo "strip=" >> .hg/hgrc
173 $ hg strip -q tip
174 $ hg up c70aee6da07d7cdb9897375473690df3a8563339
175 'c70aee6da07d7cdb9897375473690df3a8563339' does not exist locally - looking for it remotely...
176 pulling from ssh://user@dummy/repo
177 searching for changes
178 adding changesets
179 adding manifests
180 adding file changes
181 added 1 changesets with 1 changes to 1 files
182 new changesets c70aee6da07d
183 (run 'hg update' to get a working copy)
184 'c70aee6da07d7cdb9897375473690df3a8563339' found remotely
185 2 files updated, 0 files merged, 2 files removed, 0 files unresolved
186
187 Trying to pull from bad path
188 $ hg strip -q tip
189 $ hg --config paths.default=badpath up c70aee6da07d7cdb9897375473690df3a8563339
190 'c70aee6da07d7cdb9897375473690df3a8563339' does not exist locally - looking for it remotely...
191 pulling from $TESTTMP/client2/badpath (glob)
192 pull failed: repository $TESTTMP/client2/badpath not found
193 abort: unknown revision 'c70aee6da07d7cdb9897375473690df3a8563339'!
194 [255]
195
196 Strip commit and pull it using hg update with bookmark name
197 $ hg strip -q d8fde0ddfc96
198 $ hg book -d scratch/mybranch
199 $ hg up scratch/mybranch
200 'scratch/mybranch' does not exist locally - looking for it remotely...
201 pulling from ssh://user@dummy/repo
202 searching for changes
203 adding changesets
204 adding manifests
205 adding file changes
206 added 1 changesets with 1 changes to 2 files
207 new changesets d8fde0ddfc96
208 (run 'hg update' to get a working copy)
209 'scratch/mybranch' found remotely
210 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
211 (activating bookmark scratch/mybranch)
212 $ hg log -r scratch/mybranch -T '{node}'
213 d8fde0ddfc962183977f92d2bc52d303b8840f9d (no-eol)
214
215 Test debugfillinfinitepushmetadata
216 $ cd ../repo
217 $ hg debugfillinfinitepushmetadata
218 abort: nodes are not specified
219 [255]
220 $ hg debugfillinfinitepushmetadata --node randomnode
221 abort: node randomnode is not found
222 [255]
223 $ hg debugfillinfinitepushmetadata --node d8fde0ddfc962183977f92d2bc52d303b8840f9d
224 $ cat .hg/scratchbranches/index/nodemetadatamap/d8fde0ddfc962183977f92d2bc52d303b8840f9d
225 {"changed_files": {"testpullbycommithash2": {"adds": 1, "isbinary": false, "removes": 0, "status": "added"}}} (no-eol)
226
227 $ cd ../client
228 $ hg up d8fde0ddfc962183977f92d2bc52d303b8840f9d
229 'd8fde0ddfc962183977f92d2bc52d303b8840f9d' does not exist locally - looking for it remotely...
230 pulling from ssh://user@dummy/repo
231 searching for changes
232 adding changesets
233 adding manifests
234 adding file changes
235 added 2 changesets with 2 changes to 2 files (+1 heads)
236 new changesets 33910bfe6ffe:d8fde0ddfc96
237 (run 'hg heads .' to see heads, 'hg merge' to merge)
238 'd8fde0ddfc962183977f92d2bc52d303b8840f9d' found remotely
239 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
240 $ echo file > file
241 $ hg add file
242 $ hg rm testpullbycommithash2
243 $ hg ci -m 'add and rm files'
244 $ hg log -r . -T '{node}\n'
245 3edfe7e9089ab9f728eb8e0d0c62a5d18cf19239
246 $ hg cp file cpfile
247 $ hg mv file mvfile
248 $ hg ci -m 'cpfile and mvfile'
249 $ hg log -r . -T '{node}\n'
250 c7ac39f638c6b39bcdacf868fa21b6195670f8ae
251 $ hg push -r . --bundle-store
252 pushing to ssh://user@dummy/repo
253 searching for changes
254 remote: pushing 4 commits:
255 remote: 33910bfe6ffe testpullbycommithash1
256 remote: d8fde0ddfc96 testpullbycommithash2
257 remote: 3edfe7e9089a add and rm files
258 remote: c7ac39f638c6 cpfile and mvfile
259 $ cd ../repo
260 $ hg debugfillinfinitepushmetadata --node 3edfe7e9089ab9f728eb8e0d0c62a5d18cf19239 --node c7ac39f638c6b39bcdacf868fa21b6195670f8ae
261 $ cat .hg/scratchbranches/index/nodemetadatamap/3edfe7e9089ab9f728eb8e0d0c62a5d18cf19239
262 {"changed_files": {"file": {"adds": 1, "isbinary": false, "removes": 0, "status": "added"}, "testpullbycommithash2": {"adds": 0, "isbinary": false, "removes": 1, "status": "removed"}}} (no-eol)
263 $ cat .hg/scratchbranches/index/nodemetadatamap/c7ac39f638c6b39bcdacf868fa21b6195670f8ae
264 {"changed_files": {"cpfile": {"adds": 1, "copies": "file", "isbinary": false, "removes": 0, "status": "added"}, "file": {"adds": 0, "isbinary": false, "removes": 1, "status": "removed"}, "mvfile": {"adds": 1, "copies": "file", "isbinary": false, "removes": 0, "status": "added"}}} (no-eol)
265
266 Test infinitepush.metadatafilelimit number
267 $ cd ../client
268 $ echo file > file
269 $ hg add file
270 $ echo file1 > file1
271 $ hg add file1
272 $ echo file2 > file2
273 $ hg add file2
274 $ hg ci -m 'add many files'
275 $ hg log -r . -T '{node}'
276 09904fb20c53ff351bd3b1d47681f569a4dab7e5 (no-eol)
277 $ hg push -r . --bundle-store
278 pushing to ssh://user@dummy/repo
279 searching for changes
280 remote: pushing 5 commits:
281 remote: 33910bfe6ffe testpullbycommithash1
282 remote: d8fde0ddfc96 testpullbycommithash2
283 remote: 3edfe7e9089a add and rm files
284 remote: c7ac39f638c6 cpfile and mvfile
285 remote: 09904fb20c53 add many files
286
287 $ cd ../repo
288 $ hg debugfillinfinitepushmetadata --node 09904fb20c53ff351bd3b1d47681f569a4dab7e5 --config infinitepush.metadatafilelimit=2
289 $ cat .hg/scratchbranches/index/nodemetadatamap/09904fb20c53ff351bd3b1d47681f569a4dab7e5
290 {"changed_files": {"file": {"adds": 1, "isbinary": false, "removes": 0, "status": "added"}, "file1": {"adds": 1, "isbinary": false, "removes": 0, "status": "added"}}, "changed_files_truncated": true} (no-eol)
291
292 Test infinitepush.fillmetadatabranchpattern
293 $ cd ../repo
294 $ cat >> .hg/hgrc << EOF
295 > [infinitepush]
296 > fillmetadatabranchpattern=re:scratch/fillmetadata/.*
297 > EOF
298 $ cd ../client
299 $ echo tofillmetadata > tofillmetadata
300 $ hg ci -Aqm "tofillmetadata"
301 $ hg log -r . -T '{node}\n'
302 d2b0410d4da084bc534b1d90df0de9eb21583496
303 $ hg push -r . --to scratch/fillmetadata/fill --create
304 pushing to ssh://user@dummy/repo
305 searching for changes
306 remote: pushing 6 commits:
307 remote: 33910bfe6ffe testpullbycommithash1
308 remote: d8fde0ddfc96 testpullbycommithash2
309 remote: 3edfe7e9089a add and rm files
310 remote: c7ac39f638c6 cpfile and mvfile
311 remote: 09904fb20c53 add many files
312 remote: d2b0410d4da0 tofillmetadata
313
314 Make sure background process finished
315 $ sleep 3
316 $ cd ../repo
317 $ cat .hg/scratchbranches/index/nodemetadatamap/d2b0410d4da084bc534b1d90df0de9eb21583496
318 {"changed_files": {"tofillmetadata": {"adds": 1, "isbinary": false, "removes": 0, "status": "added"}}} (no-eol)