##// 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-url-rev.t
332 lines | 7.6 KiB | text/troff | Tads3Lexer
Matt Mackall
tests: fix a bunch of pointless #s in unified tests
r12328 Test basic functionality of url#rev syntax
Adrian Buehlmann
tests: unify test-url-rev
r12300
$ hg init repo
$ cd repo
$ echo a > a
$ hg ci -qAm 'add a'
$ hg branch foo
marked working directory as branch foo
Matt Mackall
branch: warn on branching
r15615 (branches are permanent and global, did you want a bookmark?)
Adrian Buehlmann
tests: unify test-url-rev
r12300 $ echo >> a
$ hg ci -m 'change a'
$ cd ..
$ hg clone 'repo#foo' clone
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 1 files
Denis Laxalde
transaction-summary: show the range of new revisions upon pull/unbundle (BC)...
r34662 new changesets 1f0dee641bb7:cd2a86ecc814
Adrian Buehlmann
tests: unify test-url-rev
r12300 updating to branch foo
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg --cwd clone heads
changeset: 1:cd2a86ecc814
branch: foo
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: change a
changeset: 0:1f0dee641bb7
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: add a
$ hg --cwd clone parents
changeset: 1:cd2a86ecc814
branch: foo
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: change a
$ cat clone/.hg/hgrc
timeless
samplehgrcs: use single quotes in use warning
r29978 # example repository config (see 'hg help config' for more info)
Jordi Gutiérrez Hermoso
config: use the same hgrc for a cloned repo as for an uninitted repo...
r22837 [paths]
Matt Harbison
tests: remove (glob) annotations that were only for '\' matches...
r35394 default = $TESTTMP/repo#foo
Jordi Gutiérrez Hermoso
config: use the same hgrc for a cloned repo as for an uninitted repo...
r22837
# path aliases to other clones of this repo in URLs or filesystem paths
timeless
samplehgrcs: use single quotes in use warning
r29978 # (see 'hg help config.paths' for more info)
Jordi Gutiérrez Hermoso
config: use the same hgrc for a cloned repo as for an uninitted repo...
r22837 #
Rishabh Madan
ui: replace obsolete default-push with default:pushurl (issue5485)...
r31064 # default:pushurl = ssh://jdoe@example.net/hg/jdoes-fork
# my-fork = ssh://jdoe@example.net/hg/jdoes-fork
# my-clone = /home/jdoe/jdoes-clone
Jordi Gutiérrez Hermoso
config: use the same hgrc for a cloned repo as for an uninitted repo...
r22837
[ui]
# name and email (local to this repository, optional), e.g.
Augie Fackler
clone: provide sample username = config entry in .hg/hgrc (issue4359)...
r22380 # username = Jane Doe <jdoe@example.com>
Adrian Buehlmann
tests: unify test-url-rev
r12300
Changing original repo:
$ cd repo
$ echo >> a
$ hg ci -m 'new head of branch foo'
$ hg up -qC default
$ echo bar > bar
$ hg ci -qAm 'add bar'
$ hg log
changeset: 3:4cd725637392
tag: tip
parent: 0:1f0dee641bb7
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: add bar
changeset: 2:faba9097cad4
branch: foo
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: new head of branch foo
changeset: 1:cd2a86ecc814
branch: foo
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: change a
changeset: 0:1f0dee641bb7
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: add a
FUJIWARA Katsunori
summary: make "outgoing" information sensitive to branch in URL (issue3829)...
r18994 $ hg -q outgoing '../clone'
2:faba9097cad4
3:4cd725637392
$ hg summary --remote --config paths.default='../clone'
parent: 3:4cd725637392 tip
add bar
branch: default
commit: (clean)
update: (current)
Gilles Moris
summary: move the parents phase marker to commit line (issue4688)...
r25382 phases: 4 draft
FUJIWARA Katsunori
summary: make "outgoing" information sensitive to branch in URL (issue3829)...
r18994 remote: 2 outgoing
Adrian Buehlmann
tests: unify test-url-rev
r12300 $ hg -q outgoing '../clone#foo'
2:faba9097cad4
FUJIWARA Katsunori
summary: make "outgoing" information sensitive to branch in URL (issue3829)...
r18994 $ hg summary --remote --config paths.default='../clone#foo'
parent: 3:4cd725637392 tip
add bar
branch: default
commit: (clean)
update: (current)
Gilles Moris
summary: move the parents phase marker to commit line (issue4688)...
r25382 phases: 4 draft
FUJIWARA Katsunori
summary: make "outgoing" information sensitive to branch in URL (issue3829)...
r18994 remote: 1 outgoing
Adrian Buehlmann
tests: unify test-url-rev
r12300
FUJIWARA Katsunori
summary: make "incoming" information sensitive to branch in URL (issue3830)...
r18996 $ hg -q --cwd ../clone incoming '../repo#foo'
2:faba9097cad4
$ hg --cwd ../clone summary --remote --config paths.default='../repo#foo'
parent: 1:cd2a86ecc814 tip
change a
branch: foo
commit: (clean)
update: (current)
remote: 1 or more incoming
Adrian Buehlmann
tests: unify test-url-rev
r12300 $ hg -q push '../clone#foo'
$ hg --cwd ../clone heads
changeset: 2:faba9097cad4
branch: foo
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: new head of branch foo
changeset: 0:1f0dee641bb7
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: add a
FUJIWARA Katsunori
summary: make "incoming" information sensitive to branch in URL (issue3830)...
r18996 $ hg -q --cwd ../clone incoming '../repo#foo'
[1]
$ hg --cwd ../clone summary --remote --config paths.default='../repo#foo'
parent: 1:cd2a86ecc814
change a
branch: foo
commit: (clean)
update: 1 new changesets (update)
remote: (synced)
Adrian Buehlmann
tests: unify test-url-rev
r12300 $ cd ..
$ cd clone
$ hg rollback
Gilles Moris
rollback: clarifies the message about the reverted state (issue2628)...
r13446 repository tip rolled back to revision 1 (undo push)
Adrian Buehlmann
tests: unify test-url-rev
r12300
$ hg -q incoming
2:faba9097cad4
$ hg -q pull
$ hg heads
changeset: 2:faba9097cad4
branch: foo
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: new head of branch foo
changeset: 0:1f0dee641bb7
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: add a
Pull should not have updated:
$ hg parents -q
1:cd2a86ecc814
Going back to the default branch:
$ hg up -C 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg parents
changeset: 0:1f0dee641bb7
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: add a
No new revs, no update:
$ hg pull -qu
$ hg parents -q
0:1f0dee641bb7
$ hg rollback
Gilles Moris
rollback: clarifies the message about the reverted state (issue2628)...
r13446 repository tip rolled back to revision 1 (undo pull)
Adrian Buehlmann
tests: unify test-url-rev
r12300
$ hg parents -q
0:1f0dee641bb7
Pull -u takes us back to branch foo:
$ hg pull -qu
$ hg parents
changeset: 2:faba9097cad4
branch: foo
tag: tip
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: new head of branch foo
$ hg rollback
Gilles Moris
rollback: clarifies the message about the reverted state (issue2628)...
r13446 repository tip rolled back to revision 1 (undo pull)
working directory now based on revision 0
Adrian Buehlmann
tests: unify test-url-rev
r12300
$ hg up -C 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg parents -q
0:1f0dee641bb7
$ hg heads -q
1:cd2a86ecc814
0:1f0dee641bb7
$ hg pull -qur default default
$ hg parents
changeset: 3:4cd725637392
tag: tip
parent: 0:1f0dee641bb7
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: add bar
$ hg heads
changeset: 3:4cd725637392
tag: tip
parent: 0:1f0dee641bb7
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: add bar
changeset: 2:faba9097cad4
branch: foo
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: new head of branch foo
Mads Kiilerich
httprepo: make __del__ more stable in error situations...
r15246 Test handling of invalid urls
Adrian Buehlmann
tests: unify test-url-rev
r12300
Mads Kiilerich
httprepo: make __del__ more stable in error situations...
r15246 $ hg id http://foo/?bar
abort: unsupported URL component: "bar"
[255]
Mads Kiilerich
tests: add missing trailing 'cd ..'...
r16913
$ cd ..
FUJIWARA Katsunori
summary: clear "commonincoming" also if branches are different...
r18997
Test handling common incoming revisions between "default" and
"default-push"
$ hg -R clone rollback
repository tip rolled back to revision 1 (undo pull)
working directory now based on revision 0
$ cd repo
$ hg update -q -C default
$ echo modified >> bar
$ hg commit -m "new head to push current default head"
$ hg -q push -r ".^1" '../clone'
$ hg -q outgoing '../clone'
2:faba9097cad4
4:d515801a8f3d
$ hg summary --remote --config paths.default='../clone#default' --config paths.default-push='../clone#foo'
parent: 4:d515801a8f3d tip
new head to push current default head
branch: default
commit: (clean)
update: (current)
Gilles Moris
summary: move the parents phase marker to commit line (issue4688)...
r25382 phases: 1 draft
FUJIWARA Katsunori
summary: clear "commonincoming" also if branches are different...
r18997 remote: 1 outgoing
$ hg summary --remote --config paths.default='../clone#foo' --config paths.default-push='../clone'
parent: 4:d515801a8f3d tip
new head to push current default head
branch: default
commit: (clean)
update: (current)
Gilles Moris
summary: move the parents phase marker to commit line (issue4688)...
r25382 phases: 1 draft
FUJIWARA Katsunori
summary: clear "commonincoming" also if branches are different...
r18997 remote: 2 outgoing
$ hg summary --remote --config paths.default='../clone' --config paths.default-push='../clone#foo'
parent: 4:d515801a8f3d tip
new head to push current default head
branch: default
commit: (clean)
update: (current)
Gilles Moris
summary: move the parents phase marker to commit line (issue4688)...
r25382 phases: 1 draft
FUJIWARA Katsunori
summary: clear "commonincoming" also if branches are different...
r18997 remote: 1 outgoing
$ hg clone -q -r 0 . ../another
$ hg -q outgoing '../another#default'
3:4cd725637392
4:d515801a8f3d
$ hg summary --remote --config paths.default='../another#default' --config paths.default-push='../clone#default'
parent: 4:d515801a8f3d tip
new head to push current default head
branch: default
commit: (clean)
update: (current)
Gilles Moris
summary: move the parents phase marker to commit line (issue4688)...
r25382 phases: 1 draft
FUJIWARA Katsunori
summary: clear "commonincoming" also if branches are different...
r18997 remote: 1 outgoing
$ cd ..
Yuya Nishihara
url: fix crash by empty path with #fragments...
r30036
Test url#rev syntax of local destination path, which should be taken as
a 'url#rev' path
$ hg clone repo '#foo'
updating to branch default
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg root -R '#foo'
Matt Harbison
tests: remove (glob) annotations that were only for '\' matches...
r35394 $TESTTMP/#foo