changeset 3133:5c8d5f980f49

tests: add a new test for testing changing or clearing topics test-topic.t is getting bigger and bigger. This patch introduces a new test which includes test for clearing and changing topics. Since the tests are moved to a new file, this patch, removes those tests from test-topic.t also.
author Pulkit Goyal <7895pulkit@gmail.com>
date Thu, 05 Oct 2017 18:13:52 +0530
parents 60896df503ba
children 103244e34a9c
files tests/test-topic-change.t tests/test-topic.t
diffstat 2 files changed, 383 insertions(+), 265 deletions(-) [+]
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/tests/test-topic-change.t
@@ -0,0 +1,370 @@
+Tests for changing and clearing topics
+======================================
+
+  $ . "$TESTDIR/testlib/topic_setup.sh"
+  $ cat <<EOF >> $HGRCPATH
+  > [experimental]
+  > # disable the new graph style until we drop 3.7 support
+  > graphstyle.missing = |
+  > evolution=createmarkers, allowunstable
+  > [phases]
+  > publish=false
+  > [alias]
+  > glog = log -G -T "{rev}:{node|short} \{{topics}}\n{desc}  ({bookmarks})\n\n"
+  > EOF
+
+About the glog output: {} contains the topic name and () will contain the bookmark
+
+Setting up a repo
+----------------
+
+  $ hg init topics
+  $ cd topics
+  $ for ch in {a..h}; do touch $ch; echo "foo" >> $ch; hg ci -Aqm "Added "$ch; done
+
+  $ hg glog
+  @  7:ec2426147f0e {}
+  |  Added h  ()
+  |
+  o  6:87d6d6676308 {}
+  |  Added g  ()
+  |
+  o  5:825660c69f0c {}
+  |  Added f  ()
+  |
+  o  4:aa98ab95a928 {}
+  |  Added e  ()
+  |
+  o  3:62615734edd5 {}
+  |  Added d  ()
+  |
+  o  2:28ad74487de9 {}
+  |  Added c  ()
+  |
+  o  1:29becc82797a {}
+  |  Added b  ()
+  |
+  o  0:18d04c59bb5d {}
+     Added a  ()
+  
+
+Clearing topic from revision without topic
+
+  $ hg topic -r . --clear
+  changed topic on 0 changes
+
+Clearing current topic when no active topic is not error
+
+  $ hg topic
+  $ hg topic --clear
+
+Setting topics to all the revisions
+
+  $ hg topic -r 0:: foo
+  switching to topic foo
+  changed topic on 8 changes
+  $ hg glog
+  @  15:05095f607171 {foo}
+  |  Added h  ()
+  |
+  o  14:97505b53ab0d {foo}
+  |  Added g  ()
+  |
+  o  13:75a8360fe626 {foo}
+  |  Added f  ()
+  |
+  o  12:abcedffeae90 {foo}
+  |  Added e  ()
+  |
+  o  11:1315a3808ed0 {foo}
+  |  Added d  ()
+  |
+  o  10:1fa891977a22 {foo}
+  |  Added c  ()
+  |
+  o  9:a53ba98dd6b8 {foo}
+  |  Added b  ()
+  |
+  o  8:86a186070af2 {foo}
+     Added a  ()
+  
+
+Clearing the active topic using --clear
+
+  $ hg topic
+   * foo
+  $ hg topic --clear
+  $ hg topic
+     foo
+Changing topics on some revisions (also testing issue 5441)
+
+  $ hg topic -r 12:: bar
+  switching to topic bar
+  changed topic on 4 changes
+  $ hg glog
+  @  19:d7d36e193ea7 {bar}
+  |  Added h  ()
+  |
+  o  18:e7b418d79a05 {bar}
+  |  Added g  ()
+  |
+  o  17:82e0b14f4d9e {bar}
+  |  Added f  ()
+  |
+  o  16:edc4a6b9ea60 {bar}
+  |  Added e  ()
+  |
+  o  11:1315a3808ed0 {foo}
+  |  Added d  ()
+  |
+  o  10:1fa891977a22 {foo}
+  |  Added c  ()
+  |
+  o  9:a53ba98dd6b8 {foo}
+  |  Added b  ()
+  |
+  o  8:86a186070af2 {foo}
+     Added a  ()
+  
+
+Changing topics without passing topic name and clear
+
+  $ hg topic -r .
+  abort: changing topic requires a topic name or --clear
+  [255]
+
+Changing topic using --current flag
+
+  $ hg topic foobar
+  $ hg topic -r . --current
+  active topic 'foobar' grew its first changeset
+  changed topic on 1 changes
+  $ hg glog -r .
+  @  20:c2d6b7df5dcf {foobar}
+  |  Added h  ()
+  |
+
+Changing topic in between the stack
+
+  $ hg topic -r 9::10 --current
+  changed topic on 2 changes
+  $ hg glog
+  o  22:1b88140feefe {foobar}
+  |  Added c  ()
+  |
+  o  21:c39cabfcbbf7 {foobar}
+  |  Added b  ()
+  |
+  | @  20:c2d6b7df5dcf {foobar}
+  | |  Added h  ()
+  | |
+  | o  18:e7b418d79a05 {bar}
+  | |  Added g  ()
+  | |
+  | o  17:82e0b14f4d9e {bar}
+  | |  Added f  ()
+  | |
+  | o  16:edc4a6b9ea60 {bar}
+  | |  Added e  ()
+  | |
+  | o  11:1315a3808ed0 {foo}
+  | |  Added d  ()
+  | |
+  | x  10:1fa891977a22 {foo}
+  | |  Added c  ()
+  | |
+  | x  9:a53ba98dd6b8 {foo}
+  |/   Added b  ()
+  |
+  o  8:86a186070af2 {foo}
+     Added a  ()
+  
+  $ hg rebase -s 11 -d 22
+  rebasing 11:1315a3808ed0 "Added d" (foo)
+  switching to topic foo
+  rebasing 16:edc4a6b9ea60 "Added e" (bar)
+  switching to topic bar
+  rebasing 17:82e0b14f4d9e "Added f" (bar)
+  rebasing 18:e7b418d79a05 "Added g" (bar)
+  rebasing 20:c2d6b7df5dcf "Added h" (foobar)
+  switching to topic foobar
+
+  $ hg glog
+  @  27:a1a9465da59b {foobar}
+  |  Added h  ()
+  |
+  o  26:7c76c271395f {bar}
+  |  Added g  ()
+  |
+  o  25:7f26084dfaf1 {bar}
+  |  Added f  ()
+  |
+  o  24:b1f05e9ba0b5 {bar}
+  |  Added e  ()
+  |
+  o  23:f9869da2286e {foo}
+  |  Added d  ()
+  |
+  o  22:1b88140feefe {foobar}
+  |  Added c  ()
+  |
+  o  21:c39cabfcbbf7 {foobar}
+  |  Added b  ()
+  |
+  o  8:86a186070af2 {foo}
+     Added a  ()
+  
+Amending a topic
+----------------
+
+When the changeset has a topic and we have different active topic
+
+  $ hg topic wat
+  $ hg ci --amend
+  active topic 'wat' grew its first changeset
+  $ hg glog -r .
+  @  28:61470c956807 {wat}
+  |  Added h  ()
+  |
+
+Clear the current topic and amending
+
+  $ hg topic --clear
+  $ hg ci --amend
+  $ hg glog -r .
+  @  29:b584fa49f42e {}
+  |  Added h  ()
+  |
+
+When the changeset does not has a topic but we have an active topic
+
+  $ hg topic watwat
+  marked working directory as topic: watwat
+  $ hg ci --amend
+  active topic 'watwat' grew its first changeset
+  $ hg glog -r .
+  @  30:a24c31c35013 {watwat}
+  |  Added h  ()
+  |
+
+Testing changing topics on public changeset
+-------------------------------------------
+
+  $ hg phase -r 8 -p
+
+Clearing the topic
+
+  $ hg topic -r 8 --clear
+  abort: can't change topic of a public change
+  [255]
+
+Changing the topic
+
+  $ hg topic -r 8 foobarboo
+  abort: can't change topic of a public change
+  [255]
+
+Testing the bookmark movement
+-----------------------------
+
+  $ hg bookmark book
+  $ hg glog
+  @  30:a24c31c35013 {watwat}
+  |  Added h  (book)
+  |
+  o  26:7c76c271395f {bar}
+  |  Added g  ()
+  |
+  o  25:7f26084dfaf1 {bar}
+  |  Added f  ()
+  |
+  o  24:b1f05e9ba0b5 {bar}
+  |  Added e  ()
+  |
+  o  23:f9869da2286e {foo}
+  |  Added d  ()
+  |
+  o  22:1b88140feefe {foobar}
+  |  Added c  ()
+  |
+  o  21:c39cabfcbbf7 {foobar}
+  |  Added b  ()
+  |
+  o  8:86a186070af2 {}
+     Added a  ()
+  
+On clearing the topic
+XXX: the bookmark must have moved
+
+  $ hg topic -r . --clear
+  clearing empty topic "watwat"
+  active topic 'watwat' is now empty
+  changed topic on 1 changes
+
+  $ hg glog
+  @  31:c48d6d71b2d9 {}
+  |  Added h  ()
+  |
+  | x  30:a24c31c35013 {watwat}
+  |/   Added h  (book)
+  |
+  o  26:7c76c271395f {bar}
+  |  Added g  ()
+  |
+  o  25:7f26084dfaf1 {bar}
+  |  Added f  ()
+  |
+  o  24:b1f05e9ba0b5 {bar}
+  |  Added e  ()
+  |
+  o  23:f9869da2286e {foo}
+  |  Added d  ()
+  |
+  o  22:1b88140feefe {foobar}
+  |  Added c  ()
+  |
+  o  21:c39cabfcbbf7 {foobar}
+  |  Added b  ()
+  |
+  o  8:86a186070af2 {}
+     Added a  ()
+  
+
+On changing the topic
+XXX: the bookmark must have moved
+
+  $ hg bookmark bookboo
+  $ hg topic -r . movebook
+  switching to topic movebook
+  changed topic on 1 changes
+  $ hg glog
+  @  32:1b83d11095b9 {movebook}
+  |  Added h  ()
+  |
+  | x  31:c48d6d71b2d9 {}
+  |/   Added h  (bookboo)
+  |
+  | x  30:a24c31c35013 {watwat}
+  |/   Added h  (book)
+  |
+  o  26:7c76c271395f {bar}
+  |  Added g  ()
+  |
+  o  25:7f26084dfaf1 {bar}
+  |  Added f  ()
+  |
+  o  24:b1f05e9ba0b5 {bar}
+  |  Added e  ()
+  |
+  o  23:f9869da2286e {foo}
+  |  Added d  ()
+  |
+  o  22:1b88140feefe {foobar}
+  |  Added c  ()
+  |
+  o  21:c39cabfcbbf7 {foobar}
+  |  Added b  ()
+  |
+  o  8:86a186070af2 {}
+     Added a  ()
+  
--- a/tests/test-topic.t
+++ b/tests/test-topic.t
@@ -502,10 +502,6 @@
   $ hg topics
      fran
 
---clear when we don't have an active topic isn't an error:
-
-  $ hg topics --clear
-
 Topic revset
   $ hg log -r 'topic()' -G
   o  changeset:   9:0469d521db49
@@ -628,284 +624,36 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     start on fran
   |
+
   $ hg topics
      fran
-Changing topic fails if we don't give a topic
-  $ hg topic --rev 9
-  abort: changing topic requires a topic name or --clear
-  [255]
-
-Can't change topic of a public change
-  $ hg topic --rev 1:: --clear
-  abort: can't change topic of a public change
-  [255]
-
-Can clear topics
-  $ hg topic --rev 9 --clear
-  changed topic on 1 changes
-  $ hg log -Gr 'draft() and not obsolete()'
-  o  changeset:   11:0beca5ab56c3
-  |  tag:         tip
-  |  parent:      3:a53952faf762
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     start on fran
-  |
-  | @  changeset:   10:4073470c35e1
-  | |  user:        test
-  | |  date:        Thu Jan 01 00:00:00 1970 +0000
-  | |  instability: orphan
-  | |  summary:     fran?
-  | |
-
-Normally you'd do this with evolve, but we'll use rebase to avoid
-bonus deps in the testsuite.
-
-  $ hg rebase -d tip -s .
-  rebasing 10:4073470c35e1 "fran?"
-
-Can add a topic to an existing change
-  $ hg topic
-  $ hg sum
-  parent: 12:18b70b8de1f0 tip
-   fran?
-  branch: default
-  commit: (clean)
-  update: 5 new changesets, 2 branch heads (merge)
-  phases: 2 draft
-  $ hg topic --rev 11 wat
-  changed topic on 1 changes
-  $ hg log -r .
-  changeset:   12:18b70b8de1f0
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  instability: orphan
-  summary:     fran?
-  
-  $ hg sum
-  parent: 12:18b70b8de1f0  (orphan)
-   fran?
-  branch: default
-  commit: (clean)
-  update: 5 new changesets, 2 branch heads (merge)
-  phases: 3 draft
-  orphan: 1 changesets
-  $ hg topic
-     wat
-  $ hg log -Gr 'draft() and not obsolete()'
-  o  changeset:   13:686a642006db
-  |  tag:         tip
-  |  topic:       wat
-  |  parent:      3:a53952faf762
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     start on fran
-  |
-  | @  changeset:   12:18b70b8de1f0
-  | |  user:        test
-  | |  date:        Thu Jan 01 00:00:00 1970 +0000
-  | |  instability: orphan
-  | |  summary:     fran?
-  | |
-
-Normally you'd do this with evolve, but we'll use rebase to avoid
-bonus deps in the testsuite.
-
-  $ hg topic
-     wat
-  $ hg rebase -d tip -s .
-  rebasing 12:18b70b8de1f0 "fran?"
-  switching to topic wat
-  $ hg topic
-     wat
-
-  $ hg log -Gr 'draft()'
-  @  changeset:   14:45358f7a5892
-  |  tag:         tip
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     fran?
-  |
-  o  changeset:   13:686a642006db
-  |  topic:       wat
-  |  parent:      3:a53952faf762
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     start on fran
-  |
-
-Amend a topic
-
-  $ hg topic watwat
-  marked working directory as topic: watwat
-  $ hg ci --amend
-  active topic 'watwat' grew its first changeset
-  $ hg log -Gr 'draft()'
-  @  changeset:   15:6c40a4c21bbe
-  |  tag:         tip
-  |  topic:       watwat
-  |  parent:      13:686a642006db
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     fran?
-  |
-  o  changeset:   13:686a642006db
-  |  topic:       wat
-  |  parent:      3:a53952faf762
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     start on fran
-  |
-
-Clear and amend:
-
-  $ hg topic --clear
-  $ hg ci --amend
-  $ hg log -r .
-  changeset:   16:0f9cd5070654
-  tag:         tip
-  parent:      13:686a642006db
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     fran?
-  
-Reading the same topic with topic --rev should work:
-  $ hg topic --rev . watwat
-  switching to topic watwat
-  changed topic on 1 changes
-
-Testing issue5441
-  $ hg co 17
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg log -Gr 'draft()'
-  @  changeset:   17:980a0f608481
-  |  tag:         tip
-  |  topic:       watwat
-  |  parent:      13:686a642006db
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     fran?
-  |
-  o  changeset:   13:686a642006db
-  |  topic:       wat
-  |  parent:      3:a53952faf762
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     start on fran
-  |
-
-Using the current flag
-
-  $ hg topic changewat
-  $ hg topics --rev '13::17' --current
-  active topic 'changewat' grew its 2 first changesets
-  changed topic on 2 changes
-
-  $ hg log -Gr 'draft()'
-  @  changeset:   19:56c83be6105f
-  |  tag:         tip
-  |  topic:       changewat
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     fran?
-  |
-  o  changeset:   18:ceba5be9d56f
-  |  topic:       changewat
-  |  parent:      3:a53952faf762
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     start on fran
-  |
-
-Case with branching:
-
-  $ hg up changewat
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg up t1
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ echo gamma >> gamma
-  $ hg ci -m gamma
-
-  $ hg log -Gr 'draft()'
-  @  changeset:   20:0d3d805542b4
-  |  tag:         tip
-  |  topic:       changewat
-  |  parent:      18:ceba5be9d56f
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     gamma
-  |
-  | o  changeset:   19:56c83be6105f
-  |/   topic:       changewat
-  |    user:        test
-  |    date:        Thu Jan 01 00:00:00 1970 +0000
-  |    summary:     fran?
-  |
-  o  changeset:   18:ceba5be9d56f
-  |  topic:       changewat
-  |  parent:      3:a53952faf762
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     start on fran
-  |
-
-  $ hg topics --rev 't1::' changewut
-  switching to topic changewut
-  active topic 'changewat' is now empty
-  changed topic on 3 changes
-
-  $ hg log -Gr 'draft()'
-  @  changeset:   23:729ed5717393
-  |  tag:         tip
-  |  topic:       changewut
-  |  parent:      21:62e49f09f883
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     gamma
-  |
-  | o  changeset:   22:369c6e2e5474
-  |/   topic:       changewut
-  |    user:        test
-  |    date:        Thu Jan 01 00:00:00 1970 +0000
-  |    summary:     fran?
-  |
-  o  changeset:   21:62e49f09f883
-  |  topic:       changewut
-  |  parent:      3:a53952faf762
-  |  user:        test
-  |  date:        Thu Jan 01 00:00:00 1970 +0000
-  |  summary:     start on fran
-  |
 
 Testing for updating to t0
 ==========================
 
+  $ hg up fran
+  switching to topic fran
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg stack
-  ### topic: changewut (2 heads)
-  ### target: default (branch), 5 behind
-  t3: fran?
-  t1^ start on fran (base)
-  t2@ gamma (current)
-  t1: start on fran
+  ### topic: fran
+  ### target: default (branch), ambigious rebase destination - branch 'default' has 2 heads
+  t1@ start on fran (current)
   t0^ Add file delta (base)
 
   $ hg up t0
-  preserving the current topic 'changewut'
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  preserving the current topic 'fran'
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
   $ hg topic
-   * changewut
+   * fran
   $ hg stack
-  ### topic: changewut (2 heads)
-  ### target: default (branch), 5 behind
-  t3: fran?
-  t1^ start on fran (base)
-  t2: gamma
+  ### topic: fran
+  ### target: default (branch), ambigious rebase destination - branch 'default' has 2 heads
   t1: start on fran
   t0^ Add file delta (base)
 
   $ hg topics --age
-   * changewut (1970-01-01 by test)
+   * fran (1970-01-01 by test)
 
   $ cd ..