view tests/test-obsolete.t @ 350:b836862d48b4 stable

[convert] properly exclude null successors from convertion Old remain of the old way to kill changeset.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 10 Jul 2012 16:03:29 +0200
parents 63f267bd2176
children 6b92f8d5ae58 bd26eb9714fb
line wrap: on
line source

  $ cat >> $HGRCPATH <<EOF
  > [web]
  > push_ssl = false
  > allow_push = *
  > [phases]
  > publish=False
  > [alias]
  > odiff=diff --rev 'limit(precursors(.),1)' --rev .
  > [extensions]
  > hgext.graphlog=
  > EOF
  $ echo "obsolete=$(echo $(dirname $TESTDIR))/hgext/obsolete.py" >> $HGRCPATH
  $ mkcommit() {
  >    echo "$1" > "$1"
  >    hg add "$1"
  >    hg ci -m "add $1"
  > }

  $ alias qlog="hg log --template='{rev}\n- {node|short}\n'"
  $ hg init local
  $ cd local
  $ mkcommit a # 0
  $ hg phase -p .
  $ mkcommit b # 1
  $ mkcommit c # 2
  $ hg up 1
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ mkcommit obsol_c # 3
  created new head
  $ hg debugobsolete 3 2


Test that obsolete changeset are hidden

  $ qlog
  3
  - 0d3f46688ccc
  1
  - 7c3bad9141dc
  0
  - 1f0dee641bb7
  $ qlog --hidden
  3
  - 0d3f46688ccc
  2
  - 4538525df7e2
  1
  - 7c3bad9141dc
  0
  - 1f0dee641bb7
  $ qlog -r 'obsolete()' --hidden
  2
  - 4538525df7e2

Test that obsolete parent a properly computed

  $ qlog -r 'precursors(.)' --hidden
  2
  - 4538525df7e2
  $ qlog -r .
  3
  - 0d3f46688ccc
  $ hg odiff
  diff -r 4538525df7e2 -r 0d3f46688ccc c
  --- a/c	Thu Jan 01 00:00:00 1970 +0000
  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
  @@ -1,1 +0,0 @@
  -c
  diff -r 4538525df7e2 -r 0d3f46688ccc obsol_c
  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
  +++ b/obsol_c	Thu Jan 01 00:00:00 1970 +0000
  @@ -0,0 +1,1 @@
  +obsol_c

Test that obsolete successors a properly computed

  $ qlog -r 'successors(2)' --hidden
  3
  - 0d3f46688ccc

test obsolete changeset with no-obsolete descendant
  $ hg up 1 -q
  $ mkcommit "obsol_c'" # 4 (on 1)
  created new head
  $ hg debugobsolete 4 3
  $ qlog
  4
  - 725c380fe99b
  1
  - 7c3bad9141dc
  0
  - 1f0dee641bb7
  $ qlog -r 'obsolete()' --hidden
  2
  - 4538525df7e2
  3
  - 0d3f46688ccc
  $ qlog -r 'allprecursors(4)' --hidden
  2
  - 4538525df7e2
  3
  - 0d3f46688ccc
  $ qlog -r 'allsuccessors(2)' --hidden
  3
  - 0d3f46688ccc
  4
  - 725c380fe99b
  $ hg up 3 -q
  Working directory parent is obsolete
  $ mkcommit d # 5 (on 3)
  $ qlog -r 'obsolete()'
  3
  - 0d3f46688ccc

  $ qlog -r 'extinct()' --hidden
  2
  - 4538525df7e2
  $ qlog -r 'suspended()'
  3
  - 0d3f46688ccc
  $ qlog -r 'unstable()'
  5
  - a7a6f2b5d8a5

Test obsolete keyword

  $ hg glog --template '{rev}:{node|short}@{branch}({obsolete}/{phase}) {desc|firstline}\n' \
  >   --hidden
  @  5:a7a6f2b5d8a5@default(unstable/secret) add d
  |
  | o  4:725c380fe99b@default(stable/draft) add obsol_c'
  | |
  o |  3:0d3f46688ccc@default(suspended/secret) add obsol_c
  |/
  | o  2:4538525df7e2@default(extinct/secret) add c
  |/
  o  1:7c3bad9141dc@default(stable/draft) add b
  |
  o  0:1f0dee641bb7@default(stable/public) add a
  

Test communication of obsolete relation with a compatible client

  $ hg init ../other-new
  $ hg phase --draft 'secret() - extinct()' # until we fix exclusion
  $ hg push ../other-new
  pushing to ../other-new
  searching for changes
  abort: Trying to push unstable changeset: a7a6f2b5d8a5!
  (use 'hg stabilize' to get a stable history (or --force to proceed))
  [255]
  $ hg push -f ../other-new
  pushing to ../other-new
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 5 changesets with 5 changes to 5 files (+1 heads)
  $ hg -R ../other-new verify
  checking changesets
  checking manifests
  crosschecking files in changesets and manifests
  checking files
  5 files, 5 changesets, 5 total revisions
  $ qlog -R ../other-new -r 'obsolete()'
  2
  - 0d3f46688ccc
  $ qlog -R ../other-new
  4
  - a7a6f2b5d8a5
  3
  - 725c380fe99b
  2
  - 0d3f46688ccc
  1
  - 7c3bad9141dc
  0
  - 1f0dee641bb7
  $ hg up 3 -q
  Working directory parent is obsolete
  $ mkcommit obsol_d # 6
  created new head
  $ hg debugobsolete 6 5
  $ qlog
  6
  - 95de7fc6918d
  4
  - 725c380fe99b
  3
  - 0d3f46688ccc
  1
  - 7c3bad9141dc
  0
  - 1f0dee641bb7
  $ qlog -r 'obsolete()'
  3
  - 0d3f46688ccc
  $ hg push ../other-new
  pushing to ../other-new
  searching for changes
  abort: Trying to push unstable changeset: 95de7fc6918d!
  (use 'hg stabilize' to get a stable history (or --force to proceed))
  [255]
  $ hg push ../other-new -f # use f because there is unstability
  pushing to ../other-new
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files (+1 heads)
  $ qlog -R ../other-new
  5
  - 95de7fc6918d
  3
  - 725c380fe99b
  2
  - 0d3f46688ccc
  1
  - 7c3bad9141dc
  0
  - 1f0dee641bb7
  $ qlog -R ../other-new -r 'obsolete()'
  2
  - 0d3f46688ccc

Pushing again does not advertise extinct changeset

  $ hg push ../other-new
  pushing to ../other-new
  searching for changes
  no changes found (ignored 0 secret changesets)
  [1]

  $ hg up -q .^ # 3
  Working directory parent is obsolete
  $ mkcommit "obsol_d'" # 7
  created new head
  $ hg debugobsolete 7 6
  $ hg pull -R ../other-new .
  pulling from .
  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 merge' to merge)
  $ qlog -R ../other-new
  6
  - 909a0fb57e5d
  3
  - 725c380fe99b
  2
  - 0d3f46688ccc
  1
  - 7c3bad9141dc
  0
  - 1f0dee641bb7

pushing to stuff that doesn't support obsolete

  $ hg init ../other-old
  > # XXX I don't like this but changeset get published otherwise
  > # remove it when we will get a --keep-state flag for push
  $ echo '[extensions]'  > ../other-old/.hg/hgrc
  $ echo "obsolete=!$(echo $(dirname $TESTDIR))/obsolete.py" >> ../other-old/.hg/hgrc
  $ hg push ../other-old
  pushing to ../other-old
  searching for changes
  abort: Trying to push unstable changeset: 909a0fb57e5d!
  (use 'hg stabilize' to get a stable history (or --force to proceed))
  [255]
  $ hg push -f ../other-old
  pushing to ../other-old
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 5 changesets with 5 changes to 5 files (+1 heads)
  $ qlog -R ../other-old
  4
  - 909a0fb57e5d
  3
  - 725c380fe99b
  2
  - 0d3f46688ccc
  1
  - 7c3bad9141dc
  0
  - 1f0dee641bb7

clone support

  $ hg clone . ../cloned
  > # The warning should go away once we have default value to set ready before we pull
  requesting all changes
  adding changesets
  adding manifests
  adding file changes
  added 5 changesets with 5 changes to 5 files (+1 heads)
  updating to branch default
  4 files updated, 0 files merged, 0 files removed, 0 files unresolved

  $ qlog -R ../cloned
  4
  - 909a0fb57e5d
  3
  - 725c380fe99b
  2
  - 0d3f46688ccc
  1
  - 7c3bad9141dc
  0
  - 1f0dee641bb7

Test rollback support

  $ hg up .^ -q # 3
  Working directory parent is obsolete
  $ mkcommit "obsol_d''"
  created new head
  $ hg debugobsolete 8 7
  $ cd ../other-new
  $ hg up -q 3
  $ hg pull ../local/
  pulling from ../local/
  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 merge' to merge)

  $ hg up -q 7 # to check rollback update behavior
  $ qlog
  7
  - 159dfc9fa5d3
  3
  - 725c380fe99b
  2
  - 0d3f46688ccc
  1
  - 7c3bad9141dc
  0
  - 1f0dee641bb7
  $ hg rollback
  repository tip rolled back to revision 6 (undo pull)
  working directory now based on revision 3
  $ hg summary
  parent: 3:725c380fe99b 
   add obsol_c'
  branch: default
  commit: 1 deleted, 2 unknown (clean)
  update: 4 new changesets, 4 branch heads (merge)
  $ qlog
  6
  - 909a0fb57e5d
  3
  - 725c380fe99b
  2
  - 0d3f46688ccc
  1
  - 7c3bad9141dc
  0
  - 1f0dee641bb7
  $ cd ../local

obsolete public changeset

# move draft boundary from 0 to 1
  $ sed -e 's/1f0dee641bb7258c56bd60e93edfa2405381c41e/7c3bad9141dcb46ff89abf5f61856facd56e476c/' -i'.back' .hg/store/phaseroots

  $ hg up null
  0 files updated, 0 files merged, 4 files removed, 0 files unresolved
  $ mkcommit toto # 9
  created new head
  $ hg id -n
  9
  $ hg debugobsolete 9 0
  83b5778897ad try to obsolete immutable changeset 1f0dee641bb7
  $ qlog -r 'obsolete()'
  3
  - 0d3f46688ccc
allow to just kill changeset

  $ qlog
  9
  - 83b5778897ad
  8
  - 159dfc9fa5d3
  4
  - 725c380fe99b
  3
  - 0d3f46688ccc
  1
  - 7c3bad9141dc
  0
  - 1f0dee641bb7

  $ hg debugobsolete null 9 #kill
  $ hg up null -q # to be not based on 9 anymore
  $ qlog
  8
  - 159dfc9fa5d3
  4
  - 725c380fe99b
  3
  - 0d3f46688ccc
  1
  - 7c3bad9141dc
  0
  - 1f0dee641bb7

check rebase compat

  $ hg glog -r 'not extinct()'  --template='{rev} - {node|short}\n'
  o  8 - 159dfc9fa5d3
  |
  | o  4 - 725c380fe99b
  | |
  o |  3 - 0d3f46688ccc
  |/
  o  1 - 7c3bad9141dc
  |
  o  0 - 1f0dee641bb7
  

  $ hg glog  --template='{rev} - {node|short}\n' `(hg --version | grep -q 'version 2.1') ||  echo '--hidden'`
  o  9 - 83b5778897ad
  
  o  8 - 159dfc9fa5d3
  |
  | o  7 - 909a0fb57e5d
  |/
  | o  6 - 95de7fc6918d
  |/
  | o  5 - a7a6f2b5d8a5
  |/
  | o  4 - 725c380fe99b
  | |
  o |  3 - 0d3f46688ccc
  |/
  | o  2 - 4538525df7e2
  |/
  o  1 - 7c3bad9141dc
  |
  o  0 - 1f0dee641bb7
  

should not rebase extinct changeset

  $ hg --config extensions.hgext.rebase= rebase -b 3 -d 4 --traceback
  $ hg --config extensions.graphlog= glog -r 'not extinct()'  --template='{rev} - {node|short}\n'
  @  11 - 9468a5f5d8b2
  |
  o  10 - 2033b4e49474
  |
  o  4 - 725c380fe99b
  |
  o  1 - 7c3bad9141dc
  |
  o  0 - 1f0dee641bb7
  

Does not complain about new head if you obsolete the old one

  $ hg push ../other-new --traceback
  pushing to ../other-new
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 2 changesets with 1 changes to 1 files
  $ hg up -q 10
  $ mkcommit "obsol_d'''"
  created new head
  $ hg debugobsolete 12 11
  $ hg push ../other-new --traceback
  pushing to ../other-new
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files (+1 heads)
  $ cd ..

check latecomer detection
(make an obsolete changeset public)

  $ cd local
  $ hg phase --public 11
  $ hg --config extensions.graphlog=glog glog --template='{rev} - ({phase}) {node|short} {desc}\n'
  @  12 - (draft) 6db5e282cb91 add obsol_d'''
  |
  | o  11 - (public) 9468a5f5d8b2 add obsol_d''
  |/
  o  10 - (public) 2033b4e49474 add obsol_c
  |
  o  4 - (public) 725c380fe99b add obsol_c'
  |
  o  1 - (public) 7c3bad9141dc add b
  |
  o  0 - (public) 1f0dee641bb7 add a
  
  $ hg log -r 'latecomer()'
  changeset:   12:6db5e282cb91
  tag:         tip
  parent:      10:2033b4e49474
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  summary:     add obsol_d'''
  
  $ hg push ../other-new/
  pushing to ../other-new/
  searching for changes
  abort: Trying to push latecomer changeset: 6db5e282cb91!
  (use 'hg stabilize' to get a stable history (or --force to proceed))
  [255]

Check hg commit --amend compat

  $ hg up 'desc(obsol_c)'
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ mkcommit f
  created new head
  $ echo 42 >> f
  $ hg commit --amend --traceback
  saved backup bundle to $TESTTMP/local/.hg/strip-backup/0b1b6dd009c0-amend-backup.hg
  $ hg glog
  @  changeset:   13:3734a65252e6
  |  tag:         tip
  |  parent:      10:2033b4e49474
  |  user:        test
  |  date:        Thu Jan 01 00:00:00 1970 +0000
  |  summary:     add f
  |
  | o  changeset:   12:6db5e282cb91
  |/   parent:      10:2033b4e49474
  |    user:        test
  |    date:        Thu Jan 01 00:00:00 1970 +0000
  |    summary:     add obsol_d'''
  |
  | o  changeset:   11:9468a5f5d8b2
  |/   user:        test
  |    date:        Thu Jan 01 00:00:00 1970 +0000
  |    summary:     add obsol_d''
  |
  o  changeset:   10:2033b4e49474
  |  parent:      4:725c380fe99b
  |  user:        test
  |  date:        Thu Jan 01 00:00:00 1970 +0000
  |  summary:     add obsol_c
  |
  o  changeset:   4:725c380fe99b
  |  parent:      1:7c3bad9141dc
  |  user:        test
  |  date:        Thu Jan 01 00:00:00 1970 +0000
  |  summary:     add obsol_c'
  |
  o  changeset:   1:7c3bad9141dc
  |  user:        test
  |  date:        Thu Jan 01 00:00:00 1970 +0000
  |  summary:     add b
  |
  o  changeset:   0:1f0dee641bb7
     user:        test
     date:        Thu Jan 01 00:00:00 1970 +0000
     summary:     add a
  
  $ hg debugsuccessors
  0b1b6dd009c0 3734a65252e6
  0d3f46688ccc 2033b4e49474
  0d3f46688ccc 725c380fe99b
  159dfc9fa5d3 9468a5f5d8b2
  1f0dee641bb7 83b5778897ad
  4538525df7e2 0d3f46688ccc
  83b5778897ad 000000000000
  909a0fb57e5d 159dfc9fa5d3
  9468a5f5d8b2 6db5e282cb91
  95de7fc6918d 909a0fb57e5d
  a7a6f2b5d8a5 95de7fc6918d