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

r38268:d0abd794 @34 default
r39595:07b58266 default
Show More
test-obsolete-checkheads.t
317 lines | 7.6 KiB | text/troff | Tads3Lexer
/ tests / test-obsolete-checkheads.t
Pierre-Yves David
test: add testing of checkheads behavior with obsolete...
r17546 Check that obsolete properly strip heads
$ cat >> $HGRCPATH << EOF
> [phases]
> # public changeset are not obsolete
> publish=false
> [ui]
> logtemplate='{node|short} ({phase}) {desc|firstline}\n'
Durham Goode
obsolete: update tests to use obsolete options...
r22955 > [experimental]
Boris Feld
config: use 'experimental.evolution.create-markers'...
r34867 > evolution.createmarkers=True
Pierre-Yves David
test: add testing of checkheads behavior with obsolete...
r17546 > EOF
$ mkcommit() {
> echo "$1" > "$1"
> hg add "$1"
> hg ci -m "add $1"
> }
$ getid() {
> hg id --debug -ir "desc('$1')"
> }
$ hg init remote
$ cd remote
$ mkcommit base
$ hg phase --public .
$ cd ..
Jun Wu
tests: replace "cp -r" with "cp -R"...
r30556 $ cp -R remote base
Pierre-Yves David
test: add testing of checkheads behavior with obsolete...
r17546 $ hg clone remote local
updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd local
New head replaces old head
==========================
setup
Pierre-Yves David
push: refuse to push bumped changeset...
r17834 (we add the 1 flags to prevent bumped error during the test)
Pierre-Yves David
test: add testing of checkheads behavior with obsolete...
r17546
$ mkcommit old
$ hg push
Matt Harbison
tests: remove (glob) annotations that were only for '\' matches...
r35394 pushing to $TESTTMP/remote
Pierre-Yves David
test: add testing of checkheads behavior with obsolete...
r17546 searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
$ hg up -q '.^'
$ mkcommit new
created new head
Pierre-Yves David
push: refuse to push bumped changeset...
r17834 $ hg debugobsolete --flags 1 `getid old` `getid new`
Boris Feld
debugobsolete: also report the number of obsoleted changesets...
r33542 obsoleted 1 changesets
Martin Geisler
tests: don't load unnecessary graphlog extension...
r20117 $ hg log -G --hidden
Pierre-Yves David
test: add testing of checkheads behavior with obsolete...
r17546 @ 71e3228bffe1 (draft) add new
|
| x c70b08862e08 (draft) add old
|/
o b4952fcf48cf (public) add base
Jun Wu
tests: replace "cp -r" with "cp -R"...
r30556 $ cp -R ../remote ../backup1
Pierre-Yves David
test: add testing of checkheads behavior with obsolete...
r17546
old exists remotely as draft. It is obsoleted by new that we now push.
Push should not warn about creating new head
$ hg push
Matt Harbison
tests: remove (glob) annotations that were only for '\' matches...
r35394 pushing to $TESTTMP/remote
Pierre-Yves David
test: add testing of checkheads behavior with obsolete...
r17546 searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
Pierre-Yves David
checkheads: attend to phases when computing new heads with obsolete...
r17547 old head is now public (public local version)
=============================================
setup
$ rm -fr ../remote
Jun Wu
tests: replace "cp -r" with "cp -R"...
r30556 $ cp -R ../backup1 ../remote
Pierre-Yves David
checkheads: attend to phases when computing new heads with obsolete...
r17547 $ hg -R ../remote phase --public c70b08862e08
$ hg pull -v
Matt Harbison
tests: remove (glob) annotations that were only for '\' matches...
r35394 pulling from $TESTTMP/remote
Pierre-Yves David
checkheads: attend to phases when computing new heads with obsolete...
r17547 searching for changes
no changes found
Boris Feld
phases: use "published" in the phase movement message...
r38268 1 local changesets published
Martin Geisler
tests: don't load unnecessary graphlog extension...
r20117 $ hg log -G --hidden
Pierre-Yves David
checkheads: attend to phases when computing new heads with obsolete...
r17547 @ 71e3228bffe1 (draft) add new
|
| o c70b08862e08 (public) add old
|/
o b4952fcf48cf (public) add base
Abort: old will still be an head because it's public.
$ hg push
Matt Harbison
tests: remove (glob) annotations that were only for '\' matches...
r35394 pushing to $TESTTMP/remote
Pierre-Yves David
checkheads: attend to phases when computing new heads with obsolete...
r17547 searching for changes
abort: push creates new remote head 71e3228bffe1!
timeless
discovery: use single quotes in use warning
r29973 (merge or see 'hg help push' for details about pushing new heads)
Pierre-Yves David
checkheads: attend to phases when computing new heads with obsolete...
r17547 [255]
old head is now public (public remote version)
==============================================
TODO: Not implemented yet.
# setup
#
# $ rm -fr ../remote
Jun Wu
tests: replace "cp -r" with "cp -R"...
r30556 # $ cp -R ../backup1 ../remote
Pierre-Yves David
checkheads: attend to phases when computing new heads with obsolete...
r17547 # $ hg -R ../remote phase --public c70b08862e08
# $ hg phase --draft --force c70b08862e08
Martin Geisler
tests: don't load unnecessary graphlog extension...
r20117 # $ hg log -G --hidden
Pierre-Yves David
checkheads: attend to phases when computing new heads with obsolete...
r17547 # @ 71e3228bffe1 (draft) add new
# |
# | x c70b08862e08 (draft) add old
# |/
# o b4952fcf48cf (public) add base
#
#
#
# Abort: old will still be an head because it's public.
#
# $ hg push
# pushing to $TESTTMP/remote
# searching for changes
# abort: push creates new remote head 71e3228bffe1!
timeless
tests: favor single quotes for wrapping hg help ...
r29979 # (merge or see 'hg help push' for details about pushing new heads)
Pierre-Yves David
checkheads: attend to phases when computing new heads with obsolete...
r17547 # [255]
old head is obsolete but replacement is not pushed
Pierre-Yves David
test: add testing of checkheads behavior with obsolete...
r17546 ==================================================
setup
$ rm -fr ../remote
Jun Wu
tests: replace "cp -r" with "cp -R"...
r30556 $ cp -R ../backup1 ../remote
Pierre-Yves David
checkheads: attend to phases when computing new heads with obsolete...
r17547 $ hg phase --draft --force '(0::) - 0'
Pierre-Yves David
test: add testing of checkheads behavior with obsolete...
r17546 $ hg up -q '.^'
$ mkcommit other
created new head
Martin Geisler
tests: don't load unnecessary graphlog extension...
r20117 $ hg log -G --hidden
Pierre-Yves David
test: add testing of checkheads behavior with obsolete...
r17546 @ d7d41ccbd4de (draft) add other
|
| o 71e3228bffe1 (draft) add new
|/
| x c70b08862e08 (draft) add old
|/
o b4952fcf48cf (public) add base
old exists remotely as draft. It is obsoleted by new but we don't push new.
Push should abort on new head
$ hg push -r 'desc("other")'
Matt Harbison
tests: remove (glob) annotations that were only for '\' matches...
r35394 pushing to $TESTTMP/remote
Pierre-Yves David
test: add testing of checkheads behavior with obsolete...
r17546 searching for changes
abort: push creates new remote head d7d41ccbd4de!
timeless
discovery: use single quotes in use warning
r29973 (merge or see 'hg help push' for details about pushing new heads)
Pierre-Yves David
test: add testing of checkheads behavior with obsolete...
r17546 [255]
Pierre-Yves David
checkheads: check successors for new heads in both missing and common...
r17548
Both precursors and successors are already know remotely. Descendant adds heads
===============================================================================
setup. (The obsolete marker is known locally only
$ cd ..
$ rm -rf local
$ hg clone remote local
updating to branch default
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd local
$ mkcommit old
old already tracked!
nothing changed
[1]
$ hg up -q '.^'
$ mkcommit new
created new head
$ hg push -f
Matt Harbison
tests: remove (glob) annotations that were only for '\' matches...
r35394 pushing to $TESTTMP/remote
Pierre-Yves David
checkheads: check successors for new heads in both missing and common...
r17548 searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
$ mkcommit desc1
$ hg up -q '.^'
$ mkcommit desc2
created new head
$ hg debugobsolete `getid old` `getid new`
Boris Feld
debugobsolete: also report the number of obsoleted changesets...
r33542 obsoleted 1 changesets
Martin Geisler
tests: don't load unnecessary graphlog extension...
r20117 $ hg log -G --hidden
Pierre-Yves David
checkheads: check successors for new heads in both missing and common...
r17548 @ 5fe37041cc2b (draft) add desc2
|
| o a3ef1d111c5f (draft) add desc1
|/
o 71e3228bffe1 (draft) add new
|
| x c70b08862e08 (draft) add old
|/
o b4952fcf48cf (public) add base
Martin Geisler
tests: don't load unnecessary graphlog extension...
r20117 $ hg log -G --hidden -R ../remote
Pierre-Yves David
checkheads: check successors for new heads in both missing and common...
r17548 o 71e3228bffe1 (draft) add new
|
| o c70b08862e08 (draft) add old
|/
@ b4952fcf48cf (public) add base
Jun Wu
tests: replace "cp -r" with "cp -R"...
r30556 $ cp -R ../remote ../backup2
Pierre-Yves David
checkheads: check successors for new heads in both missing and common...
r17548
Push should not warn about adding new heads. We create one, but we'll delete
one anyway.
$ hg push
Matt Harbison
tests: remove (glob) annotations that were only for '\' matches...
r35394 pushing to $TESTTMP/remote
Pierre-Yves David
checkheads: check successors for new heads in both missing and common...
r17548 searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files (+1 heads)
Remote head is unknown but obsoleted by a local changeset
=========================================================
setup
$ rm -fr ../remote
Jun Wu
tests: replace "cp -r" with "cp -R"...
r30556 $ cp -R ../backup1 ../remote
Pierre-Yves David
checkheads: check successors for new heads in both missing and common...
r17548 $ cd ..
$ rm -rf local
$ hg clone remote local -r 0
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 b4952fcf48cf
Pierre-Yves David
checkheads: check successors for new heads in both missing and common...
r17548 updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd local
$ mkcommit new
$ hg -R ../remote id --debug -r tip
c70b08862e0838ea6d7c59c85da2f1ed6c8d67da tip
$ hg id --debug -r tip
71e3228bffe1886550777233d6c97bb5a6b2a650 tip
$ hg debugobsolete c70b08862e0838ea6d7c59c85da2f1ed6c8d67da 71e3228bffe1886550777233d6c97bb5a6b2a650
Martin Geisler
tests: don't load unnecessary graphlog extension...
r20117 $ hg log -G --hidden
Pierre-Yves David
checkheads: check successors for new heads in both missing and common...
r17548 @ 71e3228bffe1 (draft) add new
|
o b4952fcf48cf (public) add base
Martin Geisler
tests: don't load unnecessary graphlog extension...
r20117 $ hg log -G --hidden -R ../remote
Pierre-Yves David
checkheads: check successors for new heads in both missing and common...
r17548 o c70b08862e08 (draft) add old
|
@ b4952fcf48cf (public) add base
Pierre-Yves David
checkheads: upgrade the obsolescence postprocessing logic (issue4354)...
r32009 We do not have enought data to take the right decision, we should fail
$ hg push
Matt Harbison
tests: remove (glob) annotations that were only for '\' matches...
r35394 pushing to $TESTTMP/remote
Pierre-Yves David
checkheads: upgrade the obsolescence postprocessing logic (issue4354)...
r32009 searching for changes
remote has heads on branch 'default' that are not known locally: c70b08862e08
abort: push creates new remote head 71e3228bffe1!
(pull and merge or see 'hg help push' for details about pushing new heads)
[255]
Pierre-Yves David
checkheads: check successors for new heads in both missing and common...
r17548
Pierre-Yves David
checkheads: upgrade the obsolescence postprocessing logic (issue4354)...
r32009 Pulling the missing data makes it work
$ hg pull
Matt Harbison
tests: remove (glob) annotations that were only for '\' matches...
r35394 pulling from $TESTTMP/remote
Pierre-Yves David
checkheads: upgrade the obsolescence postprocessing logic (issue4354)...
r32009 searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
(run 'hg heads' to see heads)
$ hg push
Matt Harbison
tests: remove (glob) annotations that were only for '\' matches...
r35394 pushing to $TESTTMP/remote
Pierre-Yves David
checkheads: check successors for new heads in both missing and common...
r17548 searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
Yuya Nishihara
discovery: prevent crash caused by prune marker having no parent data...
r32096
Old head is pruned without parent data and new unrelated head added
===================================================================
setup
$ cd ..
$ rm -R remote local
$ cp -R backup1 remote
$ hg clone remote local -qr c70b08862e08
$ cd local
$ hg up -q '.^'
$ mkcommit new-unrelated
created new head
$ hg debugobsolete `getid old`
Boris Feld
debugobsolete: also report the number of obsoleted changesets...
r33542 obsoleted 1 changesets
Yuya Nishihara
discovery: prevent crash caused by prune marker having no parent data...
r32096 $ hg log -G --hidden
@ 350a93b716be (draft) add new-unrelated
|
| x c70b08862e08 (draft) add old
|/
o b4952fcf48cf (public) add base
$ hg push
Matt Harbison
tests: remove (glob) annotations that were only for '\' matches...
r35394 pushing to $TESTTMP/remote
Yuya Nishihara
discovery: prevent crash caused by prune marker having no parent data...
r32096 searching for changes
abort: push creates new remote head 350a93b716be!
(merge or see 'hg help push' for details about pushing new heads)
[255]