Debian Codegraph @

tests/test-phabricator.t

raw
1 #require vcr
2 $ cat >> $HGRCPATH <<EOF
3 > [extensions]
4 > phabricator =
5 >
6 > [auth]
7 > hgphab.schemes = https
8 > hgphab.prefix = phab.mercurial-scm.org
9 > # When working on the extension and making phabricator interaction
10 > # changes, edit this to be a real phabricator token. When done, edit
11 > # it back. The VCR transcripts will be auto-sanitised to replace your real
12 > # token with this value.
13 > hgphab.phabtoken = cli-hahayouwish
14 >
15 > [phabricator]
16 > debug = True
17 > EOF
18 $ hg init repo
19 $ cd repo
20 $ cat >> .hg/hgrc <<EOF
21 > [phabricator]
22 > url = https://phab.mercurial-scm.org/
23 > callsign = HG
24 > EOF
25 $ VCR="$TESTDIR/phabricator"
26
27 debugcallconduit doesn't claim invalid arguments without --test-vcr:
28 $ echo '{}' | HGRCSKIPREPO= hg debugcallconduit 'conduit.ping'
29 abort: config phabricator.url is required
30 [255]
31
32 Error is handled reasonably. We override the phabtoken here so that
33 when you're developing changes to phabricator.py you can edit the
34 above config and have a real token in the test but not have to edit
35 this test.
36 $ hg phabread --config auth.hgphab.phabtoken=cli-notavalidtoken \
37 > --test-vcr "$VCR/phabread-conduit-error.json" D4480 | head
38 abort: Conduit Error (ERR-INVALID-AUTH): API token "cli-notavalidtoken" has the wrong length. API tokens should be 32 characters long.
39
40 Missing arguments don't crash, and may print the command help
41
42 $ hg debugcallconduit
43 hg debugcallconduit: invalid arguments
44 hg debugcallconduit METHOD
45
46 call Conduit API
47
48 options:
49
50 (use 'hg debugcallconduit -h' to show more help)
51 [10]
52 $ hg phabread
53 abort: empty DREVSPEC set
54 [255]
55
56 Basic phabread:
57 $ hg phabread --test-vcr "$VCR/phabread-4480.json" D4480 | head
58 # HG changeset patch
59 # Date 1536771503 0
60 # Parent a5de21c9e3703f8e8eb064bd7d893ff2f703c66a
61 exchangev2: start to implement pull with wire protocol v2
62
63 Wire protocol version 2 will take a substantially different
64 approach to exchange than version 1 (at least as far as pulling
65 is concerned).
66
67 This commit establishes a new exchangev2 module for holding
68
69 Phabread with multiple DREVSPEC
70
71 TODO: attempt to order related revisions like --stack?
72 $ hg phabread --test-vcr "$VCR/phabread-multi-drev.json" D8205 8206 D8207 \
73 > | grep '^Differential Revision'
74 Differential Revision: https://phab.mercurial-scm.org/D8205
75 Differential Revision: https://phab.mercurial-scm.org/D8206
76 Differential Revision: https://phab.mercurial-scm.org/D8207
77
78 Empty DREVSPECs don't crash
79
80 $ hg phabread --test-vcr "$VCR/phabread-empty-drev.json" D7917-D7917
81 abort: empty DREVSPEC set
82 [255]
83
84
85 phabupdate with an accept:
86 $ hg phabupdate --accept D4564 \
87 > -m 'I think I like where this is headed. Will read rest of series later.'\
88 > --test-vcr "$VCR/accept-4564.json"
89 abort: Conduit Error (ERR-CONDUIT-CORE): Validation errors:
90 - You can not accept this revision because it has already been closed. Only open revisions can be accepted.
91 [255]
92 $ hg phabupdate --accept D7913 -m 'LGTM' --test-vcr "$VCR/accept-7913.json"
93
94 phabupdate with --plan-changes:
95
96 $ hg phabupdate --plan-changes D6876 --test-vcr "$VCR/phabupdate-change-6876.json"
97
98 Create a differential diff:
99 $ HGENCODING=utf-8; export HGENCODING
100 $ echo alpha > alpha
101 $ hg ci --addremove -m 'create alpha for phabricator test €'
102 adding alpha
103 $ hg phabsend -r . --test-vcr "$VCR/phabsend-create-alpha.json"
104 D7915 - created - 0:d386117f30e6 tip "create alpha for phabricator test \xe2\x82\xac" (esc)
105 new commits: ['347bf67801e5']
106 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/d386117f30e6-24ffe649-phabsend.hg
107 $ echo more >> alpha
108 $ HGEDITOR=true hg ci --amend
109 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/347bf67801e5-3bf313e4-amend.hg
110 $ echo beta > beta
111 $ hg ci --addremove -m 'create beta for phabricator test'
112 adding beta
113 $ hg phabsend -r ".^::" --test-vcr "$VCR/phabsend-update-alpha-create-beta.json"
114 c44b38f24a45 mapped to old nodes []
115 D7915 - updated - 0:c44b38f24a45 "create alpha for phabricator test \xe2\x82\xac" (esc)
116 D7916 - created - 1:9e6901f21d5b tip "create beta for phabricator test"
117 new commits: ['a692622e6937']
118 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/9e6901f21d5b-1fcd4f0e-phabsend.hg
119 $ unset HGENCODING
120
121 The amend won't explode after posting a public commit. The local tag is left
122 behind to identify it.
123
124 $ echo 'public change' > beta
125 $ hg ci -m 'create public change for phabricator testing'
126 $ hg phase --public .
127 $ echo 'draft change' > alpha
128 $ hg ci -m 'create draft change for phabricator testing'
129 $ hg phabsend --amend -r '.^::' --test-vcr "$VCR/phabsend-create-public.json"
130 D7917 - created - 2:7b4185ab5d16 "create public change for phabricator testing"
131 D7918 - created - 3:251c1c333fc6 tip "create draft change for phabricator testing"
132 warning: not updating public commit 2:7b4185ab5d16
133 new commits: ['3244dc4a3334']
134 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/251c1c333fc6-41cb7c3b-phabsend.hg
135 $ hg tags -v
136 tip 3:3244dc4a3334
137 D7917 2:7b4185ab5d16 local
138
139 $ hg debugcallconduit user.search --test-vcr "$VCR/phab-conduit.json" <<EOF
140 > {
141 > "constraints": {
142 > "isBot": true
143 > }
144 > }
145 > EOF
146 {
147 "cursor": {
148 "after": null,
149 "before": null,
150 "limit": 100,
151 "order": null
152 },
153 "data": [],
154 "maps": {},
155 "query": {
156 "queryKey": null
157 }
158 }
159
160 Template keywords
161 $ hg log -T'{rev} {phabreview|json}\n'
162 3 {"id": "D7918", "url": "https://phab.mercurial-scm.org/D7918"}
163 2 {"id": "D7917", "url": "https://phab.mercurial-scm.org/D7917"}
164 1 {"id": "D7916", "url": "https://phab.mercurial-scm.org/D7916"}
165 0 {"id": "D7915", "url": "https://phab.mercurial-scm.org/D7915"}
166
167 $ hg log -T'{rev} {if(phabreview, "{phabreview.url} {phabreview.id}")}\n'
168 3 https://phab.mercurial-scm.org/D7918 D7918
169 2 https://phab.mercurial-scm.org/D7917 D7917
170 1 https://phab.mercurial-scm.org/D7916 D7916
171 0 https://phab.mercurial-scm.org/D7915 D7915
172
173 Commenting when phabsending:
174 $ echo comment > comment
175 $ hg ci --addremove -m "create comment for phabricator test"
176 adding comment
177 $ hg phabsend -r . -m "For default branch" --test-vcr "$VCR/phabsend-comment-created.json"
178 D7919 - created - 4:d5dddca9023d tip "create comment for phabricator test"
179 new commits: ['f7db812bbe1d']
180 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/d5dddca9023d-adf673ba-phabsend.hg
181 $ echo comment2 >> comment
182 $ hg ci --amend
183 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/f7db812bbe1d-8fcded77-amend.hg
184 $ hg phabsend -r . -m "Address review comments" --test-vcr "$VCR/phabsend-comment-updated.json"
185 1849d7828727 mapped to old nodes []
186 D7919 - updated - 4:1849d7828727 tip "create comment for phabricator test"
187
188 Phabsending a skipped commit:
189 $ hg phabsend --no-amend -r . --test-vcr "$VCR/phabsend-skipped.json"
190 1849d7828727 mapped to old nodes ['1849d7828727']
191 D7919 - skipped - 4:1849d7828727 tip "create comment for phabricator test"
192
193 Phabsend doesn't create an instability when restacking existing revisions on top
194 of new revisions.
195
196 $ hg init reorder
197 $ cd reorder
198 $ cat >> .hg/hgrc <<EOF
199 > [phabricator]
200 > url = https://phab.mercurial-scm.org/
201 > callsign = HG
202 > [experimental]
203 > evolution = all
204 > EOF
205
206 $ echo "add" > file1.txt
207 $ hg ci -Aqm 'added'
208 $ echo "mod1" > file1.txt
209 $ hg ci -m 'modified 1'
210 $ echo "mod2" > file1.txt
211 $ hg ci -m 'modified 2'
212 $ hg phabsend -r . --test-vcr "$VCR/phabsend-add-parent-setup.json"
213 D8433 - created - 2:5d3959e20d1d tip "modified 2"
214 new commits: ['2b4aa8a88d61']
215 $ hg log -G -T compact
216 @ 3[tip]:1 2b4aa8a88d61 1970-01-01 00:00 +0000 test
217 | modified 2
218 |
219 o 1 d549263bcb2d 1970-01-01 00:00 +0000 test
220 | modified 1
221 |
222 o 0 5cbade24e0fa 1970-01-01 00:00 +0000 test
223 added
224
225 Also check that it doesn't create more orphans outside of the stack
226
227 $ hg up -q 1
228 $ echo "mod3" > file1.txt
229 $ hg ci -m 'modified 3'
230 created new head
231 $ hg up -q 3
232 $ hg phabsend -r ".^ + ." --test-vcr "$VCR/phabsend-add-parent.json"
233 2b4aa8a88d61 mapped to old nodes ['2b4aa8a88d61']
234 D8434 - created - 1:d549263bcb2d "modified 1"
235 D8433 - updated - 3:2b4aa8a88d61 "modified 2"
236 new commits: ['876a60d024de']
237 new commits: ['0c6523cb1d0f']
238 restabilizing 1eda4bf55021 as d2c78c3a3e01
239 $ hg log -G -T compact
240 o 7[tip]:5 d2c78c3a3e01 1970-01-01 00:00 +0000 test
241 | modified 3
242 |
243 | @ 6 0c6523cb1d0f 1970-01-01 00:00 +0000 test
244 |/ modified 2
245 |
246 o 5:0 876a60d024de 1970-01-01 00:00 +0000 test
247 | modified 1
248 |
249 o 0 5cbade24e0fa 1970-01-01 00:00 +0000 test
250 added
251
252 Posting obsolete commits is disallowed
253
254 $ echo "mod3" > file1.txt
255 $ hg ci -m 'modified A'
256 $ echo "mod4" > file1.txt
257 $ hg ci -m 'modified B'
258
259 $ hg up '.^'
260 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
261 $ echo 'obsolete' > file1.txt
262 $ hg amend --config extensions.amend=
263 1 new orphan changesets
264 $ hg log -G
265 @ changeset: 10:082be6c94150
266 | tag: tip
267 | parent: 6:0c6523cb1d0f
268 | user: test
269 | date: Thu Jan 01 00:00:00 1970 +0000
270 | summary: modified A
271 |
272 | * changeset: 9:a67643f48146
273 | | user: test
274 | | date: Thu Jan 01 00:00:00 1970 +0000
275 | | instability: orphan
276 | | summary: modified B
277 | |
278 | x changeset: 8:db79727cb2f7
279 |/ parent: 6:0c6523cb1d0f
280 | user: test
281 | date: Thu Jan 01 00:00:00 1970 +0000
282 | obsolete: rewritten using amend as 10:082be6c94150
283 | summary: modified A
284 |
285 | o changeset: 7:d2c78c3a3e01
286 | | parent: 5:876a60d024de
287 | | user: test
288 | | date: Thu Jan 01 00:00:00 1970 +0000
289 | | summary: modified 3
290 | |
291 o | changeset: 6:0c6523cb1d0f
292 |/ user: test
293 | date: Thu Jan 01 00:00:00 1970 +0000
294 | summary: modified 2
295 |
296 o changeset: 5:876a60d024de
297 | parent: 0:5cbade24e0fa
298 | user: test
299 | date: Thu Jan 01 00:00:00 1970 +0000
300 | summary: modified 1
301 |
302 o changeset: 0:5cbade24e0fa
303 user: test
304 date: Thu Jan 01 00:00:00 1970 +0000
305 summary: added
306
307 $ hg phabsend -r 5::
308 abort: obsolete commits cannot be posted for review
309 [255]
310
311 Don't restack existing orphans
312
313 $ hg phabsend -r 5::tip --test-vcr "$VCR/phabsend-no-restack-orphan.json"
314 876a60d024de mapped to old nodes ['876a60d024de']
315 0c6523cb1d0f mapped to old nodes ['0c6523cb1d0f']
316 D8434 - updated - 5:876a60d024de "modified 1"
317 D8433 - updated - 6:0c6523cb1d0f "modified 2"
318 D8435 - created - 10:082be6c94150 tip "modified A"
319 new commits: ['b5913193c805']
320 not restabilizing unchanged d2c78c3a3e01
321 $ hg log -G
322 @ changeset: 11:b5913193c805
323 | tag: tip
324 | parent: 6:0c6523cb1d0f
325 | user: test
326 | date: Thu Jan 01 00:00:00 1970 +0000
327 | summary: modified A
328 |
329 | * changeset: 9:a67643f48146
330 | | user: test
331 | | date: Thu Jan 01 00:00:00 1970 +0000
332 | | instability: orphan
333 | | summary: modified B
334 | |
335 | x changeset: 8:db79727cb2f7
336 |/ parent: 6:0c6523cb1d0f
337 | user: test
338 | date: Thu Jan 01 00:00:00 1970 +0000
339 | obsolete: rewritten using amend, phabsend as 11:b5913193c805
340 | summary: modified A
341 |
342 | o changeset: 7:d2c78c3a3e01
343 | | parent: 5:876a60d024de
344 | | user: test
345 | | date: Thu Jan 01 00:00:00 1970 +0000
346 | | summary: modified 3
347 | |
348 o | changeset: 6:0c6523cb1d0f
349 |/ user: test
350 | date: Thu Jan 01 00:00:00 1970 +0000
351 | summary: modified 2
352 |
353 o changeset: 5:876a60d024de
354 | parent: 0:5cbade24e0fa
355 | user: test
356 | date: Thu Jan 01 00:00:00 1970 +0000
357 | summary: modified 1
358 |
359 o changeset: 0:5cbade24e0fa
360 user: test
361 date: Thu Jan 01 00:00:00 1970 +0000
362 summary: added
363
364 $ cd ..
365
366 Phabesending a new binary, a modified binary, and a removed binary
367
368 >>> open('bin', 'wb').write(b'\0a') and None
369 $ hg ci -Am 'add binary'
370 adding bin
371 >>> open('bin', 'wb').write(b'\0b') and None
372 $ hg ci -m 'modify binary'
373 $ hg rm bin
374 $ hg ci -m 'remove binary'
375 $ hg phabsend -r .~2:: --test-vcr "$VCR/phabsend-binary.json"
376 uploading bin@aa24a81f55de
377 D8007 - created - 5:aa24a81f55de "add binary"
378 uploading bin@d8d62a881b54
379 D8008 - created - 6:d8d62a881b54 "modify binary"
380 D8009 - created - 7:af55645b2e29 tip "remove binary"
381 new commits: ['b8139fbb4a57']
382 new commits: ['c88ce4c2d2ad']
383 new commits: ['75dbbc901145']
384 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/aa24a81f55de-a3a0cf24-phabsend.hg
385
386 Phabsend a renamed binary and a copied binary, with and without content changes
387 to src and dest
388
389 >>> open('bin2', 'wb').write(b'\0c') and None
390 $ hg ci -Am 'add another binary'
391 adding bin2
392
393 TODO: "bin2" can't be viewed in this commit (left or right side), and the URL
394 looks much different than when viewing "bin2_moved". No idea if this is a phab
395 bug, or phabsend bug. The patch (as printed by phabread) look reasonable
396 though.
397
398 $ hg mv bin2 bin2_moved
399 $ hg ci -m "moved binary"
400
401 Note: "bin2_moved" is also not viewable in phabricator with this review
402
403 $ hg cp bin2_moved bin2_copied
404 $ hg ci -m "copied binary"
405
406 Note: "bin2_moved_again" is marked binary in phabricator, and both sides of it
407 are viewable in their proper state. "bin2_copied" is not viewable, and not
408 listed as binary in phabricator.
409
410 >>> open('bin2_copied', 'wb').write(b'\0move+mod') and None
411 $ hg mv bin2_copied bin2_moved_again
412 $ hg ci -m "move+mod copied binary"
413
414 Note: "bin2_moved" and "bin2_moved_copy" are both marked binary, and both
415 viewable on each side.
416
417 >>> open('bin2_moved', 'wb').write(b'\0precopy mod') and None
418 $ hg cp bin2_moved bin2_moved_copied
419 >>> open('bin2_moved', 'wb').write(b'\0copy src+mod') and None
420 $ hg ci -m "copy+mod moved binary"
421
422 $ hg phabsend -r .~4:: --test-vcr "$VCR/phabsend-binary-renames.json"
423 uploading bin2@f42f9195e00c
424 D8128 - created - 8:f42f9195e00c "add another binary"
425 D8129 - created - 9:834ab31d80ae "moved binary"
426 D8130 - created - 10:494b750e5194 "copied binary"
427 uploading bin2_moved_again@25f766b50cc2
428 D8131 - created - 11:25f766b50cc2 "move+mod copied binary"
429 uploading bin2_moved_copied@1b87b363a5e4
430 uploading bin2_moved@1b87b363a5e4
431 D8132 - created - 12:1b87b363a5e4 tip "copy+mod moved binary"
432 new commits: ['90437c20312a']
433 new commits: ['f391f4da4c61']
434 new commits: ['da86a9f3268c']
435 new commits: ['003ffc16ba66']
436 new commits: ['13bd750c36fa']
437 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/f42f9195e00c-e82a0769-phabsend.hg
438
439 Phabreading a DREV with a local:commits time as a string:
440 $ hg phabread --test-vcr "$VCR/phabread-str-time.json" D1285
441 # HG changeset patch
442 # User Pulkit Goyal <[email protected]>
443 # Date 1509404054 -19800
444 # Node ID 44fc1c1f1774a76423b9c732af6938435099bcc5
445 # Parent 8feef8ef8389a3b544e0a74624f1efc3a8d85d35
446 repoview: add a new attribute _visibilityexceptions and related API
447
448 Currently we don't have a defined way in core to make some hidden revisions
449 visible in filtered repo. Extensions to achieve the purpose of unhiding some
450 hidden commits, wrap repoview.pinnedrevs() function.
451
452 To make the above task simple and have well defined API, this patch adds a new
453 attribute '_visibilityexceptions' to repoview class which will contains
454 the hidden revs which should be exception.
455 This will allow to set different exceptions for different repoview objects
456 backed by the same unfiltered repo.
457
458 This patch also adds API to add revs to the attribute set and get them.
459
460 Thanks to Jun for suggesting the use of repoview class instead of localrepo.
461
462 Differential Revision: https://phab.mercurial-scm.org/D1285
463 diff --git a/mercurial/repoview.py b/mercurial/repoview.py
464 --- a/mercurial/repoview.py
465 +++ b/mercurial/repoview.py
466 @@ * @@ (glob)
467 subclasses of `localrepo`. Eg: `bundlerepo` or `statichttprepo`.
468 """
469
470 + # hidden revs which should be visible
471 + _visibilityexceptions = set()
472 +
473 def __init__(self, repo, filtername):
474 object.__setattr__(self, r'_unfilteredrepo', repo)
475 object.__setattr__(self, r'filtername', filtername)
476 @@ -231,6 +234,14 @@
477 return self
478 return self.unfiltered().filtered(name)
479
480 + def addvisibilityexceptions(self, revs):
481 + """adds hidden revs which should be visible to set of exceptions"""
482 + self._visibilityexceptions.update(revs)
483 +
484 + def getvisibilityexceptions(self):
485 + """returns the set of hidden revs which should be visible"""
486 + return self._visibilityexceptions
487 +
488 # everything access are forwarded to the proxied repo
489 def __getattr__(self, attr):
490 return getattr(self._unfilteredrepo, attr)
491 diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
492 --- a/mercurial/localrepo.py
493 +++ b/mercurial/localrepo.py
494 @@ -570,6 +570,14 @@
495 def close(self):
496 self._writecaches()
497
498 + def addvisibilityexceptions(self, exceptions):
499 + # should be called on a filtered repository
500 + pass
501 +
502 + def getvisibilityexceptions(self):
503 + # should be called on a filtered repository
504 + return set()
505 +
506 def _loadextensions(self):
507 extensions.loadall(self.ui)
508
509
510 A bad .arcconfig doesn't error out
511 $ echo 'garbage' > .arcconfig
512 $ hg config phabricator --source
513 invalid JSON in $TESTTMP/repo/.arcconfig
514 */.hgrc:*: phabricator.debug=True (glob)
515 $TESTTMP/repo/.hg/hgrc:*: phabricator.url=https://phab.mercurial-scm.org/ (glob)
516 $TESTTMP/repo/.hg/hgrc:*: phabricator.callsign=HG (glob)
517
518 The .arcconfig content overrides global config
519 $ cat >> $HGRCPATH << EOF
520 > [phabricator]
521 > url = global
522 > callsign = global
523 > EOF
524 $ cp $TESTDIR/../.arcconfig .
525 $ mv .hg/hgrc .hg/hgrc.bak
526 $ hg config phabricator --source
527 */.hgrc:*: phabricator.debug=True (glob)
528 $TESTTMP/repo/.arcconfig: phabricator.callsign=HG
529 $TESTTMP/repo/.arcconfig: phabricator.url=https://phab.mercurial-scm.org/
530
531 But it doesn't override local config
532 $ cat >> .hg/hgrc << EOF
533 > [phabricator]
534 > url = local
535 > callsign = local
536 > EOF
537 $ hg config phabricator --source
538 */.hgrc:*: phabricator.debug=True (glob)
539 $TESTTMP/repo/.hg/hgrc:*: phabricator.url=local (glob)
540 $TESTTMP/repo/.hg/hgrc:*: phabricator.callsign=local (glob)
541 $ mv .hg/hgrc.bak .hg/hgrc
542
543 Phabimport works with a stack
544
545 $ cd ..
546 $ hg clone repo repo2 -qr 1
547 $ cp repo/.hg/hgrc repo2/.hg/
548 $ cd repo2
549 $ hg phabimport --stack 'D7918' --test-vcr "$VCR/phabimport-stack.json"
550 applying patch from D7917
551 applying patch from D7918
552 $ hg log -r .: -G -Tcompact
553 o 3[tip] aaef04066140 1970-01-01 00:00 +0000 test
554 | create draft change for phabricator testing
555 |
556 o 2 8de3712202d1 1970-01-01 00:00 +0000 test
557 | create public change for phabricator testing
558 |
559 @ 1 a692622e6937 1970-01-01 00:00 +0000 test
560 | create beta for phabricator test
561 ~
562 Phabimport can create secret commits
563
564 $ hg rollback --config ui.rollback=True
565 repository tip rolled back to revision 1 (undo phabimport)
566 $ hg phabimport --stack 'D7918' --test-vcr "$VCR/phabimport-stack.json" \
567 > --config phabimport.secret=True
568 applying patch from D7917
569 applying patch from D7918
570 $ hg log -r 'reverse(.:)' -T phases
571 changeset: 3:aaef04066140
572 tag: tip
573 phase: secret
574 user: test
575 date: Thu Jan 01 00:00:00 1970 +0000
576 summary: create draft change for phabricator testing
577
578 changeset: 2:8de3712202d1
579 phase: secret
580 user: test
581 date: Thu Jan 01 00:00:00 1970 +0000
582 summary: create public change for phabricator testing
583
584 changeset: 1:a692622e6937
585 phase: public
586 user: test
587 date: Thu Jan 01 00:00:00 1970 +0000
588 summary: create beta for phabricator test
589
590 phabupdate can convert from local revisions
591
592 $ hg phabupdate --reclaim D7917 -r '.: and not public()'
593 abort: cannot specify both DREVSPEC and --rev
594 [10]
595
596 $ hg phabupdate --reclaim -r '.: and not public()' --test-vcr "$VCR/phabupdate-revs.json"
597
598 Phabimport accepts multiple DREVSPECs
599
600 $ hg rollback --config ui.rollback=True
601 repository tip rolled back to revision 1 (undo phabimport)
602 $ hg phabimport --no-stack D7917 D7918 --test-vcr "$VCR/phabimport-multi-drev.json"
603 applying patch from D7917
604 applying patch from D7918
605
606 Phabsend requires a linear range of commits
607
608 $ hg phabsend -r 0+2+3
609 abort: cannot phabsend multiple head revisions: c44b38f24a45 aaef04066140
610 (the revisions must form a linear chain)
611 [255]
612
613 Validate arguments with --fold
614
615 $ hg phabsend --fold -r 1
616 abort: cannot fold a single revision
617 [255]
618 $ hg phabsend --fold --no-amend -r 1::
619 abort: cannot fold with --no-amend
620 [255]
621 $ hg phabsend --fold -r 1::
622 abort: cannot fold revisions with different DREV values
623 [255]
624
625 Setup a series of commits to be folded, and include the Test Plan field multiple
626 times to test the concatenation logic. No Test Plan field in the last one to
627 ensure missing fields are skipped.
628
629 $ hg init ../folded
630 $ cd ../folded
631 $ cat >> .hg/hgrc <<EOF
632 > [phabricator]
633 > url = https://phab.mercurial-scm.org/
634 > callsign = HG
635 > EOF
636
637 $ echo 'added' > file.txt
638 $ hg ci -Aqm 'added file'
639
640 $ cat > log.txt <<EOF
641 > one: first commit to review
642 >
643 > This file was modified with 'mod1' as its contents.
644 >
645 > Test Plan:
646 > LOL! What testing?!
647 > EOF
648 $ echo mod1 > file.txt
649 $ hg ci -l log.txt
650
651 $ cat > log.txt <<EOF
652 > two: second commit to review
653 >
654 > This file was modified with 'mod2' as its contents.
655 >
656 > Test Plan:
657 > Haha! yeah, right.
658 >
659 > EOF
660 $ echo mod2 > file.txt
661 $ hg ci -l log.txt
662
663 $ echo mod3 > file.txt
664 $ hg ci -m '3: a commit with no detailed message'
665
666 The folding of immutable commits works...
667
668 $ hg phase -r tip --public
669 $ hg phabsend --fold -r 1:: --test-vcr "$VCR/phabsend-fold-immutable.json"
670 D8386 - created - 1:a959a3f69d8d "one: first commit to review"
671 D8386 - created - 2:24a4438154ba "two: second commit to review"
672 D8386 - created - 3:d235829e802c tip "3: a commit with no detailed message"
673 warning: not updating public commit 1:a959a3f69d8d
674 warning: not updating public commit 2:24a4438154ba
675 warning: not updating public commit 3:d235829e802c
676 no newnodes to update
677
678 $ hg phase -r 0 --draft --force
679
680 ... as does the initial mutable fold...
681
682 $ echo y | hg phabsend --fold --confirm -r 1:: \
683 > --test-vcr "$VCR/phabsend-fold-initial.json"
684 NEW - 1:a959a3f69d8d "one: first commit to review"
685 NEW - 2:24a4438154ba "two: second commit to review"
686 NEW - 3:d235829e802c tip "3: a commit with no detailed message"
687 Send the above changes to https://phab.mercurial-scm.org/ (Y/n)? y
688 D8387 - created - 1:a959a3f69d8d "one: first commit to review"
689 D8387 - created - 2:24a4438154ba "two: second commit to review"
690 D8387 - created - 3:d235829e802c tip "3: a commit with no detailed message"
691 updating local commit list for D8387
692 new commits: ['602c4e738243', '832553266fe8', '921f8265efbd']
693 saved backup bundle to $TESTTMP/folded/.hg/strip-backup/a959a3f69d8d-a4a24136-phabsend.hg
694
695 ... and doesn't mangle the local commits.
696
697 $ hg log -T '{rev}:{node|short}\n{indent(desc, " ")}\n'
698 3:921f8265efbd
699 3: a commit with no detailed message
700
701 Differential Revision: https://phab.mercurial-scm.org/D8387
702 2:832553266fe8
703 two: second commit to review
704
705 This file was modified with 'mod2' as its contents.
706
707 Test Plan:
708 Haha! yeah, right.
709
710 Differential Revision: https://phab.mercurial-scm.org/D8387
711 1:602c4e738243
712 one: first commit to review
713
714 This file was modified with 'mod1' as its contents.
715
716 Test Plan:
717 LOL! What testing?!
718
719 Differential Revision: https://phab.mercurial-scm.org/D8387
720 0:98d480e0d494
721 added file
722
723 Setup some obsmarkers by adding a file to the middle commit. This stress tests
724 getoldnodedrevmap() in later phabsends.
725
726 $ hg up '.^'
727 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
728 $ echo 'modified' > file2.txt
729 $ hg add file2.txt
730 $ hg amend --config experimental.evolution=all --config extensions.amend=
731 1 new orphan changesets
732 $ hg up 3
733 "obsolete" feature not enabled but 1 markers found!
734 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
735 $ hg rebase --config experimental.evolution=all --config extensions.rebase=
736 note: not rebasing 2:832553266fe8 "two: second commit to review", already in destination as 4:0124e5474c88 tip "two: second commit to review"
737 rebasing 3:921f8265efbd "3: a commit with no detailed message"
738
739 When commits have changed locally, the local commit list on Phabricator is
740 updated.
741
742 $ echo y | hg phabsend --fold --confirm -r 1:: \
743 > --test-vcr "$VCR/phabsend-fold-updated.json"
744 "obsolete" feature not enabled but 2 markers found!
745 602c4e738243 mapped to old nodes ['602c4e738243']
746 0124e5474c88 mapped to old nodes ['832553266fe8']
747 e4edb1fe3565 mapped to old nodes ['921f8265efbd']
748 D8387 - 1:602c4e738243 "one: first commit to review"
749 D8387 - 4:0124e5474c88 "two: second commit to review"
750 D8387 - 5:e4edb1fe3565 tip "3: a commit with no detailed message"
751 Send the above changes to https://phab.mercurial-scm.org/ (Y/n)? y
752 D8387 - updated - 1:602c4e738243 "one: first commit to review"
753 D8387 - updated - 4:0124e5474c88 "two: second commit to review"
754 D8387 - updated - 5:e4edb1fe3565 tip "3: a commit with no detailed message"
755 "obsolete" feature not enabled but 2 markers found! (?)
756 updating local commit list for D8387
757 new commits: ['602c4e738243', '0124e5474c88', 'e4edb1fe3565']
758 $ hg log -Tcompact
759 "obsolete" feature not enabled but 2 markers found!
760 5[tip] e4edb1fe3565 1970-01-01 00:00 +0000 test
761 3: a commit with no detailed message
762
763 4:1 0124e5474c88 1970-01-01 00:00 +0000 test
764 two: second commit to review
765
766 1 602c4e738243 1970-01-01 00:00 +0000 test
767 one: first commit to review
768
769 0 98d480e0d494 1970-01-01 00:00 +0000 test
770 added file
771
772 When nothing has changed locally since the last phabsend, the commit list isn't
773 updated, and nothing is changed locally afterward.
774
775 $ hg phabsend --fold -r 1:: --test-vcr "$VCR/phabsend-fold-no-changes.json"
776 "obsolete" feature not enabled but 2 markers found!
777 602c4e738243 mapped to old nodes ['602c4e738243']
778 0124e5474c88 mapped to old nodes ['0124e5474c88']
779 e4edb1fe3565 mapped to old nodes ['e4edb1fe3565']
780 D8387 - updated - 1:602c4e738243 "one: first commit to review"
781 D8387 - updated - 4:0124e5474c88 "two: second commit to review"
782 D8387 - updated - 5:e4edb1fe3565 tip "3: a commit with no detailed message"
783 "obsolete" feature not enabled but 2 markers found! (?)
784 local commit list for D8387 is already up-to-date
785 $ hg log -Tcompact
786 "obsolete" feature not enabled but 2 markers found!
787 5[tip] e4edb1fe3565 1970-01-01 00:00 +0000 test
788 3: a commit with no detailed message
789
790 4:1 0124e5474c88 1970-01-01 00:00 +0000 test
791 two: second commit to review
792
793 1 602c4e738243 1970-01-01 00:00 +0000 test
794 one: first commit to review
795
796 0 98d480e0d494 1970-01-01 00:00 +0000 test
797 added file
798
799 Fold will accept new revisions at the end...
800
801 $ echo 'another mod' > file2.txt
802 $ hg ci -m 'four: extend the fold range'
803 "obsolete" feature not enabled but 2 markers found!
804 $ hg phabsend --fold -r 1:: --test-vcr "$VCR/phabsend-fold-extend-end.json" \
805 > --config experimental.evolution=all
806 602c4e738243 mapped to old nodes ['602c4e738243']
807 0124e5474c88 mapped to old nodes ['0124e5474c88']
808 e4edb1fe3565 mapped to old nodes ['e4edb1fe3565']
809 D8387 - updated - 1:602c4e738243 "one: first commit to review"
810 D8387 - updated - 4:0124e5474c88 "two: second commit to review"
811 D8387 - updated - 5:e4edb1fe3565 "3: a commit with no detailed message"
812 D8387 - created - 6:94aaae213b23 tip "four: extend the fold range"
813 updating local commit list for D8387
814 new commits: ['602c4e738243', '0124e5474c88', 'e4edb1fe3565', '51a04fea8707']
815 $ hg log -r . -T '{desc}\n'
816 four: extend the fold range
817
818 Differential Revision: https://phab.mercurial-scm.org/D8387
819 $ hg log -T'{rev} {if(phabreview, "{phabreview.url} {phabreview.id}")}\n' -r 1::
820 "obsolete" feature not enabled but 3 markers found!
821 1 https://phab.mercurial-scm.org/D8387 D8387
822 4 https://phab.mercurial-scm.org/D8387 D8387
823 5 https://phab.mercurial-scm.org/D8387 D8387
824 7 https://phab.mercurial-scm.org/D8387 D8387
825
826 ... and also accepts new revisions at the beginning of the range
827
828 It's a bit unfortunate that not having a Differential URL on the first commit
829 causes a new Differential Revision to be created, though it isn't *entirely*
830 unreasonable. At least this updates the subsequent commits.
831
832 TODO: See if it can reuse the existing Differential.
833
834 $ hg phabsend --fold -r 0:: --test-vcr "$VCR/phabsend-fold-extend-front.json" \
835 > --config experimental.evolution=all
836 602c4e738243 mapped to old nodes ['602c4e738243']
837 0124e5474c88 mapped to old nodes ['0124e5474c88']
838 e4edb1fe3565 mapped to old nodes ['e4edb1fe3565']
839 51a04fea8707 mapped to old nodes ['51a04fea8707']
840 D8388 - created - 0:98d480e0d494 "added file"
841 D8388 - updated - 1:602c4e738243 "one: first commit to review"
842 D8388 - updated - 4:0124e5474c88 "two: second commit to review"
843 D8388 - updated - 5:e4edb1fe3565 "3: a commit with no detailed message"
844 D8388 - updated - 7:51a04fea8707 tip "four: extend the fold range"
845 updating local commit list for D8388
846 new commits: ['15e9b14b4b4c', '6320b7d714cf', '3ee132d41dbc', '30682b960804', 'ac7db67f0991']
847
848 $ hg log -T '{rev}:{node|short}\n{indent(desc, " ")}\n'
849 "obsolete" feature not enabled but 8 markers found!
850 12:ac7db67f0991
851 four: extend the fold range
852
853 Differential Revision: https://phab.mercurial-scm.org/D8388
854 11:30682b960804
855 3: a commit with no detailed message
856
857 Differential Revision: https://phab.mercurial-scm.org/D8388
858 10:3ee132d41dbc
859 two: second commit to review
860
861 This file was modified with 'mod2' as its contents.
862
863 Test Plan:
864 Haha! yeah, right.
865
866 Differential Revision: https://phab.mercurial-scm.org/D8388
867 9:6320b7d714cf
868 one: first commit to review
869
870 This file was modified with 'mod1' as its contents.
871
872 Test Plan:
873 LOL! What testing?!
874
875 Differential Revision: https://phab.mercurial-scm.org/D8388
876 8:15e9b14b4b4c
877 added file
878
879 Differential Revision: https://phab.mercurial-scm.org/D8388
880
881 Test phabsend --fold with an `hg split` at the end of the range
882
883 $ echo foo > file3.txt
884 $ hg add file3.txt
885
886 $ hg log -r . -T '{desc}' > log.txt
887 $ echo 'amended mod' > file2.txt
888 $ hg ci --amend -l log.txt --config experimental.evolution=all
889
890 $ cat <<EOF | hg --config extensions.split= --config ui.interactive=True \
891 > --config experimental.evolution=all split -r .
892 > n
893 > y
894 > y
895 > y
896 > y
897 > EOF
898 diff --git a/file2.txt b/file2.txt
899 1 hunks, 1 lines changed
900 examine changes to 'file2.txt'?
901 (enter ? for help) [Ynesfdaq?] n
902
903 diff --git a/file3.txt b/file3.txt
904 new file mode 100644
905 examine changes to 'file3.txt'?
906 (enter ? for help) [Ynesfdaq?] y
907
908 @@ -0,0 +1,1 @@
909 +foo
910 record change 2/2 to 'file3.txt'?
911 (enter ? for help) [Ynesfdaq?] y
912
913 created new head
914 diff --git a/file2.txt b/file2.txt
915 1 hunks, 1 lines changed
916 examine changes to 'file2.txt'?
917 (enter ? for help) [Ynesfdaq?] y
918
919 @@ -1,1 +1,1 @@
920 -modified
921 +amended mod
922 record this change to 'file2.txt'?
923 (enter ? for help) [Ynesfdaq?] y
924
925 $ hg phabsend --fold -r 8:: --test-vcr "$VCR/phabsend-fold-split-end.json" \
926 > --config experimental.evolution=all
927 15e9b14b4b4c mapped to old nodes ['15e9b14b4b4c']
928 6320b7d714cf mapped to old nodes ['6320b7d714cf']
929 3ee132d41dbc mapped to old nodes ['3ee132d41dbc']
930 30682b960804 mapped to old nodes ['30682b960804']
931 6bc15dc99efd mapped to old nodes ['ac7db67f0991']
932 b50946d5e490 mapped to old nodes ['ac7db67f0991']
933 D8388 - updated - 8:15e9b14b4b4c "added file"
934 D8388 - updated - 9:6320b7d714cf "one: first commit to review"
935 D8388 - updated - 10:3ee132d41dbc "two: second commit to review"
936 D8388 - updated - 11:30682b960804 "3: a commit with no detailed message"
937 D8388 - updated - 14:6bc15dc99efd "four: extend the fold range"
938 D8388 - updated - 15:b50946d5e490 tip "four: extend the fold range"
939 updating local commit list for D8388
940 new commits: ['15e9b14b4b4c', '6320b7d714cf', '3ee132d41dbc', '30682b960804', '6bc15dc99efd', 'b50946d5e490']
941
942 Test phabsend --fold with an `hg fold` at the end of the range
943
944 $ hg --config experimental.evolution=all --config extensions.rebase= \
945 > rebase -r '.^' -r . -d '.^^' --collapse -l log.txt
946 rebasing 14:6bc15dc99efd "four: extend the fold range"
947 rebasing 15:b50946d5e490 tip "four: extend the fold range"
948
949 $ hg phabsend --fold -r 8:: --test-vcr "$VCR/phabsend-fold-fold-end.json" \
950 > --config experimental.evolution=all
951 15e9b14b4b4c mapped to old nodes ['15e9b14b4b4c']
952 6320b7d714cf mapped to old nodes ['6320b7d714cf']
953 3ee132d41dbc mapped to old nodes ['3ee132d41dbc']
954 30682b960804 mapped to old nodes ['30682b960804']
955 e919cdf3d4fe mapped to old nodes ['6bc15dc99efd', 'b50946d5e490']
956 D8388 - updated - 8:15e9b14b4b4c "added file"
957 D8388 - updated - 9:6320b7d714cf "one: first commit to review"
958 D8388 - updated - 10:3ee132d41dbc "two: second commit to review"
959 D8388 - updated - 11:30682b960804 "3: a commit with no detailed message"
960 D8388 - updated - 16:e919cdf3d4fe tip "four: extend the fold range"
961 updating local commit list for D8388
962 new commits: ['15e9b14b4b4c', '6320b7d714cf', '3ee132d41dbc', '30682b960804', 'e919cdf3d4fe']
963
964 $ hg log -r tip -v
965 "obsolete" feature not enabled but 12 markers found!
966 changeset: 16:e919cdf3d4fe
967 tag: tip
968 parent: 11:30682b960804
969 user: test
970 date: Thu Jan 01 00:00:00 1970 +0000
971 files: file2.txt file3.txt
972 description:
973 four: extend the fold range
974
975 Differential Revision: https://phab.mercurial-scm.org/D8388
976
977
978 Hashes in the messages are updated automatically as phabsend amends and restacks
979 them. This covers both commits that are posted and descendants that are
980 restacked.
981
982 $ cat >> .hg/hgrc << EOF
983 > [experimental]
984 > evolution = all
985 > EOF
986
987 $ echo content > file.txt
988 $ hg ci -m 'base review (generate test for phabsend)'
989 $ echo 'more content' > file.txt
990 $ hg ci -m '133c1c6c6449 is my parent (generate test for phabsend)'
991 $ echo 'even more content' > file.txt
992 $ hg ci -m 'c2874a398f7e is my parent (generate test for phabsend)'
993
994 $ hg phabsend -r 17::18 --test-vcr "$VCR/phabsend-hash-fixes.json"
995 D8945 - created - 17:133c1c6c6449 "base review (generate test for phabsend)"
996 D8946 - created - 18:c2874a398f7e "133c1c6c6449 is my parent (generate test for phabsend)"
997 new commits: ['f444f060f4d6']
998 new commits: ['9c9290f945b1']
999 restabilizing 1528c12fa2e4 as b28b20212bd4
1000
1001 $ hg log -l 3 -Tcompact
1002 22[tip] b28b20212bd4 1970-01-01 00:00 +0000 test
1003 9c9290f945b1 is my parent (generate test for phabsend)
1004
1005 21 9c9290f945b1 1970-01-01 00:00 +0000 test
1006 f444f060f4d6 is my parent (generate test for phabsend)
1007
1008 20:16 f444f060f4d6 1970-01-01 00:00 +0000 test
1009 base review (generate test for phabsend)
1010
1011 $ cd ..