tests/test-topic-stack.t
branchmercurial-3.9
changeset 2801 49494d0155b7
parent 2800 13c4d518327a
parent 2702 167567795f6c
child 2802 41c9a4df628e
child 2811 35d053d7bd87
equal deleted inserted replaced
2800:13c4d518327a 2801:49494d0155b7
     1   $ . "$TESTDIR/testlib/topic_setup.sh"
       
     2 
       
     3 Initial setup
       
     4 
       
     5 
       
     6   $ cat << EOF >> $HGRCPATH
       
     7   > [extensions]
       
     8   > color =
       
     9   > [ui]
       
    10   > logtemplate = {rev} {branch} \{{get(namespaces, "topics")}} {phase} {desc|firstline}\n
       
    11   > [experimental]
       
    12   > evolution=createmarkers,exchange,allowunstable
       
    13   > EOF
       
    14 
       
    15   $ hg init main
       
    16   $ cd main
       
    17   $ hg topic other
       
    18   $ echo aaa > aaa
       
    19   $ hg add aaa
       
    20   $ hg commit -m c_a
       
    21   $ echo aaa > bbb
       
    22   $ hg add bbb
       
    23   $ hg commit -m c_b
       
    24   $ hg topic foo
       
    25   $ echo aaa > ccc
       
    26   $ hg add ccc
       
    27   $ hg commit -m c_c
       
    28   $ echo aaa > ddd
       
    29   $ hg add ddd
       
    30   $ hg commit -m c_d
       
    31   $ echo aaa > eee
       
    32   $ hg add eee
       
    33   $ hg commit -m c_e
       
    34   $ echo aaa > fff
       
    35   $ hg add fff
       
    36   $ hg commit -m c_f
       
    37   $ hg log -G
       
    38   @  5 default {foo} draft c_f
       
    39   |
       
    40   o  4 default {foo} draft c_e
       
    41   |
       
    42   o  3 default {foo} draft c_d
       
    43   |
       
    44   o  2 default {foo} draft c_c
       
    45   |
       
    46   o  1 default {other} draft c_b
       
    47   |
       
    48   o  0 default {other} draft c_a
       
    49   
       
    50 
       
    51 Check that topic without any parent does not crash --list
       
    52 ---------------------------------------------------------
       
    53 
       
    54   $ hg up other
       
    55   switching to topic other
       
    56   0 files updated, 0 files merged, 4 files removed, 0 files unresolved
       
    57   $ hg topic --list
       
    58   ### topic: other
       
    59   ### branch: default
       
    60   t2@ c_b (current)
       
    61   t1: c_a
       
    62   $ hg phase --public 'topic("other")'
       
    63   $ hg up foo
       
    64   switching to topic foo
       
    65   4 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
    66 
       
    67 Simple test
       
    68 -----------
       
    69 
       
    70 'hg stack' list all changeset in the topic
       
    71 
       
    72   $ hg topic
       
    73    * foo
       
    74   $ hg stack
       
    75   ### topic: foo
       
    76   ### branch: default
       
    77   t4@ c_f (current)
       
    78   t3: c_e
       
    79   t2: c_d
       
    80   t1: c_c
       
    81   t0^ c_b (base)
       
    82   $ hg stack -v
       
    83   ### topic: foo
       
    84   ### branch: default
       
    85   t4(6559e6d93aea)@ c_f (current)
       
    86   t3(0f9ac936c87d): c_e
       
    87   t2(e629654d7050): c_d
       
    88   t1(8522f9e3fee9): c_c
       
    89   t0(ea705abc4f51)^ c_b (base)
       
    90   $ hg stack -Tjson | python -m json.tool
       
    91   [
       
    92       {
       
    93           "isentry": true,
       
    94           "topic.stack.desc": "c_f",
       
    95           "topic.stack.index": 4,
       
    96           "topic.stack.state": [
       
    97               "current"
       
    98           ],
       
    99           "topic.stack.state.symbol": "@"
       
   100       },
       
   101       {
       
   102           "isentry": true,
       
   103           "topic.stack.desc": "c_e",
       
   104           "topic.stack.index": 3,
       
   105           "topic.stack.state": [
       
   106               "clean"
       
   107           ],
       
   108           "topic.stack.state.symbol": ":"
       
   109       },
       
   110       {
       
   111           "isentry": true,
       
   112           "topic.stack.desc": "c_d",
       
   113           "topic.stack.index": 2,
       
   114           "topic.stack.state": [
       
   115               "clean"
       
   116           ],
       
   117           "topic.stack.state.symbol": ":"
       
   118       },
       
   119       {
       
   120           "isentry": true,
       
   121           "topic.stack.desc": "c_c",
       
   122           "topic.stack.index": 1,
       
   123           "topic.stack.state": [
       
   124               "clean"
       
   125           ],
       
   126           "topic.stack.state.symbol": ":"
       
   127       },
       
   128       {
       
   129           "isentry": false,
       
   130           "topic.stack.desc": "c_b",
       
   131           "topic.stack.index": 0,
       
   132           "topic.stack.state": [
       
   133               "base"
       
   134           ],
       
   135           "topic.stack.state.symbol": "^"
       
   136       }
       
   137   ]
       
   138   $ hg stack -v -Tjson | python -m json.tool
       
   139   [
       
   140       {
       
   141           "isentry": true,
       
   142           "topic.stack.desc": "c_f",
       
   143           "topic.stack.index": 4,
       
   144           "topic.stack.shortnode": "6559e6d93aea",
       
   145           "topic.stack.state": [
       
   146               "current"
       
   147           ],
       
   148           "topic.stack.state.symbol": "@"
       
   149       },
       
   150       {
       
   151           "isentry": true,
       
   152           "topic.stack.desc": "c_e",
       
   153           "topic.stack.index": 3,
       
   154           "topic.stack.shortnode": "0f9ac936c87d",
       
   155           "topic.stack.state": [
       
   156               "clean"
       
   157           ],
       
   158           "topic.stack.state.symbol": ":"
       
   159       },
       
   160       {
       
   161           "isentry": true,
       
   162           "topic.stack.desc": "c_d",
       
   163           "topic.stack.index": 2,
       
   164           "topic.stack.shortnode": "e629654d7050",
       
   165           "topic.stack.state": [
       
   166               "clean"
       
   167           ],
       
   168           "topic.stack.state.symbol": ":"
       
   169       },
       
   170       {
       
   171           "isentry": true,
       
   172           "topic.stack.desc": "c_c",
       
   173           "topic.stack.index": 1,
       
   174           "topic.stack.shortnode": "8522f9e3fee9",
       
   175           "topic.stack.state": [
       
   176               "clean"
       
   177           ],
       
   178           "topic.stack.state.symbol": ":"
       
   179       },
       
   180       {
       
   181           "isentry": false,
       
   182           "topic.stack.desc": "c_b",
       
   183           "topic.stack.index": 0,
       
   184           "topic.stack.shortnode": "ea705abc4f51",
       
   185           "topic.stack.state": [
       
   186               "base"
       
   187           ],
       
   188           "topic.stack.state.symbol": "^"
       
   189       }
       
   190   ]
       
   191 
       
   192 error case, nothing to list
       
   193 
       
   194   $ hg topic --clear
       
   195   $ hg stack
       
   196   ### branch: 
       
   197 
       
   198 Test "t#" reference
       
   199 -------------------
       
   200 
       
   201 
       
   202   $ hg up t2
       
   203   abort: cannot resolve "t2": no active topic
       
   204   [255]
       
   205   $ hg topic foo
       
   206   $ hg up t42
       
   207   abort: cannot resolve "t42": topic "foo" has only 4 changesets
       
   208   [255]
       
   209   $ hg up t2
       
   210   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
       
   211   $ hg summary
       
   212   parent: 3:e629654d7050 
       
   213    c_d
       
   214   branch: default
       
   215   commit: (clean)
       
   216   update: (current)
       
   217   phases: 4 draft
       
   218   topic:  foo
       
   219 
       
   220 Case with some of the topic unstable
       
   221 ------------------------------------
       
   222 
       
   223   $ echo bbb > ddd
       
   224   $ hg commit --amend
       
   225   $ hg log -G
       
   226   @  7 default {foo} draft c_d
       
   227   |
       
   228   | o  5 default {foo} draft c_f
       
   229   | |
       
   230   | o  4 default {foo} draft c_e
       
   231   | |
       
   232   | x  3 default {foo} draft c_d
       
   233   |/
       
   234   o  2 default {foo} draft c_c
       
   235   |
       
   236   o  1 default {} public c_b
       
   237   |
       
   238   o  0 default {} public c_a
       
   239   
       
   240   $ hg topic --list
       
   241   ### topic: foo
       
   242   ### branch: default
       
   243   t4$ c_f (unstable)
       
   244   t3$ c_e (unstable)
       
   245   t2@ c_d (current)
       
   246   t1: c_c
       
   247   t0^ c_b (base)
       
   248   $ hg up t3
       
   249   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   250   $ hg topic --list
       
   251   ### topic: foo
       
   252   ### branch: default
       
   253   t4$ c_f (unstable)
       
   254   t3$ c_e (current unstable)
       
   255   t2: c_d
       
   256   t1: c_c
       
   257   t0^ c_b (base)
       
   258   $ hg topic --list --color=debug
       
   259   [topic.stack.summary.topic|### topic: [topic.active|foo]]
       
   260   [topic.stack.summary.branches|### branch: default]
       
   261   [topic.stack.index topic.stack.index.unstable|t4][topic.stack.state topic.stack.state.unstable|$] [topic.stack.desc topic.stack.desc.unstable|c_f][topic.stack.state topic.stack.state.unstable| (unstable)]
       
   262   [topic.stack.index topic.stack.index.current topic.stack.index.unstable|t3][topic.stack.state topic.stack.state.current topic.stack.state.unstable|$] [topic.stack.desc topic.stack.desc.current topic.stack.desc.unstable|c_e][topic.stack.state topic.stack.state.current topic.stack.state.unstable| (current unstable)]
       
   263   [topic.stack.index topic.stack.index.clean|t2][topic.stack.state topic.stack.state.clean|:] [topic.stack.desc topic.stack.desc.clean|c_d]
       
   264   [topic.stack.index topic.stack.index.clean|t1][topic.stack.state topic.stack.state.clean|:] [topic.stack.desc topic.stack.desc.clean|c_c]
       
   265   [topic.stack.index topic.stack.index.base|t0][topic.stack.state topic.stack.state.base|^] [topic.stack.desc topic.stack.desc.base|c_b][topic.stack.state topic.stack.state.base| (base)]
       
   266   $ hg up t2
       
   267   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
       
   268 
       
   269 Also test the revset:
       
   270 
       
   271   $ hg log -r 'stack()'
       
   272   2 default {foo} draft c_c
       
   273   7 default {foo} draft c_d
       
   274   4 default {foo} draft c_e
       
   275   5 default {foo} draft c_f
       
   276 
       
   277   $ hg log -r 'stack(foo)'
       
   278   hg: parse error: stack() takes no argument, it works on current topic
       
   279   [255]
       
   280 
       
   281   $ hg log -r 'stack(foobar)'
       
   282   hg: parse error: stack() takes no argument, it works on current topic
       
   283   [255]
       
   284 
       
   285 Case with multiple heads on the topic
       
   286 -------------------------------------
       
   287 
       
   288 Make things linear again
       
   289 
       
   290   $ hg rebase -s 'desc(c_e)' -d 'desc(c_d) - obsolete()'
       
   291   rebasing 4:0f9ac936c87d "c_e"
       
   292   rebasing 5:6559e6d93aea "c_f"
       
   293   $ hg log -G
       
   294   o  9 default {foo} draft c_f
       
   295   |
       
   296   o  8 default {foo} draft c_e
       
   297   |
       
   298   @  7 default {foo} draft c_d
       
   299   |
       
   300   o  2 default {foo} draft c_c
       
   301   |
       
   302   o  1 default {} public c_b
       
   303   |
       
   304   o  0 default {} public c_a
       
   305   
       
   306 
       
   307 
       
   308 Create the second branch
       
   309 
       
   310   $ hg up 'desc(c_d)'
       
   311   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   312   $ echo aaa > ggg
       
   313   $ hg add ggg
       
   314   $ hg commit -m c_g
       
   315   $ echo aaa > hhh
       
   316   $ hg add hhh
       
   317   $ hg commit -m c_h
       
   318   $ hg log -G
       
   319   @  11 default {foo} draft c_h
       
   320   |
       
   321   o  10 default {foo} draft c_g
       
   322   |
       
   323   | o  9 default {foo} draft c_f
       
   324   | |
       
   325   | o  8 default {foo} draft c_e
       
   326   |/
       
   327   o  7 default {foo} draft c_d
       
   328   |
       
   329   o  2 default {foo} draft c_c
       
   330   |
       
   331   o  1 default {} public c_b
       
   332   |
       
   333   o  0 default {} public c_a
       
   334   
       
   335 
       
   336 Test output
       
   337 
       
   338   $ hg top -l
       
   339   ### topic: foo (2 heads)
       
   340   ### branch: default
       
   341   t6: c_f
       
   342   t5: c_e
       
   343   t2^ c_d (base)
       
   344   t4@ c_h (current)
       
   345   t3: c_g
       
   346   t2: c_d
       
   347   t1: c_c
       
   348   t0^ c_b (base)
       
   349 
       
   350 Case with multiple heads on the topic with unstability involved
       
   351 ---------------------------------------------------------------
       
   352 
       
   353 We amend the message to make sure the display base pick the right changeset
       
   354 
       
   355   $ hg up 'desc(c_d)'
       
   356   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
       
   357   $ echo ccc > ddd
       
   358   $ hg commit --amend -m 'c_D' 
       
   359   $ hg rebase -d . -s 'desc(c_g)'
       
   360   rebasing 10:81264ae8a36a "c_g"
       
   361   rebasing 11:fde5f5941642 "c_h"
       
   362   $ hg log -G
       
   363   o  15 default {foo} draft c_h
       
   364   |
       
   365   o  14 default {foo} draft c_g
       
   366   |
       
   367   @  13 default {foo} draft c_D
       
   368   |
       
   369   | o  9 default {foo} draft c_f
       
   370   | |
       
   371   | o  8 default {foo} draft c_e
       
   372   | |
       
   373   | x  7 default {foo} draft c_d
       
   374   |/
       
   375   o  2 default {foo} draft c_c
       
   376   |
       
   377   o  1 default {} public c_b
       
   378   |
       
   379   o  0 default {} public c_a
       
   380   
       
   381 
       
   382   $ hg topic --list
       
   383   ### topic: foo (2 heads)
       
   384   ### branch: default
       
   385   t6$ c_f (unstable)
       
   386   t5$ c_e (unstable)
       
   387   t2^ c_D (base)
       
   388   t4: c_h
       
   389   t3: c_g
       
   390   t2@ c_D (current)
       
   391   t1: c_c
       
   392   t0^ c_b (base)
       
   393 
       
   394 Trying to list non existing topic
       
   395   $ hg stack thisdoesnotexist
       
   396   abort: cannot resolve "thisdoesnotexist": no such topic found
       
   397   [255]
       
   398   $ hg topic --list thisdoesnotexist
       
   399   abort: cannot resolve "thisdoesnotexist": no such topic found
       
   400   [255]
       
   401