##// END OF EJS Templates
wireprotov2: implement commands as a generator of objects...
wireprotov2: implement commands as a generator of objects Previously, wire protocol version 2 inherited version 1's model of having separate types to represent the results of different wire protocol commands. As I implemented more powerful commands in future commits, I found I was using a common pattern of returning a special type to hold a generator. This meant the command function required a closure to do most of the work. That made logic flow more difficult to follow. I also noticed that many commands were effectively a sequence of objects to be CBOR encoded. I think it makes sense to define version 2 commands as generators. This way, commands can simply emit the data structures they wish to send to the client. This eliminates the need for a closure in command functions and removes encoding from the bodies of commands. As part of this commit, the handling of response objects has been moved into the serverreactor class. This puts the reactor in the driver's seat with regards to CBOR encoding and error handling. Having error handling in the function that emits frames is particularly important because exceptions in that function can lead to things getting in a bad state: I'm fairly certain that uncaught exceptions in the frame generator were causing deadlocks. I also introduced a dedicated error type for explicit error reporting in command handlers. This will be used in subsequent commits. There's still a bit of work to be done here, especially around formalizing the error handling "protocol." I've added yet another TODO to track this so we don't forget. Test output changed because we're using generators and no longer know we are at the end of the data until we hit the end of the generator. This means we can't emit the end-of-stream flag until we've exhausted the generator. Hence the introduction of 0-sized end-of-stream frames. Differential Revision: https://phab.mercurial-scm.org/D4472

File last commit:

r34505:8cef8f7d default
r39595:07b58266 default
Show More
test-rebase-transaction.t
196 lines | 3.4 KiB | text/troff | Tads3Lexer
/ tests / test-rebase-transaction.t
Martin von Zweigbergk
tests: simplify test-rebase-transaction.t...
r36833 Rebasing using a single transaction
Jun Wu
test-rebase-base: clarify it is about the "--base" flag...
r34505 $ cat >> $HGRCPATH <<EOF
> [extensions]
> rebase=
> drawdag=$TESTDIR/drawdag.py
>
Martin von Zweigbergk
tests: simplify test-rebase-transaction.t...
r36833 > [rebase]
> singletransaction=True
>
Jun Wu
test-rebase-base: clarify it is about the "--base" flag...
r34505 > [phases]
> publish=False
>
> [alias]
> tglog = log -G --template "{rev}: {desc}"
> EOF
Martin von Zweigbergk
tests: simplify test-rebase-transaction.t...
r36833 Check that a simple rebase works
Jun Wu
test-rebase-base: clarify it is about the "--base" flag...
r34505
Martin von Zweigbergk
tests: simplify test-rebase-transaction.t...
r36833 $ hg init simple && cd simple
Jun Wu
test-rebase-base: clarify it is about the "--base" flag...
r34505 $ hg debugdrawdag <<'EOF'
> Z
> |
> | D
> | |
> | C
> | |
> Y B
> |/
> A
> EOF
Martin von Zweigbergk
rebase: also include commit of collapsed commits in single transaction...
r36945 - We should only see one status stored message. It comes from the start.
Jun Wu
test-rebase-base: clarify it is about the "--base" flag...
r34505 $ hg rebase --debug -b D -d Z | grep 'status stored'
rebase status stored
$ hg tglog
o 5: D
|
o 4: C
|
o 3: B
|
o 2: Z
|
o 1: Y
|
o 0: A
$ cd ..
Martin von Zweigbergk
tests: add a few tests involving --collapse and rebase.singletransaction=1...
r36834
Check that --collapse works
$ hg init collapse && cd collapse
$ hg debugdrawdag <<'EOF'
> Z
> |
> | D
> | |
> | C
> | |
> Y B
> |/
> A
> EOF
- We should only see two status stored messages. One from the start, one from
Martin von Zweigbergk
rebase: also include commit of collapsed commits in single transaction...
r36945 - cmdutil.commitforceeditor() which forces tr.writepending()
Martin von Zweigbergk
tests: add a few tests involving --collapse and rebase.singletransaction=1...
r36834 $ hg rebase --collapse --debug -b D -d Z | grep 'status stored'
rebase status stored
rebase status stored
$ hg tglog
o 3: Collapsed revision
| * B
| * C
| * D
o 2: Z
|
o 1: Y
|
o 0: A
$ cd ..
With --collapse, check that conflicts can be resolved and rebase can then be
continued
$ hg init collapse-conflict && cd collapse-conflict
$ hg debugdrawdag <<'EOF'
> Z # Z/conflict=Z
> |
> | D
> | |
> | C # C/conflict=C
> | |
> Y B
> |/
> A
> EOF
$ hg rebase --collapse -b D -d Z
rebasing 1:112478962961 "B" (B)
rebasing 3:c26739dbe603 "C" (C)
merging conflict
warning: conflicts while merging conflict! (edit, then use 'hg resolve --mark')
unresolved conflicts (see hg resolve, then hg rebase --continue)
[1]
$ hg tglog
o 5: D
|
| @ 4: Z
| |
@ | 3: C
| |
| o 2: Y
| |
o | 1: B
|/
o 0: A
$ hg st
M C
M conflict
A B
? conflict.orig
$ echo resolved > conflict
$ hg resolve -m
(no more unresolved files)
continue: hg rebase --continue
$ hg rebase --continue
already rebased 1:112478962961 "B" (B) as 79bc8f4973ce
rebasing 3:c26739dbe603 "C" (C)
rebasing 5:d24bb333861c "D" (D tip)
saved backup bundle to $TESTTMP/collapse-conflict/.hg/strip-backup/112478962961-b5b34645-rebase.hg
$ hg tglog
o 3: Collapsed revision
| * B
| * C
| * D
o 2: Z
|
o 1: Y
|
o 0: A
$ cd ..
With --collapse, check that the commit message editing can be canceled and
rebase can then be continued
$ hg init collapse-cancel-editor && cd collapse-cancel-editor
$ hg debugdrawdag <<'EOF'
> Z
> |
> | D
> | |
> | C
> | |
> Y B
> |/
> A
> EOF
$ HGEDITOR=false hg --config ui.interactive=1 rebase --collapse -b D -d Z
rebasing 1:112478962961 "B" (B)
rebasing 3:26805aba1e60 "C" (C)
rebasing 5:f585351a92f8 "D" (D tip)
Martin von Zweigbergk
rebase: also include commit of collapsed commits in single transaction...
r36945 transaction abort!
rollback completed
Martin von Zweigbergk
tests: add a few tests involving --collapse and rebase.singletransaction=1...
r36834 abort: edit failed: false exited with status 1
[255]
$ hg tglog
o 5: D
|
Martin von Zweigbergk
rebase: also include commit of collapsed commits in single transaction...
r36945 | o 4: Z
Martin von Zweigbergk
tests: add a few tests involving --collapse and rebase.singletransaction=1...
r36834 | |
o | 3: C
| |
| o 2: Y
| |
o | 1: B
|/
o 0: A
$ hg rebase --continue
Martin von Zweigbergk
rebase: also include commit of collapsed commits in single transaction...
r36945 rebasing 1:112478962961 "B" (B)
rebasing 3:26805aba1e60 "C" (C)
rebasing 5:f585351a92f8 "D" (D tip)
Martin von Zweigbergk
tests: add a few tests involving --collapse and rebase.singletransaction=1...
r36834 saved backup bundle to $TESTTMP/collapse-cancel-editor/.hg/strip-backup/112478962961-cb2a9b47-rebase.hg
$ hg tglog
o 3: Collapsed revision
| * B
| * C
| * D
o 2: Z
|
o 1: Y
|
o 0: A
$ cd ..