tests/test-obsolete-rebase.t
author Pierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 27 Nov 2012 14:27:50 +0100
branchstable
changeset 621 e50a5d9a6cbf
parent 572 dc107acd0bd2
permissions -rw-r--r--
merge with Denis improvement

  $ cat >> $HGRCPATH <<EOF
  > [defaults]
  > amend=-d "0 0"
  > [extensions]
  > hgext.rebase=
  > hgext.graphlog=
  > EOF
  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext/evolve.py" >> $HGRCPATH

  $ glog() {
  >   hg glog --template '{rev}:{node|short}@{branch}({phase}) {desc|firstline}\n'\
  >     "$@"
  > }

  $ hg init repo
  $ cd repo
  $ echo a > a
  $ hg ci -Am adda
  adding a
  $ echo a >> a
  $ hg ci -m changea

Test regular rebase

  $ hg up 0
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo b > b
  $ hg ci -Am addb
  adding b
  created new head
  $ echo e > e
  $ hg ci -Am adde e

(phase compliance)

  $ hg phase --public 3
  $ hg rebase -d 1 -r 3
  abort: can't rebase immutable changeset 98e4a024635e
  (see hg help phases for details)
  [255]
  $ hg phase --draft --force 0
  $ hg rebase -d 1 -r 3 --keep  
  $ glog
  @  4:9c5494949763@default(draft) adde
  |
  | o  3:98e4a024635e@default(draft) adde
  | |
  | o  2:102a90ea7b4a@default(draft) addb
  | |
  o |  1:540395c44225@default(draft) changea
  |/
  o  0:07f494440405@default(draft) adda
  
  $ glog --hidden
  @  4:9c5494949763@default(draft) adde
  |
  | o  3:98e4a024635e@default(draft) adde
  | |
  | o  2:102a90ea7b4a@default(draft) addb
  | |
  o |  1:540395c44225@default(draft) changea
  |/
  o  0:07f494440405@default(draft) adda
  
  $ hg debugobsolete
  $ hg --config extensions.hgext.mq= strip tip
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/9c5494949763-backup.hg
  $ hg rebase -d 1 -r 3
  $ glog
  @  4:9c5494949763@default(draft) adde
  |
  | o  2:102a90ea7b4a@default(draft) addb
  | |
  o |  1:540395c44225@default(draft) changea
  |/
  o  0:07f494440405@default(draft) adda
  
  $ glog --hidden
  @  4:9c5494949763@default(draft) adde
  |
  | x  3:98e4a024635e@default(draft) adde
  | |
  | o  2:102a90ea7b4a@default(draft) addb
  | |
  o |  1:540395c44225@default(draft) changea
  |/
  o  0:07f494440405@default(draft) adda
  
  $ hg debugobsolete
  98e4a024635e8c50928144c9277a4388d26bd786 9c54949497631abfb5a255d96746bbd3a42ed2ba 0 {'date': '* *', 'user': 'test'} (glob)

Test rebase with deleted empty revision

  $ hg up 0
  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ hg branch foo
  marked working directory as branch foo
  (branches are permanent and global, did you want a bookmark?)
  $ echo a >> a
  $ hg ci -m changea
  $ hg rebase -d 1
  $ glog --hidden
  x  5:4e322f7ce8e3@foo(draft) changea
  |
  | o  4:9c5494949763@default(draft) adde
  | |
  | | x  3:98e4a024635e@default(draft) adde
  | | |
  +---o  2:102a90ea7b4a@default(draft) addb
  | |
  | @  1:540395c44225@default(draft) changea
  |/
  o  0:07f494440405@default(draft) adda
  
  $ hg debugobsolete
  98e4a024635e8c50928144c9277a4388d26bd786 9c54949497631abfb5a255d96746bbd3a42ed2ba 0 {'date': '* *', 'user': 'test'} (glob)
  4e322f7ce8e3e4203950eac9ece27bf7e45ffa6c 540395c442253af3b991be882b539e7e198b5808 0 {'date': '* *', 'user': 'test'} (glob)

Test rebase --collapse

  $ hg up 0
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo c > c
  $ hg ci -Am addc
  adding c
  created new head
  $ echo c >> c
  $ hg ci -m changec
  $ hg rebase --collapse -d 1
  merging c
  $ glog --hidden
  @  8:a7773ffa7edc@default(draft) Collapsed revision
  |
  | x  7:03f31481307a@default(draft) changec
  | |
  | x  6:076e9b2ffbe1@default(draft) addc
  | |
  | | x  5:4e322f7ce8e3@foo(draft) changea
  | |/
  +---o  4:9c5494949763@default(draft) adde
  | |
  | | x  3:98e4a024635e@default(draft) adde
  | | |
  | | o  2:102a90ea7b4a@default(draft) addb
  | |/
  o |  1:540395c44225@default(draft) changea
  |/
  o  0:07f494440405@default(draft) adda
  
  $ hg debugobsolete
  98e4a024635e8c50928144c9277a4388d26bd786 9c54949497631abfb5a255d96746bbd3a42ed2ba 0 {'date': '* *', 'user': 'test'} (glob)
  4e322f7ce8e3e4203950eac9ece27bf7e45ffa6c 540395c442253af3b991be882b539e7e198b5808 0 {'date': '* *', 'user': 'test'} (glob)
  076e9b2ffbe11c7bcb9ee97f5c0c8b88a1a10b93 a7773ffa7edcfac27b5dcdb2d5c1036e15a49861 0 {'date': '* *', 'user': 'test'} (glob)
  03f31481307aaf5275d07ec28c1c59931759ccd2 a7773ffa7edcfac27b5dcdb2d5c1036e15a49861 0 {'date': '* *', 'user': 'test'} (glob)

Test rebase --abort

  $ hg debugobsolete > ../successors.old
  $ hg up 0
  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ echo d > d
  $ hg ci -Am addd d
  created new head
  $ echo b >> a
  $ hg ci -m appendab
  $ hg rebase -d 1
  merging a
  warning: conflicts during merge.
  merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
  abort: unresolved conflicts (see hg resolve, then hg rebase --continue)
  [255]
  $ hg rebase --abort
  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/03f165c84ea8-backup.hg
  rebase aborted
  $ hg debugobsolete > ../successors.new
  $ diff -u ../successors.old ../successors.new

Test rebase --continue

  $ hg rebase -d 1
  merging a
  warning: conflicts during merge.
  merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
  abort: unresolved conflicts (see hg resolve, then hg rebase --continue)
  [255]
  $ hg resolve --tool internal:other a
  $ hg rebase --continue
  $ glog --hidden
  @  12:1951ead97108@default(draft) appendab
  |
  o  11:03f165c84ea8@default(draft) addd
  |
  | x  10:4b9d80f48523@default(draft) appendab
  | |
  | x  9:a31943eabc43@default(draft) addd
  | |
  +---o  8:a7773ffa7edc@default(draft) Collapsed revision
  | |
  | | x  7:03f31481307a@default(draft) changec
  | | |
  | | x  6:076e9b2ffbe1@default(draft) addc
  | |/
  | | x  5:4e322f7ce8e3@foo(draft) changea
  | |/
  +---o  4:9c5494949763@default(draft) adde
  | |
  | | x  3:98e4a024635e@default(draft) adde
  | | |
  | | o  2:102a90ea7b4a@default(draft) addb
  | |/
  o |  1:540395c44225@default(draft) changea
  |/
  o  0:07f494440405@default(draft) adda
  
  $ hg debugobsolete > ../successors.new
  $ diff -u ../successors.old ../successors.new
  --- ../successors.old* (glob)
  +++ ../successors.new* (glob)
  @@ -2,3 +2,5 @@
   4e322f7ce8e3e4203950eac9ece27bf7e45ffa6c 540395c442253af3b991be882b539e7e198b5808 0 {'date': '* *', 'user': 'test'} (glob)
   076e9b2ffbe11c7bcb9ee97f5c0c8b88a1a10b93 a7773ffa7edcfac27b5dcdb2d5c1036e15a49861 0 {'date': '* *', 'user': 'test'} (glob)
   03f31481307aaf5275d07ec28c1c59931759ccd2 a7773ffa7edcfac27b5dcdb2d5c1036e15a49861 0 {'date': '* *', 'user': 'test'} (glob)
  +a31943eabc4327df16f9eca71bf7779c32f815f7 03f165c84ea8889fc35a64a392caa7a0084dd212 0 {'date': '* *', 'user': 'test'} (glob)
  +4b9d80f48523e296f4402cc8e37236b768dfb981 1951ead9710803dbf117e95901954d5ed717f80b 0 {'date': '* *', 'user': 'test'} (glob)
  [1]

Test hg pull --rebase

  $ hg glog
  @  changeset:   12:1951ead97108
  |  tag:         tip
  |  user:        test
  |  date:        Thu Jan 01 00:00:00 1970 +0000
  |  summary:     appendab
  |
  o  changeset:   11:03f165c84ea8
  |  parent:      1:540395c44225
  |  user:        test
  |  date:        Thu Jan 01 00:00:00 1970 +0000
  |  summary:     addd
  |
  | o  changeset:   8:a7773ffa7edc
  |/   parent:      1:540395c44225
  |    user:        test
  |    date:        Thu Jan 01 00:00:00 1970 +0000
  |    summary:     Collapsed revision
  |
  | o  changeset:   4:9c5494949763
  |/   parent:      1:540395c44225
  |    user:        test
  |    date:        Thu Jan 01 00:00:00 1970 +0000
  |    summary:     adde
  |
  | o  changeset:   2:102a90ea7b4a
  | |  parent:      0:07f494440405
  | |  user:        test
  | |  date:        Thu Jan 01 00:00:00 1970 +0000
  | |  summary:     addb
  | |
  o |  changeset:   1:540395c44225
  |/   user:        test
  |    date:        Thu Jan 01 00:00:00 1970 +0000
  |    summary:     changea
  |
  o  changeset:   0:07f494440405
     user:        test
     date:        Thu Jan 01 00:00:00 1970 +0000
     summary:     adda
  
  $ echo '[phases]' >> .hg/hgrc
  $ echo 'publish=False' >> .hg/hgrc
  $ hg clone . -r 540395c44225 ../other
  adding changesets
  adding manifests
  adding file changes
  added 2 changesets with 2 changes to 1 files
  updating to branch default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg ph -vfd 'all()'
  no phases changed
  [1]
  $ cd ../other
  $ echo 'babar' > toto
  $ hg add toto
  $ hg ci -m 'babar is not dead'
  $ echo '[ui]' >> .hg/hgrc
  $ echo 'logtemplate={rev} {node|short} {desc|firstline}\n' >> .hg/hgrc
  $ hg pull --rebase --traceback | grep -v 'saved'
  pulling from $TESTTMP/repo
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 5 changesets with 5 changes to 5 files (+4 heads)
  $ hg glog
  @  [78] d5567dbec794 babar is not dead (re)
  |
  o  [67] 1951ead97108 appendab (re)
  |
  o  [56] 03f165c84ea8 addd (re)
  |
  | o  [45] a7773ffa7edc Collapsed revision (re)
  |/
  | o  [34] 9c5494949763 adde (re)
  |/
  | o  [23] 102a90ea7b4a addb (re)
  | |
  o |  1 540395c44225 changea
  |/
  o  0 07f494440405 adda