##// 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:

r28065:6b1fc09c default
r39595:07b58266 default
Show More
test-merge5.t
36 lines | 837 B | text/troff | Tads3Lexer
Pradeepkumar Gayam
tests: unify test-merge5
r11978 $ hg init
$ echo This is file a1 > a
$ echo This is file b1 > b
$ hg add a b
Martin Geisler
test-merge5: removed unnecessary parts of test...
r12155 $ hg commit -m "commit #0"
Pradeepkumar Gayam
tests: unify test-merge5
r11978 $ echo This is file b22 > b
Martin Geisler
test-merge5: removed unnecessary parts of test...
r12155 $ hg commit -m "comment #1"
Pradeepkumar Gayam
tests: unify test-merge5
r11978 $ hg update 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ rm b
Martin Geisler
test-merge5: removed unnecessary parts of test...
r12155 $ hg commit -A -m "comment #2"
Pradeepkumar Gayam
tests: unify test-merge5
r11978 removing b
created new head
Brodie Rao
test-merge5: ensure updating to tip across branches is tested...
r12154 $ hg update 1
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
Matt Mackall
update: check for missing files with --check (issue3595)
r17849 $ rm b
Pierre-Yves David
update: change default destination to tipmost descendant (issue4673) (BC)...
r28065 $ hg update -c 2
Siddharth Agarwal
update: standardize error message for dirty update --check...
r19801 abort: uncommitted changes
Matt Mackall
update: check for missing files with --check (issue3595)
r17849 [255]
$ hg revert b
Pierre-Yves David
update: change default destination to tipmost descendant (issue4673) (BC)...
r28065 $ hg update -c 2
Brodie Rao
test-merge5: ensure updating to tip across branches is tested...
r12154 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
Pradeepkumar Gayam
tests: unify test-merge5
r11978 $ mv a c
Martin Geisler
test-merge5: removed unnecessary parts of test...
r12155 Should abort:
Martin von Zweigbergk
test-merge5: remove obsolete '-y' and its motivating comment...
r23026 $ hg update 1
Siddharth Agarwal
update: add error message for dirty non-linear update with no rev...
r19799 abort: uncommitted changes
(commit or update --clean to discard changes)
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Pradeepkumar Gayam
tests: unify test-merge5
r11978 $ mv c a
Martin Geisler
test-merge5: removed unnecessary parts of test...
r12155
Should succeed:
Martin von Zweigbergk
test-merge5: remove obsolete '-y' and its motivating comment...
r23026 $ hg update 1
Pradeepkumar Gayam
tests: unify test-merge5
r11978 1 files updated, 0 files merged, 0 files removed, 0 files unresolved