changeset 2985:f63c97c01f92

topics/ui: signal when the topics command creates a new (empty) topic
author Aurélien Campéas
date Tue, 26 Sep 2017 12:29:15 +0200
parents 30f6030dca8f
children 4746b92cc1f8
files hgext3rd/topic/__init__.py tests/test-evolve-topic.t tests/test-split.t tests/test-topic-dest.t tests/test-topic-fold.t tests/test-topic-push-concurrent-on.t tests/test-topic-push.t tests/test-topic-rebase.t tests/test-topic-shelve.t tests/test-topic-stack-data.t tests/test-topic-stack.t tests/test-topic-tutorial.t tests/test-topic.t
diffstat 13 files changed, 36 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Tue Sep 26 12:27:43 2017 +0200
+++ b/hgext3rd/topic/__init__.py	Tue Sep 26 12:29:15 2017 +0200
@@ -437,8 +437,8 @@
             repo.invalidate()
         return
 
+    ct = repo.currenttopic
     if clear:
-        ct = repo.currenttopic
         empty = stack.stackdata(repo, topic=ct)['changesetcount'] == 0
         if empty:
             if ct:
@@ -446,11 +446,13 @@
         return _changecurrenttopic(repo, None)
 
     if topic:
+        if not ct:
+            ui.status(_('marked working directory as topic: %s\n') % topic)
         return _changecurrenttopic(repo, topic)
 
     # `hg topic --current`
     ret = 0
-    if current and not repo.currenttopic:
+    if current and not ct:
         ui.write_err(_('no active topic\n'))
         ret = 1
     elif current:
@@ -458,7 +460,7 @@
         namemask = '%s\n'
         label = 'topic.active'
         fm.startitem()
-        fm.write('topic', namemask, repo.currenttopic, label=label)
+        fm.write('topic', namemask, ct, label=label)
         fm.end()
     else:
         _listtopics(ui, repo, opts)
--- a/tests/test-evolve-topic.t	Tue Sep 26 12:27:43 2017 +0200
+++ b/tests/test-evolve-topic.t	Tue Sep 26 12:29:15 2017 +0200
@@ -31,6 +31,7 @@
   $ mkcommit aaa
   $ mkcommit bbb
   $ hg topic foo
+  marked working directory as topic: foo
   $ mkcommit ccc
   $ mkcommit ddd
   $ mkcommit eee
--- a/tests/test-split.t	Tue Sep 26 12:27:43 2017 +0200
+++ b/tests/test-split.t	Tue Sep 26 12:29:15 2017 +0200
@@ -405,6 +405,7 @@
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "topic=$(echo $(dirname $TESTDIR))/hgext3rd/topic/" >> $HGRCPATH
   $ hg topic mytopic
+  marked working directory as topic: mytopic
   $ echo babar > babar
   $ echo celeste > celeste
   $ hg add babar celeste
--- a/tests/test-topic-dest.t	Tue Sep 26 12:27:43 2017 +0200
+++ b/tests/test-topic-dest.t	Tue Sep 26 12:29:15 2017 +0200
@@ -450,6 +450,7 @@
   $ hg up 'p1(roots(topic(elephant)))'
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg topic elephant
+  marked working directory as topic: elephant
   $ hg up
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg log -G
--- a/tests/test-topic-fold.t	Tue Sep 26 12:27:43 2017 +0200
+++ b/tests/test-topic-fold.t	Tue Sep 26 12:29:15 2017 +0200
@@ -37,6 +37,7 @@
   $ cd testfold
   $ mkcommit ROOT
   $ hg topic myfeature
+  marked working directory as topic: myfeature
   $ mkcommit feature1
   $ mkcommit feature2
   $ logtopic
@@ -77,6 +78,7 @@
   $ mkcommit feature3
   created new head
   $ hg topic myotherfeature
+  marked working directory as topic: myotherfeature
   $ mkcommit feature4
   $ logtopic
   @  5:5ded4d6d578c37f339b0716de2e46e12ece7cbde
--- a/tests/test-topic-push-concurrent-on.t	Tue Sep 26 12:27:43 2017 +0200
+++ b/tests/test-topic-push-concurrent-on.t	Tue Sep 26 12:29:15 2017 +0200
@@ -130,6 +130,7 @@
   $ hg up -r 'desc(CA)'
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg topic babar
+  marked working directory as topic: babar
   $ echo aaa > ddd
   $ hg add ddd
   $ hg commit -m 'CD'
@@ -186,6 +187,7 @@
   $ hg up -r 'desc(CA)'
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg topic celeste
+  marked working directory as topic: celeste
   $ echo aaa > eee
   $ hg add eee
   $ hg commit -m 'CE'
@@ -274,6 +276,7 @@
   $ hg up 'desc(CB)'
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg topic babar
+  marked working directory as topic: babar
   $ echo aaa > fff
   $ hg add fff
   $ hg commit -m 'CF'
@@ -379,12 +382,14 @@
   $ echo aaa > aaa
   $ hg add aaa
   $ hg topic topicA
+  marked working directory as topic: topicA
   $ hg commit -m 'CA'
   $ hg up 'desc(CBASE)'
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ echo aaa > bbb
   $ hg add bbb
   $ hg topic topicB
+  marked working directory as topic: topicB
   $ hg commit -m 'CB'
   $ cd ..
   $ hg push -R repoA repoB
--- a/tests/test-topic-push.t	Tue Sep 26 12:27:43 2017 +0200
+++ b/tests/test-topic-push.t	Tue Sep 26 12:29:15 2017 +0200
@@ -126,6 +126,7 @@
   $ hg up -r 'desc(CA)'
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg topic babar
+  marked working directory as topic: babar
   $ echo aaa > ddd
   $ hg add ddd
   $ hg commit -m 'CD'
@@ -237,6 +238,7 @@
   $ hg up -r 'desc(CA)'
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg topic celeste
+  marked working directory as topic: celeste
   $ echo aaa > eee
   $ hg add eee
   $ hg commit -m 'CE'
@@ -325,6 +327,7 @@
   $ hg up 'desc(CB)'
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg topic babar
+  marked working directory as topic: babar
   $ echo aaa > fff
   $ hg add fff
   $ hg commit -m 'CF'
@@ -430,12 +433,14 @@
   $ echo aaa > aaa
   $ hg add aaa
   $ hg topic topicA
+  marked working directory as topic: topicA
   $ hg commit -m 'CA'
   $ hg up 'desc(CBASE)'
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ echo aaa > bbb
   $ hg add bbb
   $ hg topic topicB
+  marked working directory as topic: topicB
   $ hg commit -m 'CB'
   $ cd ..
   $ hg push -R repoA repoB
--- a/tests/test-topic-rebase.t	Tue Sep 26 12:27:43 2017 +0200
+++ b/tests/test-topic-rebase.t	Tue Sep 26 12:29:15 2017 +0200
@@ -40,6 +40,7 @@
 
 Work on myfeature
   $ hg topic myfeature
+  marked working directory as topic: myfeature
   $ mkcommit feature1
   $ hg stack
   ### topic: myfeature
@@ -102,6 +103,7 @@
 
 Update the common file in a topic
   $ hg topic myotherfeature
+  marked working directory as topic: myotherfeature
   $ echo "B" >> file
   $ hg commit -m "myotherfeature1"
 
--- a/tests/test-topic-shelve.t	Tue Sep 26 12:27:43 2017 +0200
+++ b/tests/test-topic-shelve.t	Tue Sep 26 12:29:15 2017 +0200
@@ -13,6 +13,7 @@
   $ touch a
   $ echo "Hello" >> a
   $ hg topic "testing-shelve"
+  marked working directory as topic: testing-shelve
   $ hg topic
    * testing-shelve
   $ hg ci -m "First commit" -A
--- a/tests/test-topic-stack-data.t	Tue Sep 26 12:27:43 2017 +0200
+++ b/tests/test-topic-stack-data.t	Tue Sep 26 12:29:15 2017 +0200
@@ -54,6 +54,7 @@
   $ hg up 'desc(base_c)'
   2 files updated, 0 files merged, 2 files removed, 0 files unresolved
   $ hg topic baz
+  marked working directory as topic: baz
   $ mkcommit baz_a
   $ mkcommit baz_b
 
@@ -62,6 +63,7 @@
   $ hg up 'desc(base_d)'
   1 files updated, 0 files merged, 2 files removed, 0 files unresolved
   $ hg topic fuz
+  marked working directory as topic: fuz
   $ mkcommit fuz_a
   $ mkcommit fuz_b
   $ mkcommit fuz_c
@@ -74,6 +76,7 @@
   $ hg up 'desc(base_e)'
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg topic bar
+  marked working directory as topic: bar
   $ mkcommit bar_a
   $ mkcommit bar_b
   $ mkcommit bar_c
@@ -90,6 +93,7 @@
   $ hg up 'desc(lake_a)'
   1 files updated, 0 files merged, 7 files removed, 0 files unresolved
   $ hg topic foo
+  marked working directory as topic: foo
   $ mkcommit foo_a
   $ mkcommit foo_b
 
--- a/tests/test-topic-stack.t	Tue Sep 26 12:27:43 2017 +0200
+++ b/tests/test-topic-stack.t	Tue Sep 26 12:29:15 2017 +0200
@@ -13,6 +13,7 @@
   $ hg init main
   $ cd main
   $ hg topic other
+  marked working directory as topic: other
   $ echo aaa > aaa
   $ hg add aaa
   $ hg commit -m c_a
@@ -238,6 +239,7 @@
   abort: cannot resolve "t2": no active topic
   [255]
   $ hg topic foo
+  marked working directory as topic: foo
   $ hg up t42
   abort: cannot resolve "t42": topic "foo" has only 4 changesets
   [255]
@@ -568,6 +570,7 @@
   $ hg commit -Am 'c_A'
   adding aaa
   $ hg topic red
+  marked working directory as topic: red
   $ echo bbb > bbb
   $ hg commit -Am 'c_B'
   adding bbb
--- a/tests/test-topic-tutorial.t	Tue Sep 26 12:27:43 2017 +0200
+++ b/tests/test-topic-tutorial.t	Tue Sep 26 12:29:15 2017 +0200
@@ -95,6 +95,7 @@
 within a topic. Creating a new topic is done using the ``topic`` command:
 
   $ hg topics food
+  marked working directory as topic: food
 
 Much like a named branch, our topic is active but it does not contain any
 changeset yet:
@@ -731,6 +732,7 @@
 tools to the shopping list within a new topic:
 
   $ hg topics tools
+  marked working directory as topic: tools
   $ echo hammer >> shopping
   $ hg commit -m 'Adding hammer'
 
@@ -748,6 +750,7 @@
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
   $ hg topics drinks
+  marked working directory as topic: drinks
   $ echo 'apple juice' >> shopping
   $ hg commit -m 'Adding apple juice'
 
--- a/tests/test-topic.t	Tue Sep 26 12:27:43 2017 +0200
+++ b/tests/test-topic.t	Tue Sep 26 12:29:15 2017 +0200
@@ -153,6 +153,7 @@
   $ hg co .^
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg topic fran
+  marked working directory as topic: fran
   $ hg topics
    * fran
      narf
@@ -314,6 +315,7 @@
   $ hg topic
   $ echo what >> alpha
   $ hg topic query
+  marked working directory as topic: query
   $ hg ci -m 'what is narf, pinky?'
   $ hg log -Gl2
   @  changeset:   5:c01515cfc331
@@ -729,6 +731,7 @@
 Amend a topic
 
   $ hg topic watwat
+  marked working directory as topic: watwat
   $ hg ci --amend
   $ hg log -Gr 'draft()'
   @  changeset:   15:6c40a4c21bbe