tests/test-topic-stack.t
author Pierre-Yves David <pierre-yves.david@fb.com>
Fri, 01 Apr 2016 16:40:19 -0700
changeset 1954 61f36480740f
parent 1953 bdc5bb223b50
child 1956 d8f1e432b16a
permissions -rw-r--r--
stack: start indexing at 't1' instead of 't0' I think 't0' could have special meaning (eg: before 't1', but still with topic activated) so let's keep room for that. Indexing from 1 is not crazy anyway.

  $ . "$TESTDIR/testlib"

Initial setup


  $ cat << EOF >> $HGRCPATH
  > [ui]
  > logtemplate = {rev} {branch} \{{get(namespaces, "topics")}} {phase} {desc|firstline}\n
  > [experimental]
  > evolution=createmarkers,exchange,allowunstable
  > EOF

(new head warning seems buggy)
  $ hg init main
  $ cd main
  $ echo aaa > aaa
  $ hg add aaa
  $ hg commit -m c_a
  $ echo aaa > bbb
  $ hg add bbb
  $ hg commit -m c_b
  $ hg topic foo
  $ echo aaa > ccc
  $ hg add ccc
  $ hg commit -m c_c
  $ echo aaa > ddd
  $ hg add ddd
  $ hg commit -m c_d
  $ echo aaa > eee
  $ hg add eee
  $ hg commit -m c_e
  $ echo aaa > fff
  $ hg add fff
  $ hg commit -m c_f
  $ hg log -G
  @  5 default {foo} draft c_f
  |
  o  4 default {foo} draft c_e
  |
  o  3 default {foo} draft c_d
  |
  o  2 default {foo} draft c_c
  |
  o  1 default {} draft c_b
  |
  o  0 default {} draft c_a
  

Simple test
-----------

hg topic -l list all changeset in the topic

  $ hg topic
   * foo
  $ hg topic --list
    _ c_b
  t1: c_c
  t2: c_d
  t3: c_e
  t4@ c_f (current)

error case, nothing to list

  $ hg topic --clear
  $ hg topic --list
  abort: no active topic to list
  [255]

Test "t#" reference
-------------------


  $ hg up t1
  abort: cannot resolve "t1": no active topic
  [255]
  $ hg topic foo
  $ hg up t42
  abort: cannot resolve "t42": topic "foo" has only 4 changesets
  [255]
  $ hg up t1
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved

Case with some of the topic unstable
------------------------------------

  $ echo bbb > ddd
  $ hg commit --amend
  $ hg log -G
  @  7 default {foo} draft c_d
  |
  | o  5 default {foo} draft c_f
  | |
  | o  4 default {foo} draft c_e
  | |
  | x  3 default {foo} draft c_d
  |/
  o  2 default {foo} draft c_c
  |
  o  1 default {} draft c_b
  |
  o  0 default {} draft c_a
  
  $ hg topic --list
    _ c_b
  t1: c_c
  t2@ c_d (current)
  t3$ c_e (unstable)
  t4$ c_f (unstable)

Also test the revset:

  $ hg log -r 'stack()'
  2 default {foo} draft c_c
  7 default {foo} draft c_d
  4 default {foo} draft c_e
  5 default {foo} draft c_f

Case with multiple heads on the topic
-------------------------------------

Make things linear again

  $ hg rebase -s 'desc(c_e)' -d 'desc(c_d) - obsolete()'
  rebasing 4:91fa8808d101 "c_e"
  rebasing 5:4ec5094907b7 "c_f"
  $ hg log -G
  o  9 default {foo} draft c_f
  |
  o  8 default {foo} draft c_e
  |
  @  7 default {foo} draft c_d
  |
  o  2 default {foo} draft c_c
  |
  o  1 default {} draft c_b
  |
  o  0 default {} draft c_a
  


Create the second branch

  $ hg up 'desc(c_d)'
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo aaa > ggg
  $ hg add ggg
  $ hg commit -m c_g
  $ echo aaa > hhh
  $ hg add hhh
  $ hg commit -m c_h
  $ hg log -G
  @  11 default {foo} draft c_h
  |
  o  10 default {foo} draft c_g
  |
  | o  9 default {foo} draft c_f
  | |
  | o  8 default {foo} draft c_e
  |/
  o  7 default {foo} draft c_d
  |
  o  2 default {foo} draft c_c
  |
  o  1 default {} draft c_b
  |
  o  0 default {} draft c_a
  

Test output

  $ hg top -l
    _ c_b
  t1: c_c
  t2: c_d
  t3: c_g
  t4@ c_h (current)
    _ c_d
  t5: c_e
  t6: c_f

Case with multiple heads on the topic with unstability involved
---------------------------------------------------------------

We amend the message to make sure the display base pick the right changeset

  $ hg up 'desc(c_d)'
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ echo ccc > ddd
  $ hg commit --amend -m 'c_D' 
  $ hg rebase -d . -s 'desc(c_g)'
  rebasing 10:11286b4fcb3d "c_g"
  rebasing 11:3ad57527186d "c_h"
  $ hg log -G
  o  15 default {foo} draft c_h
  |
  o  14 default {foo} draft c_g
  |
  @  13 default {foo} draft c_D
  |
  | o  9 default {foo} draft c_f
  | |
  | o  8 default {foo} draft c_e
  | |
  | x  7 default {foo} draft c_d
  |/
  o  2 default {foo} draft c_c
  |
  o  1 default {} draft c_b
  |
  o  0 default {} draft c_a
  

  $ hg topic --list
    _ c_b
  t1: c_c
  t2@ c_D (current)
  t3: c_g
  t4: c_h
    _ c_D
  t5$ c_e (unstable)
  t6$ c_f (unstable)