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

r35230:feecfefe default
r39595:07b58266 default
Show More
test-status-rev.t
158 lines | 6.2 KiB | text/troff | Tads3Lexer
/ tests / test-status-rev.t
Martin von Zweigbergk
status: add more complete tests for --rev...
r23037 Tests of 'hg status --rev <rev>' to make sure status between <rev> and '.' get
combined correctly with the dirstate status.
$ hg init
Martin von Zweigbergk
test-status-rev: use same names as from generate-working-copy-states...
r23196 First commit
Martin von Zweigbergk
status: add more complete tests for --rev...
r23037
Augie Fackler
cleanup: use $PYTHON to run python in many more tests...
r32940 $ $PYTHON $TESTDIR/generate-working-copy-states.py state 2 1
Martin von Zweigbergk
test-status-rev: use common script for generating file history...
r23197 $ hg addremove --similarity 0
adding content1_content1_content1-tracked
adding content1_content1_content1-untracked
adding content1_content1_content3-tracked
adding content1_content1_content3-untracked
adding content1_content1_missing-tracked
adding content1_content1_missing-untracked
adding content1_content2_content1-tracked
adding content1_content2_content1-untracked
adding content1_content2_content2-tracked
adding content1_content2_content2-untracked
adding content1_content2_content3-tracked
adding content1_content2_content3-untracked
adding content1_content2_missing-tracked
adding content1_content2_missing-untracked
adding content1_missing_content1-tracked
adding content1_missing_content1-untracked
adding content1_missing_content3-tracked
adding content1_missing_content3-untracked
adding content1_missing_missing-tracked
adding content1_missing_missing-untracked
$ hg commit -m first
Martin von Zweigbergk
status: add more complete tests for --rev...
r23037
Martin von Zweigbergk
test-status-rev: use same names as from generate-working-copy-states...
r23196 Second commit
Martin von Zweigbergk
status: add more complete tests for --rev...
r23037
Augie Fackler
cleanup: use $PYTHON to run python in many more tests...
r32940 $ $PYTHON $TESTDIR/generate-working-copy-states.py state 2 2
Martin von Zweigbergk
test-status-rev: use common script for generating file history...
r23197 $ hg addremove --similarity 0
removing content1_missing_content1-tracked
removing content1_missing_content1-untracked
removing content1_missing_content3-tracked
removing content1_missing_content3-untracked
removing content1_missing_missing-tracked
removing content1_missing_missing-untracked
adding missing_content2_content2-tracked
adding missing_content2_content2-untracked
adding missing_content2_content3-tracked
adding missing_content2_content3-untracked
adding missing_content2_missing-tracked
adding missing_content2_missing-untracked
$ hg commit -m second
Martin von Zweigbergk
status: add more complete tests for --rev...
r23037
Martin von Zweigbergk
test-status-rev: use same names as from generate-working-copy-states...
r23196 Working copy
Martin von Zweigbergk
status: add more complete tests for --rev...
r23037
Augie Fackler
cleanup: use $PYTHON to run python in many more tests...
r32940 $ $PYTHON $TESTDIR/generate-working-copy-states.py state 2 wc
Martin von Zweigbergk
test-status-rev: use common script for generating file history...
r23197 $ hg addremove --similarity 0
adding content1_missing_content1-tracked
adding content1_missing_content1-untracked
adding content1_missing_content3-tracked
adding content1_missing_content3-untracked
adding content1_missing_missing-tracked
adding content1_missing_missing-untracked
adding missing_missing_content3-tracked
adding missing_missing_content3-untracked
adding missing_missing_missing-tracked
adding missing_missing_missing-untracked
$ hg forget *_*_*-untracked
$ rm *_*_missing-*
Martin von Zweigbergk
status: add more complete tests for --rev...
r23037
Martin von Zweigbergk
test-status-rev: add tests for plain dirstate and inter-revision status...
r23230 Status compared to parent of the working copy, i.e. the dirstate status
$ hg status -A --rev 1 'glob:missing_content2_content3-tracked'
M missing_content2_content3-tracked
$ hg status -A --rev 1 'glob:missing_content2_content2-tracked'
C missing_content2_content2-tracked
$ hg status -A --rev 1 'glob:missing_missing_content3-tracked'
A missing_missing_content3-tracked
$ hg status -A --rev 1 'glob:missing_missing_content3-untracked'
? missing_missing_content3-untracked
$ hg status -A --rev 1 'glob:missing_content2_*-untracked'
R missing_content2_content2-untracked
R missing_content2_content3-untracked
R missing_content2_missing-untracked
$ hg status -A --rev 1 'glob:missing_*_missing-tracked'
! missing_content2_missing-tracked
! missing_missing_missing-tracked
Matt Harbison
test-status-rev: conditionalize output instead of tests
r33343
Matt Harbison
tests: handle differences between missing file error strings on Windows and Unix
r23353 $ hg status -A --rev 1 'glob:missing_missing_missing-untracked'
Matt Harbison
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages...
r35230 missing_missing_missing-untracked: $ENOENT$
Martin von Zweigbergk
test-status-rev: add tests for plain dirstate and inter-revision status...
r23230
Status between first and second commit. Should ignore dirstate status.
$ hg status -A --rev 0:1 'glob:content1_content2_*'
M content1_content2_content1-tracked
M content1_content2_content1-untracked
M content1_content2_content2-tracked
M content1_content2_content2-untracked
M content1_content2_content3-tracked
M content1_content2_content3-untracked
M content1_content2_missing-tracked
M content1_content2_missing-untracked
$ hg status -A --rev 0:1 'glob:content1_content1_*'
C content1_content1_content1-tracked
C content1_content1_content1-untracked
C content1_content1_content3-tracked
C content1_content1_content3-untracked
C content1_content1_missing-tracked
C content1_content1_missing-untracked
$ hg status -A --rev 0:1 'glob:missing_content2_*'
A missing_content2_content2-tracked
A missing_content2_content2-untracked
A missing_content2_content3-tracked
A missing_content2_content3-untracked
A missing_content2_missing-tracked
A missing_content2_missing-untracked
$ hg status -A --rev 0:1 'glob:content1_missing_*'
R content1_missing_content1-tracked
R content1_missing_content1-untracked
R content1_missing_content3-tracked
R content1_missing_content3-untracked
R content1_missing_missing-tracked
R content1_missing_missing-untracked
$ hg status -A --rev 0:1 'glob:missing_missing_*'
Status compared to one revision back, checking that the dirstate status
is correctly combined with the inter-revision status
Martin von Zweigbergk
status: add more complete tests for --rev...
r23037
Martin von Zweigbergk
test-status-rev: remove unnecessary initial commit...
r23229 $ hg status -A --rev 0 'glob:content1_*_content[23]-tracked'
Martin von Zweigbergk
test-status-rev: use same names as from generate-working-copy-states...
r23196 M content1_content1_content3-tracked
Martin von Zweigbergk
test-status-rev: use one glob for each expected status...
r23228 M content1_content2_content2-tracked
M content1_content2_content3-tracked
M content1_missing_content3-tracked
Martin von Zweigbergk
test-status-rev: remove unnecessary initial commit...
r23229 $ hg status -A --rev 0 'glob:content1_*_content1-tracked'
Martin von Zweigbergk
test-status-rev: use one glob for each expected status...
r23228 C content1_content1_content1-tracked
C content1_content2_content1-tracked
C content1_missing_content1-tracked
Martin von Zweigbergk
test-status-rev: remove unnecessary initial commit...
r23229 $ hg status -A --rev 0 'glob:missing_*_content?-tracked'
Martin von Zweigbergk
test-status-rev: use one glob for each expected status...
r23228 A missing_content2_content2-tracked
A missing_content2_content3-tracked
A missing_missing_content3-tracked
BROKEN: missing_content2_content[23]-untracked exist, so should be listed
Martin von Zweigbergk
test-status-rev: remove unnecessary initial commit...
r23229 $ hg status -A --rev 0 'glob:missing_*_content?-untracked'
Martin von Zweigbergk
test-status-rev: use one glob for each expected status...
r23228 ? missing_missing_content3-untracked
Martin von Zweigbergk
test-status-rev: remove unnecessary initial commit...
r23229 $ hg status -A --rev 0 'glob:content1_*_*-untracked'
Martin von Zweigbergk
test-status-rev: use one glob for each expected status...
r23228 R content1_content1_content1-untracked
R content1_content1_content3-untracked
Martin von Zweigbergk
test-status-rev: use same names as from generate-working-copy-states...
r23196 R content1_content1_missing-untracked
Martin von Zweigbergk
test-status-rev: use one glob for each expected status...
r23228 R content1_content2_content1-untracked
Martin von Zweigbergk
test-status-rev: use same names as from generate-working-copy-states...
r23196 R content1_content2_content2-untracked
Martin von Zweigbergk
test-status-rev: use one glob for each expected status...
r23228 R content1_content2_content3-untracked
Martin von Zweigbergk
test-status-rev: use same names as from generate-working-copy-states...
r23196 R content1_content2_missing-untracked
Martin von Zweigbergk
test-status-rev: use one glob for each expected status...
r23228 R content1_missing_content1-untracked
R content1_missing_content3-untracked
R content1_missing_missing-untracked
Martin von Zweigbergk
test-status-rev: remove unnecessary initial commit...
r23229 $ hg status -A --rev 0 'glob:*_*_missing-tracked'
Martin von Zweigbergk
test-status-rev: use one glob for each expected status...
r23228 ! content1_content1_missing-tracked
! content1_content2_missing-tracked
Martin von Zweigbergk
test-status-rev: use same names as from generate-working-copy-states...
r23196 ! content1_missing_missing-tracked
! missing_content2_missing-tracked
Martin von Zweigbergk
test-status-rev: use one glob for each expected status...
r23228 ! missing_missing_missing-tracked
Martin von Zweigbergk
test-status-rev: remove unnecessary initial commit...
r23229 $ hg status -A --rev 0 'glob:missing_*_missing-untracked'