changeset 5229:fa1324e58fcf stable

head-checking: also test single head enforcement with topic They are an important part of why we want this.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 12 Mar 2020 02:08:39 +0100
parents f560d23639e1
children 8431bb224862 1a81bbc94d45
files tests/test-single-head-obsolescence-topic-B1.t tests/test-single-head-obsolescence-topic-B2.t tests/test-single-head-obsolescence-topic-B3.t tests/test-single-head-obsolescence-topic-B4.t tests/test-single-head-obsolescence-topic-B5.t tests/testlib/push-checkheads-util.sh
diffstat 6 files changed, 576 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-single-head-obsolescence-topic-B1.t	Thu Mar 12 02:08:39 2020 +0100
@@ -0,0 +1,114 @@
+=========================================
+Testing single head enforcement: Case A-1
+=========================================
+
+A repository is set to only accept a single head per name (typically named
+branch). However, obsolete changesets can make this enforcement more
+complicated, because they can be kept visible by other changeset on other
+branch.
+
+This case is part of a series of tests checking this behavior.
+
+Category B: Involving obsolescence and topic
+TestCase 1: A fully obsolete topic kept visible by another one.
+
+.. old-state:
+..
+.. * 2 changeset changeset on topic X
+.. * 2 changeset changeset on topic Y on top of them.
+..
+.. new-state:
+..
+.. * 2 changeset changeset on topic Y at the same location
+.. * 2 changeset changeset on topic X superceeding the other ones
+..
+.. expected-result:
+..
+.. * only one head detected
+..
+.. graph-summary:
+..
+..   D ●      (topic-Y)
+..     |
+..   C ●      (topic-Y)
+..     |
+..   B ø⇠◔ B' (topic-X)
+..     | |
+..   A ø⇠◔ A' (topic-X)
+..     |/
+..     ●
+
+  $ . $TESTDIR/testlib/topic_setup.sh
+  $ . $TESTDIR/testlib/push-checkheads-util.sh
+
+Test setup
+----------
+
+  $ mkdir B1
+  $ cd B1
+  $ setuprepos single-head
+  creating basic server and client repo
+  updating to branch default
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd client
+  $ hg topic -r . topic-X
+  switching to topic topic-X
+  changed topic on 1 changesets to "topic-X"
+  $ hg strip --config extensions.strip= --hidden 'hidden()' --no-backup # clean old A0
+  $ mkcommit B0
+  $ hg topic topic-Y
+  $ mkcommit C0
+  active topic 'topic-Y' grew its first changeset
+  (see 'hg help topics' for more information)
+  $ mkcommit D0
+  $ hg push --new-branch
+  pushing to $TESTTMP/B1/server
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 4 changesets with 3 changes to 4 files (+1 heads)
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  $ hg up 0
+  0 files updated, 0 files merged, 4 files removed, 0 files unresolved
+  $ hg topic topic-X
+  marked working directory as topic: topic-X
+  $ mkcommit A1
+  $ mkcommit B1
+  $ hg debugobsolete `getid "desc(A0)" ` `getid "desc(A1)"`
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  3 new orphan changesets
+  $ hg debugobsolete `getid "desc(B0)" ` `getid "desc(B1)"`
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  $ hg log -G --hidden
+  @  f4ed6717fb66 [default:topic-X] (draft): B1
+  |
+  o  c1340bef453e [default:topic-X] (draft): A1
+  |
+  | *  618812b710f7 [default:topic-Y] (draft): D0
+  | |
+  | *  d1ad53773db2 [default:topic-Y] (draft): C0
+  | |
+  | x  1c1f62b56685 [default:topic-X] (draft): B0
+  | |
+  | x  5a47a98cd8e5 [default:topic-X] (draft): A0
+  |/
+  o  1e4be0697311 [default] (public): root
+  
+
+Actual testing
+--------------
+
+  $ hg push -r 'desc("B1")'
+  pushing to $TESTTMP/B1/server
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 2 files (+1 heads)
+  2 new obsolescence markers
+  obsoleted 2 changesets
+  2 new orphan changesets
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-single-head-obsolescence-topic-B2.t	Thu Mar 12 02:08:39 2020 +0100
@@ -0,0 +1,115 @@
+
+=========================================
+Testing single head enforcement: Case A-2
+=========================================
+
+A repository is set to only accept a single head per name (typically named
+branch). However, obsolete changesets can make this enforcement more
+complicated, because they can be kept visible by other changeset on other
+branch.
+
+This case is part of a series of tests checking this behavior.
+
+Category B: Involving obsolescence with topic
+TestCase 2: A branch is split in two, effectively creating two heads
+
+.. old-state:
+..
+.. * 2 changeset changeset on topic X
+.. * 2 changeset changeset on topic Y on top of them.
+..
+.. new-state:
+..
+.. * 2 changeset changeset on topic Y at the same location
+.. * 1 changeset changeset on topic X unchanged
+.. * 1 changeset changeset on topic X superceeding the other ones
+..
+.. expected-result:
+..
+.. * two heads detected
+..
+.. graph-summary:
+..
+..   D ●      (topic-Y)
+..     |
+..   C ●      (topic-Y)
+..     |
+..   B ø⇠◔ B' (topic-X)
+..     | |
+..   A ● |    (topic-X)
+..     |/
+..     ●
+
+  $ . $TESTDIR/testlib/topic_setup.sh
+  $ . $TESTDIR/testlib/push-checkheads-util.sh
+
+Test setup
+----------
+
+  $ mkdir B2
+  $ cd B2
+  $ setuprepos single-head
+  creating basic server and client repo
+  updating to branch default
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd client
+  $ hg topic -r . topic-X
+  switching to topic topic-X
+  changed topic on 1 changesets to "topic-X"
+  $ hg strip --config extensions.strip= --hidden 'hidden()' --no-backup # clean old A0
+  $ mkcommit B0
+  $ hg branch Z
+  marked working directory as branch Z
+  $ hg topic topic-Y
+  $ mkcommit C0
+  active topic 'topic-Y' grew its first changeset
+  (see 'hg help topics' for more information)
+  $ mkcommit D0
+  $ hg push --new-branch
+  pushing to $TESTTMP/B2/server
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 4 changesets with 3 changes to 4 files (+1 heads)
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  $ hg up 0
+  0 files updated, 0 files merged, 4 files removed, 0 files unresolved
+  $ hg topic topic-X
+  marked working directory as topic: topic-X
+  $ mkcommit B1
+  $ hg debugobsolete `getid "desc(B0)" ` `getid "desc(B1)"`
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  2 new orphan changesets
+  $ hg log -G --hidden
+  @  5a4735b75167 [default:topic-X] (draft): B1
+  |
+  | *  02490b2dd1c5 [Z:topic-Y] (draft): D0
+  | |
+  | *  447ad8382abc [Z:topic-Y] (draft): C0
+  | |
+  | x  1c1f62b56685 [default:topic-X] (draft): B0
+  | |
+  | o  5a47a98cd8e5 [default:topic-X] (draft): A0
+  |/
+  o  1e4be0697311 [default] (public): root
+  
+
+Actual testing
+--------------
+
+(force push to make sure we get the changeset on the remote)
+
+  $ hg push -r 'desc("B1")' --force
+  pushing to $TESTTMP/B2/server
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  transaction abort!
+  rollback completed
+  abort: rejecting multiple heads on branch "default:topic-X"
+  (2 heads: 5a47a98cd8e5 5a4735b75167)
+  [255]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-single-head-obsolescence-topic-B3.t	Thu Mar 12 02:08:39 2020 +0100
@@ -0,0 +1,116 @@
+=========================================
+Testing single head enforcement: Case A-3
+=========================================
+
+A repository is set to only accept a single head per name (typically named
+branch). However, obsolete changesets can make this enforcement more
+complicated, because they can be kept visible by other changeset on other
+branch.
+
+This case is part of a series of tests checking this behavior.
+
+Category B: Involving obsolescence with topic
+TestCase 3: Full superceedig of a branch interleaved with another
+
+.. old-state:
+..
+.. * 2 changeset changeset on topic Y
+.. * 2 changeset changeset on topic X interleaved with the other
+..
+.. new-state:
+..
+.. * 2 changeset changeset on topic X at the same location
+.. * 2 changeset changeset on topic Y superceeding the other ones
+..
+.. expected-result:
+..
+.. * only one head detected
+..
+.. graph-summary:
+..
+..   D ●      (topic-Y)
+..     |
+..   C ø⇠◔ C' (topix-X)
+..     | |
+..   B ● |    (topic-Y)
+..     | |
+..   A ø⇠◔ A' (topic-X)
+..     |/
+..     ●
+
+  $ . $TESTDIR/testlib/topic_setup.sh
+  $ . $TESTDIR/testlib/push-checkheads-util.sh
+
+Test setup
+----------
+
+  $ mkdir B3
+  $ cd B3
+  $ setuprepos single-head
+  creating basic server and client repo
+  updating to branch default
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd client
+  $ hg topic -r . topic-X
+  switching to topic topic-X
+  changed topic on 1 changesets to "topic-X"
+  $ hg strip --config extensions.strip= --hidden 'hidden()' --no-backup # clean old A0
+  $ hg topic topic-Y
+  $ mkcommit B0
+  active topic 'topic-Y' grew its first changeset
+  (see 'hg help topics' for more information)
+  $ hg topic topic-X
+  $ mkcommit C0
+  $ hg topic topic-Y
+  $ mkcommit D0
+  $ hg push --new-branch
+  pushing to $TESTTMP/B3/server
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 4 changesets with 3 changes to 4 files (+1 heads)
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  $ hg up 0
+  0 files updated, 0 files merged, 4 files removed, 0 files unresolved
+  $ hg topic topic-X
+  marked working directory as topic: topic-X
+  $ mkcommit A1
+  $ mkcommit C1
+  $ hg debugobsolete `getid "desc(A0)" ` `getid "desc(A1)"`
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  3 new orphan changesets
+  $ hg debugobsolete `getid "desc(C0)" ` `getid "desc(C1)"`
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  $ hg log -G --hidden
+  @  9f6e6381b9aa [default:topic-X] (draft): C1
+  |
+  o  c1340bef453e [default:topic-X] (draft): A1
+  |
+  | *  850d57e10bfe [default:topic-Y] (draft): D0
+  | |
+  | x  fcdd583577e8 [default:topic-X] (draft): C0
+  | |
+  | *  030eec7a0fe2 [default:topic-Y] (draft): B0
+  | |
+  | x  5a47a98cd8e5 [default:topic-X] (draft): A0
+  |/
+  o  1e4be0697311 [default] (public): root
+  
+
+Actual testing
+--------------
+
+  $ hg push -r 'desc("C1")'
+  pushing to $TESTTMP/B3/server
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 2 files (+1 heads)
+  2 new obsolescence markers
+  obsoleted 2 changesets
+  2 new orphan changesets
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-single-head-obsolescence-topic-B4.t	Thu Mar 12 02:08:39 2020 +0100
@@ -0,0 +1,113 @@
+=========================================
+Testing single head enforcement: Case A-4
+=========================================
+
+A repository is set to only accept a single head per name (typically named
+branch). However, obsolete changesets can make this enforcement more
+complicated, because they can be kept visible by other changeset on other
+branch.
+
+This case is part of a series of tests checking this behavior.
+
+Category A: Involving obsolescence
+TestCase 4: Partial rewrite of a branch to dis-interleave it
+
+.. old-state:
+..
+.. * 2 changeset changeset on topic X
+.. * 2 changeset changeset on topic Y interleaved with the other one
+..
+.. new-state:
+..
+.. * 2 changeset changeset on topic Y at the same location
+.. * 1 changeset on topic X untouched (the lower one)
+.. * 1 changeset on topic X moved on the other one
+..
+.. expected-result:
+..
+.. * only one head detected
+..
+.. graph-summary:
+..
+..   D ●      (topic-Y)
+..     |
+..   C ø⇠◔ C' (topic-X)
+..     | |
+..   B ● |    (topic-Y)
+..     |/
+..   A ●      (topic-X)
+..     |
+..     ●
+
+  $ . $TESTDIR/testlib/topic_setup.sh
+  $ . $TESTDIR/testlib/push-checkheads-util.sh
+
+Test setup
+----------
+
+  $ mkdir B4
+  $ cd B4
+  $ setuprepos single-head
+  creating basic server and client repo
+  updating to branch default
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd client
+  $ hg topic -r . topic-X
+  switching to topic topic-X
+  changed topic on 1 changesets to "topic-X"
+  $ hg strip --config extensions.strip= --hidden 'hidden()' --no-backup # clean old A0
+  $ hg topic topic-Y
+  $ mkcommit B0
+  active topic 'topic-Y' grew its first changeset
+  (see 'hg help topics' for more information)
+  $ hg topic topic-X
+  $ mkcommit C0
+  $ hg topic topic-Y
+  $ mkcommit D0
+  $ hg push --new-branch
+  pushing to $TESTTMP/B4/server
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 4 changesets with 3 changes to 4 files (+1 heads)
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  $ hg up 'desc("A0")'
+  switching to topic topic-X
+  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
+  $ hg topic topic-X
+  $ mkcommit C1
+  $ hg debugobsolete `getid "desc(C0)" ` `getid "desc(C1)"`
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  1 new orphan changesets
+  $ hg log -G --hidden
+  @  b98a8bd4ca39 [default:topic-X] (draft): C1
+  |
+  | *  850d57e10bfe [default:topic-Y] (draft): D0
+  | |
+  | x  fcdd583577e8 [default:topic-X] (draft): C0
+  | |
+  | o  030eec7a0fe2 [default:topic-Y] (draft): B0
+  |/
+  o  5a47a98cd8e5 [default:topic-X] (draft): A0
+  |
+  o  1e4be0697311 [default] (public): root
+  
+
+Actual testing
+--------------
+
+(force push to make sure we get the changeset on the remote)
+
+  $ hg push -r 'desc("C1")' --force
+  pushing to $TESTTMP/B4/server
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files (+1 heads)
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  1 new orphan changesets
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-single-head-obsolescence-topic-B5.t	Thu Mar 12 02:08:39 2020 +0100
@@ -0,0 +1,117 @@
+=========================================
+Testing single head enforcement: Case A-1
+=========================================
+
+A repository is set to only accept a single head per name (typically named
+branch). However, obsolete changesets can make this enforcement more
+complicated, because they can be kept visible by other changeset on other
+branch.
+
+This case is part of a series of tests checking this behavior.
+
+Category A: Involving obsolescence
+TestCase 1: obsoleting a merge reveal two heads
+
+.. old-state:
+..
+.. * 3 changeset changeset on topic X (2 on their own branch + 1 merge)
+.. * 1 changeset on topic Y (children of the merge)
+..
+.. new-state:
+..
+.. * 2 changeset changeset on topic X (merge is obsolete) each a head
+.. * 1 changeset on topic Y keeping the merge visible
+..
+.. expected-result:
+..
+.. * 2 heads detected (because we skip the merge).
+..
+.. graph-summary:
+..
+..   D ●      (topic-Y)
+..     |
+..   C ●      (topic-Y)
+..     |
+..   M ⊗      (topic-X)
+..     |\
+..   A ● ● B  (topic-X)
+..     |/
+..     ●
+
+  $ . $TESTDIR/testlib/topic_setup.sh
+  $ . $TESTDIR/testlib/push-checkheads-util.sh
+
+Test setup
+----------
+
+  $ mkdir B5
+  $ cd B5
+  $ setuprepos single-head
+  creating basic server and client repo
+  updating to branch default
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd client
+  $ hg topic -r . topic-X
+  switching to topic topic-X
+  changed topic on 1 changesets to "topic-X"
+  $ hg strip --config extensions.strip= --hidden 'hidden()' --no-backup # clean old A0
+  $ hg up 0
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg topic topic-X
+  marked working directory as topic: topic-X
+  $ mkcommit B0
+  $ hg merge
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg ci -m 'M0'
+  $ hg topic topic-Y
+  $ mkcommit C0
+  active topic 'topic-Y' grew its first changeset
+  (see 'hg help topics' for more information)
+  $ hg push --new-branch
+  pushing to $TESTTMP/B5/server
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 4 changesets with 2 changes to 3 files (+1 heads)
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  $ hg up 0
+  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
+  $ mkcommit A1
+  $ mkcommit B1
+  $ hg debugobsolete `getid "desc(M0)"` --record-parents
+  1 new obsolescence markers
+  obsoleted 1 changesets
+  1 new orphan changesets
+  $ hg log -G --hidden
+  @  262c8c798096 [default] (draft): B1
+  |
+  o  f6082bc4ffef [default] (draft): A1
+  |
+  | *  339fd31549ed [default:topic-Y] (draft): C0
+  | |
+  | x    33b3d4185449 [default:topic-X] (draft): M0
+  | |\
+  +---o  d3826ff42cf7 [default:topic-X] (draft): B0
+  | |
+  | o  5a47a98cd8e5 [default:topic-X] (draft): A0
+  |/
+  o  1e4be0697311 [default] (public): root
+  
+
+Actual testing
+--------------
+
+(force push to make sure we get the changeset on the remote)
+
+  $ hg push -r 'desc("C0")' --force
+  pushing to $TESTTMP/B5/server
+  searching for changes
+  no changes found
+  transaction abort!
+  rollback completed
+  abort: rejecting multiple heads on branch "default:topic-X"
+  (2 heads: 5a47a98cd8e5 d3826ff42cf7)
+  [255]
--- a/tests/testlib/push-checkheads-util.sh	Mon Apr 06 07:26:40 2020 +0200
+++ b/tests/testlib/push-checkheads-util.sh	Thu Mar 12 02:08:39 2020 +0100
@@ -34,6 +34,6 @@
 
         echo >> "client/.hg/hgrc" "[ui]"
         echo >> "client/.hg/hgrc" "# simpler log output"
-        echo >> "client/.hg/hgrc" 'logtemplate ="{node|short} [{branch}] ({phase}): {desc}\\n"'
+        echo >> "client/.hg/hgrc" 'logtemplate = "{node|short} [{branch}{if(topic, ":{topic}")}] ({phase}): {desc}\\n"'
     fi
 }