view tests/test-state-strip.t @ 99:67a3aa020d91

[states] fix strip but a case still does not work (see test test-state-strip.t)
author Alain Leufroy <alain.leufroy@logilab.fr>
date Tue, 27 Sep 2011 11:25:13 +0200
parents
children 7d0617e584ff
line wrap: on
line source



  $ cat >> $HGRCPATH <<EOF
  > [web]
  > push_ssl = false
  > allow_push = *
  > [extensions]
  > hgext.mq=
  > hgext.graphlog=
  > EOF
  $ echo "states=$(echo $(dirname $TESTDIR))/hgext/states.py" >> $HGRCPATH

  $ mkcommit() {
  >    echo "$1" > "$1"
  >    hg add "$1"
  >    hg ci -m "$1"
  > }
  $ alias hglog='hg glog --template "{rev} {state} {node}\n"'

  $ hg init alpha
  $ cd alpha
  $ hg states draft ready
  $ mkcommit 0
  $ mkcommit 1
  $ hg up 0
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ mkcommit 2
  created new head
  $ mkcommit 3
  $ mkcommit 4
  $ hg up 3
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ mkcommit 5
  created new head
  $ hg up 1
  1 files updated, 0 files merged, 3 files removed, 0 files unresolved
  $ mkcommit 6
  $ hg published 6
  $ hg ready 4
  $ hglog
  @  6 published 2a653cad66937648173a936140f09a0e780afd76
  |
  | o  5 draft ffe7eb8acef3efeceaa566b85a1ac419b0ecb856
  | |
  | | o  4 ready 138777f75ddeb6ee0b527cfdb0eebbd1e0037bf6
  | |/
  | o  3 ready 0915e256b0ca7f81dace67bc6fd512bfd1bcab85
  | |
  | o  2 ready a00ba83de58390cbbdae1fc580df0bb0db2e8e88
  | |
  o |  1 published e8342c9a2ed18fb27f9fdfc48a3105d164a06e77
  |/
  o  0 published 06254b90631198c9b9e426be9886af92fedc9a2d
  

We strip a published heads, so published heads 6 -> 1
  $ hg strip -n 6
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ hglog
  o  5 draft ffe7eb8acef3efeceaa566b85a1ac419b0ecb856
  |
  | o  4 ready 138777f75ddeb6ee0b527cfdb0eebbd1e0037bf6
  |/
  o  3 ready 0915e256b0ca7f81dace67bc6fd512bfd1bcab85
  |
  o  2 ready a00ba83de58390cbbdae1fc580df0bb0db2e8e88
  |
  | @  1 published e8342c9a2ed18fb27f9fdfc48a3105d164a06e77
  |/
  o  0 published 06254b90631198c9b9e426be9886af92fedc9a2d
  

Back to the previous configuration.
Then strip accros branches and remove draft changesets completly, and cut in
the middle of ready changesets
  $ hg up 1
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ mkcommit 6
  $ hg strip -n 3:6
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ hglog
  o  2 ready a00ba83de58390cbbdae1fc580df0bb0db2e8e88
  |
  | @  1 published e8342c9a2ed18fb27f9fdfc48a3105d164a06e77
  |/
  o  0 published 06254b90631198c9b9e426be9886af92fedc9a2d
  
Now merge 1 & 2 then strip merging changeset
  $ hg up 1
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg merge 2
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
  $ hg commit -m Merge
  $ hg strip -n 3
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ hglog
  o  2 ready a00ba83de58390cbbdae1fc580df0bb0db2e8e88
  |
  | @  1 published e8342c9a2ed18fb27f9fdfc48a3105d164a06e77
  |/
  o  0 published 06254b90631198c9b9e426be9886af92fedc9a2d
  
Do the same but with merge changeset as ready
  $ hg up 1
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg merge 2
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
  $ hg commit -m Merge
  $ hg ready 3
  $ hg strip -n 3
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ hglog
  o  2 ready a00ba83de58390cbbdae1fc580df0bb0db2e8e88
  |
  | @  1 published e8342c9a2ed18fb27f9fdfc48a3105d164a06e77
  |/
  o  0 published 06254b90631198c9b9e426be9886af92fedc9a2d
  
  $ hg log --template "{rev} {node}\n" -r 'readyheads()'
  2 a00ba83de58390cbbdae1fc580df0bb0db2e8e88

pathologic case
  $ hg up 1
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ mkcommit 3
  $ hg up 2
  1 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ hg merge 3
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
  $ hg ci -m '4'
  $ mkcommit 5
  $ hg up 3
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ mkcommit 6
  created new head
  $ hg published 3
  $ hg ready 4
  $ hglog
  @  6 draft aeb74c71311d9305498bbf371746d095b80ff51f
  |
  | o  5 draft 0777a3135ec5396c57db4402c71ab8cba2a0ef7e
  | |
  | o  4 ready 667667458ecc8cf7763dee1ae172a5a9ebf115f3
  |/|
  o |  3 published 03fc50a1c0074093104ff6c5357c486781742b64
  | |
  | o  2 ready a00ba83de58390cbbdae1fc580df0bb0db2e8e88
  | |
  o |  1 published e8342c9a2ed18fb27f9fdfc48a3105d164a06e77
  |/
  o  0 published 06254b90631198c9b9e426be9886af92fedc9a2d
  
  $ hg strip -n 3
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ hglog
  o  2 ready a00ba83de58390cbbdae1fc580df0bb0db2e8e88
  |
  | @  1 published e8342c9a2ed18fb27f9fdfc48a3105d164a06e77
  |/
  o  0 published 06254b90631198c9b9e426be9886af92fedc9a2d
  
#