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

r34662:eb586ed5 default
r39595:07b58266 default
Show More
test-mq-safety.t
216 lines | 4.8 KiB | text/troff | Tads3Lexer
Nicolas Dumazet
tests: unify test-mq-safety
r11898 $ echo '[extensions]' >> $HGRCPATH
Pierre-Yves David
mq: prevent rewriting operation on public changeset...
r16048 $ echo 'hgext.mq =' >> $HGRCPATH
Nicolas Dumazet
tests: unify test-mq-safety
r11898
$ hg init repo
$ cd repo
$ echo foo > foo
$ hg ci -qAm 'add a file'
$ hg qinit
$ hg qnew foo
$ echo foo >> foo
$ hg qrefresh -m 'append foo'
$ hg qnew bar
$ echo bar >> foo
$ hg qrefresh -m 'append bar'
Pierre-Yves David
mq: prevent rewriting operation on public changeset...
r16048 Try to operate on public mq changeset
$ hg qpop
popping bar
now at: foo
$ hg phase --public qbase
$ echo babar >> foo
$ hg qref
timeless@mozdev.org
mq: consistently use qrefresh
r26780 abort: cannot qrefresh public revision
timeless
mq: use single quotes in use warning
r29968 (see 'hg help phases' for details)
Pierre-Yves David
mq: prevent rewriting operation on public changeset...
r16048 [255]
$ hg revert -a
reverting foo
$ hg qpop
Jordi Gutiérrez Hermoso
phases: rewrite "immutable changeset" to "public changeset"...
r25411 abort: popping would remove a public revision
timeless
mq: use single quotes in use warning
r29968 (see 'hg help phases' for details)
Pierre-Yves David
mq: prevent rewriting operation on public changeset...
r16048 [255]
$ hg qfold bar
timeless@mozdev.org
mq: consistently use qrefresh
r26780 abort: cannot qrefresh public revision
timeless
mq: use single quotes in use warning
r29968 (see 'hg help phases' for details)
Pierre-Yves David
mq: prevent rewriting operation on public changeset...
r16048 [255]
$ hg revert -a
reverting foo
restore state for remaining test
$ hg qpush
applying bar
now at: bar
Nicolas Dumazet
tests: unify test-mq-safety
r11898
try to commit on top of a patch
$ echo quux >> foo
$ hg ci -m 'append quux'
abort: cannot commit over an applied mq patch
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-mq-safety
r11898
cheat a bit...
$ mv .hg/patches .hg/patches2
$ hg ci -m 'append quux'
$ mv .hg/patches2 .hg/patches
qpop/qrefresh on the wrong revision
$ hg qpop
abort: popping would remove a revision not managed by this patch queue
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: mq-safety: use regular expression instead of sed
r12108 $ hg qpop -n patches
Matt Harbison
tests: remove (glob) annotations that were only for '\' matches...
r35394 using patch queue: $TESTTMP/repo/.hg/patches
Nicolas Dumazet
tests: unify test-mq-safety
r11898 abort: popping would remove a revision not managed by this patch queue
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-mq-safety
r11898 $ hg qrefresh
abort: working directory revision is not qtip
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-mq-safety
r11898
$ hg up -C qtip
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg qpop
abort: popping would remove a revision not managed by this patch queue
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-mq-safety
r11898 $ hg qrefresh
timeless@mozdev.org
mq: consistently use qrefresh
r26780 abort: cannot qrefresh a revision with children
Matt Mackall
tests: add exit codes to unified tests
r12316 [255]
Nicolas Dumazet
tests: unify test-mq-safety
r11898 $ hg tip --template '{rev} {desc}\n'
3 append quux
qpush warning branchheads
$ cd ..
$ hg init branchy
$ cd branchy
$ echo q > q
$ hg add q
$ hg qnew -f qp
$ hg qpop
popping qp
patch queue now empty
$ echo a > a
$ hg ci -Ama
adding a
$ hg up null
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg branch b
marked working directory as branch b
Matt Mackall
branch: warn on branching
r15615 (branches are permanent and global, did you want a bookmark?)
Nicolas Dumazet
tests: unify test-mq-safety
r11898 $ echo c > c
$ hg ci -Amc
adding c
$ hg merge default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg ci -mmerge
$ hg up default
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg log
changeset: 2:65309210bf4e
branch: b
tag: tip
parent: 1:707adb4c8ae1
parent: 0:cb9a9f314b8b
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: merge
changeset: 1:707adb4c8ae1
branch: b
parent: -1:000000000000
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: c
changeset: 0:cb9a9f314b8b
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: a
$ hg qpush
applying qp
now at: qp
Matt Mackall
merge with stable
r12380
Testing applied patches, push and --force
$ cd ..
$ hg init forcepush
$ cd forcepush
$ echo a > a
$ hg ci -Am adda
adding a
$ echo a >> a
$ hg ci -m changea
$ hg up 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg branch branch
marked working directory as branch branch
Matt Mackall
branch: warn on branching
r15615 (branches are permanent and global, did you want a bookmark?)
Matt Mackall
merge with stable
r12380 $ echo b > b
$ hg ci -Am addb
adding b
$ hg up 0
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg --cwd .. clone -r 0 forcepush forcepush2
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
Denis Laxalde
transaction-summary: show the range of new revisions upon pull/unbundle (BC)...
r34662 new changesets 07f494440405
Matt Mackall
merge with stable
r12380 updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo a >> a
$ hg qnew patch
Pushing applied patch with --rev without --force
Pierre-Yves David
mq-safety: don't apply safety on non-outgoing changeset...
r15952 $ hg push -r . ../forcepush2
Matt Mackall
merge with stable
r12380 pushing to ../forcepush2
abort: source has mq patches applied
[255]
Pushing applied patch with branchhash, without --force
$ hg push ../forcepush2#default
pushing to ../forcepush2
abort: source has mq patches applied
[255]
Pushing revs excluding applied patch
Matt Harbison
tests: convert a push test to use revsets
r17199 $ hg push --new-branch -r 'branch(branch)' -r 2 ../forcepush2
Matt Mackall
merge with stable
r12380 pushing to ../forcepush2
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
Pushing applied patch with --force
Pierre-Yves David
mq-safety: don't apply safety on non-outgoing changeset...
r15952 $ hg phase --force --secret 'mq()'
Matt Mackall
merge with stable
r12380 $ hg push --force -r default ../forcepush2
pushing to ../forcepush2
searching for changes
Matt Mackall
scmutil: unify some 'no changes found' messages...
r15993 no changes found (ignored 1 secret changesets)
Matt Mackall
push: return 1 if no changes found (issue3228)...
r16023 [1]
Pierre-Yves David
mq-safety: don't apply safety on non-outgoing changeset...
r15952 $ hg phase --draft 'mq()'
Pierre-Yves David
mq: have mq create secret changeset only
r15926 $ hg push --force -r default ../forcepush2
pushing to ../forcepush2
searching for changes
Matt Mackall
merge with stable
r12380 adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
Mads Kiilerich
tests: add missing trailing 'cd ..'...
r16913
$ cd ..