test: add testing of checkheads behavior with obsolete
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Wed, 01 Aug 2012 19:35:05 +0200
changeset 17546 488e470634d8
parent 17540 f2bcc5975f10
child 17547 e6de4761d26f
test: add testing of checkheads behavior with obsolete Expected behavior is quite complex. Explicit testing with clear scenarios is welcome.
tests/test-obsolete-checkheads.t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-obsolete-checkheads.t	Wed Aug 01 19:35:05 2012 +0200
@@ -0,0 +1,102 @@
+Check that obsolete properly strip heads
+  $ cat > obs.py << EOF
+  > import mercurial.obsolete
+  > mercurial.obsolete._enabled = True
+  > EOF
+  $ cat >> $HGRCPATH << EOF
+  > [phases]
+  > # public changeset are not obsolete
+  > publish=false
+  > [ui]
+  > logtemplate='{node|short} ({phase}) {desc|firstline}\n'
+  > [extensions]
+  > graphlog=
+  > EOF
+  $ echo "obs=${TESTTMP}/obs.py" >> $HGRCPATH
+  $ 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 ..
+  $ cp -r remote base
+  $ 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
+
+  $ mkcommit old
+  $ hg push
+  pushing to $TESTTMP/remote
+  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
+  $ hg debugobsolete `getid old` `getid new`
+  $ hg glog --hidden
+  @  71e3228bffe1 (draft) add new
+  |
+  | x  c70b08862e08 (draft) add old
+  |/
+  o  b4952fcf48cf (public) add base
+  
+  $ cp -r ../remote ../backup1
+
+old exists remotely as draft. It is obsoleted by new that we now push.
+Push should not warn about creating new head
+
+  $ hg push
+  pushing to $TESTTMP/remote
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files (+1 heads)
+
+old head is obsolete but replacement in not pushed
+==================================================
+
+setup
+
+  $ rm -fr ../remote
+  $ cp -r ../backup1 ../remote
+  $ hg up -q '.^'
+  $ mkcommit other
+  created new head
+  $ hg glog --hidden
+  @  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")'
+  pushing to $TESTTMP/remote
+  searching for changes
+  abort: push creates new remote head d7d41ccbd4de!
+  (did you forget to merge? use push -f to force)
+  [255]