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

r30296:ab929a17 default
r39595:07b58266 default
Show More
test-convert-darcs.t
108 lines | 2.7 KiB | text/troff | Tads3Lexer
/ tests / test-convert-darcs.t
Matt Mackall
tests: replace exit 80 with #require
r22046 #require darcs
Matt Mackall
tests: unify test-convert-darcs
r12524
$ echo "[extensions]" >> $HGRCPATH
$ echo "convert=" >> $HGRCPATH
$ DARCS_EMAIL='test@example.org'; export DARCS_EMAIL
initialize darcs repo
$ mkdir darcs-repo
$ cd darcs-repo
Yuya Nishihara
tests: silence output of darcs command...
r30296 $ darcs init -q
Matt Mackall
tests: unify test-convert-darcs
r12524 $ echo a > a
$ darcs record -a -l -m p0
Finished recording patch 'p0'
$ cd ..
branch and update
Bryan O'Sullivan
tests: make test-convert-darcs.t happier with darcs 2.8.0
r16698 $ darcs get -q darcs-repo darcs-clone >/dev/null
Matt Mackall
tests: unify test-convert-darcs
r12524 $ cd darcs-clone
$ echo c >> a
$ echo c > c
$ darcs record -a -l -m p1.1
Finished recording patch 'p1.1'
$ cd ..
Patrick Mezard
test-convert-darcs.t: fix elementtree test...
r17448 skip if we can't import elementtree
$ if hg convert darcs-repo darcs-dummy 2>&1 | grep ElementTree > /dev/null; then
> echo 'skipped: missing feature: elementtree module'
> exit 80
> fi
Matt Mackall
tests: unify test-convert-darcs
r12524 update source
$ cd darcs-repo
$ echo b >> a
$ echo b > b
$ darcs record -a -l -m p1.2
Finished recording patch 'p1.2'
Bryan O'Sullivan
tests: make test-convert-darcs.t happier with darcs 2.8.0
r16698 $ darcs pull -q -a --no-set-default ../darcs-clone
Backing up ./a(*) (glob)
Matt Mackall
tests: unify test-convert-darcs
r12524 We have conflicts in the following files:
./a
Yuya Nishihara
tests: silence output of darcs command...
r30296 (?)
Matt Mackall
tests: unify test-convert-darcs
r12524 $ sleep 1
$ echo e > a
$ echo f > f
$ mkdir dir
$ echo d > dir/d
$ echo d > dir/d2
$ darcs record -a -l -m p2
Finished recording patch 'p2'
test file and directory move
Yuya Nishihara
tests: silence output of darcs command...
r30296 $ darcs mv -q f ff
Matt Mackall
tests: unify test-convert-darcs
r12524
Test remove + move
Yuya Nishihara
tests: silence output of darcs command...
r30296 $ darcs remove -q dir/d2
Matt Mackall
tests: unify test-convert-darcs
r12524 $ rm dir/d2
Yuya Nishihara
tests: silence output of darcs command...
r30296 $ darcs mv -q dir dir2
Matt Mackall
tests: unify test-convert-darcs
r12524 $ darcs record -a -l -m p3
Finished recording patch 'p3'
The converter does not currently handle patch conflicts very well.
When they occur, it reverts *all* changes and moves forward,
letting the conflict resolving patch fix collisions.
Unfortunately, non-conflicting changes, like the addition of the
"c" file in p1.1 patch are reverted too.
Just to say that manifest not listing "c" here is a bug.
Matt Mackall
tests: darcs > 2.5 got "smart" about encoding, disable encoding tests...
r15335 $ cd ..
$ hg convert darcs-repo darcs-repo-hg
initializing destination darcs-repo-hg repository
scanning source...
sorting...
converting...
4 p0
3 p1.2
2 p1.1
1 p2
0 p3
$ hg log -R darcs-repo-hg -g --template '{rev} "{desc|firstline}" ({author}) files: {files}\n' "$@"
4 "p3" (test@example.org) files: dir/d dir/d2 dir2/d f ff
3 "p2" (test@example.org) files: a dir/d dir/d2 f
2 "p1.1" (test@example.org) files:
1 "p1.2" (test@example.org) files: a b
0 "p0" (test@example.org) files: a
Matt Mackall
merge with stable
r12718
Matt Mackall
tests: unify test-convert-darcs
r12524 $ hg up -q -R darcs-repo-hg
$ hg -R darcs-repo-hg manifest --debug
7225b30cdf38257d5cc7780772c051b6f33e6d6b 644 a
1e88685f5ddec574a34c70af492f95b6debc8741 644 b
37406831adc447ec2385014019599dfec953c806 644 dir2/d
b783a337463792a5c7d548ad85a7d3253c16ba8c 644 ff
Patrick Mezard
test-convert-darcs.t: fix elementtree test...
r17448
#if no-outer-repo
try converting darcs1 repository
$ hg clone -q "$TESTDIR/bundles/darcs1.hg" darcs
$ hg convert -s darcs darcs/darcs1 2>&1 | grep darcs-1.0
darcs-1.0 repository format is unsupported, please upgrade
#endif