topics/ui: detect and signal when an empty changeset becomes non-empty
authorAurélien Campéas
Tue, 26 Sep 2017 12:39:11 +0200
changeset 2988 62201935e1a7
parent 2987 d59d6413bb68
child 2990 c2102598adf5
topics/ui: detect and signal when an empty changeset becomes non-empty
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
--- a/hgext3rd/topic/__init__.py	Fri Sep 22 18:01:29 2017 +0200
+++ b/hgext3rd/topic/__init__.py	Tue Sep 26 12:39:11 2017 +0200
@@ -318,17 +318,28 @@
             if ctr is not None:
                 return tr
 
+            # real transaction start
+            ct = self.currenttopic
+            if not ct:
+                return tr
+            ctwasempty = stack.stackdata(self, topic=ct)['changesetcount'] == 0
+
             reporef = weakref.ref(self)
 
             def currenttopicempty(tr):
                 # check active topic emptyness
-                ct = self.currenttopic
-                if not ct:
-                    return
                 repo = reporef()
-                empty = stack.stackdata(repo, topic=ct)['changesetcount'] == 0
-                if empty:
+                csetcount = stack.stackdata(repo, topic=ct)['changesetcount']
+                empty = csetcount == 0
+                if empty and not ctwasempty:
                     ui.status('active topic %r is now empty\n' % ct)
+                if ctwasempty and not empty:
+                    if csetcount == 1:
+                        msg = _('active topic %r grew its first changeset\n')
+                        ui.status(msg % ct)
+                    else:
+                        msg = _('active topic %r grew its %s first changesets\n')
+                        ui.status(msg % (ct, csetcount))
 
             tr.addpostclose('signalcurrenttopicempty', currenttopicempty)
             return tr
--- a/tests/test-evolve-topic.t	Fri Sep 22 18:01:29 2017 +0200
+++ b/tests/test-evolve-topic.t	Tue Sep 26 12:39:11 2017 +0200
@@ -33,11 +33,13 @@
   $ hg topic foo
   marked working directory as topic: foo
   $ mkcommit ccc
+  active topic 'foo' grew its first changeset
   $ mkcommit ddd
   $ mkcommit eee
   $ mkcommit fff
   $ hg topic bar
   $ mkcommit ggg
+  active topic 'bar' grew its first changeset
   $ mkcommit hhh
   $ mkcommit iii
   $ mkcommit jjj
--- a/tests/test-split.t	Fri Sep 22 18:01:29 2017 +0200
+++ b/tests/test-split.t	Tue Sep 26 12:39:11 2017 +0200
@@ -410,6 +410,7 @@
   $ echo celeste > celeste
   $ hg add babar celeste
   $ hg commit -m "Works on mytopic" babar celeste --user victor
+  active topic 'mytopic' grew its first changeset
   $ hg log -r . 
   changeset:   18:26f72cfaf036
   branch:      new-branch
--- a/tests/test-topic-dest.t	Fri Sep 22 18:01:29 2017 +0200
+++ b/tests/test-topic-dest.t	Tue Sep 26 12:39:11 2017 +0200
@@ -28,6 +28,7 @@
   $ echo babar >> jungle
   $ hg add jungle
   $ hg ci -t elephant -m babar
+  active topic 'elephant' grew its first changeset
 
   $ hg log -G
   @  4 (elephant) babar
@@ -53,6 +54,7 @@
   $ echo zephir >> jungle
   $ hg add jungle
   $ hg ci -t monkey -m zephir
+  active topic 'monkey' grew its first changeset
   $ hg log -G
   @  5 (monkey) zephir
   |
--- a/tests/test-topic-fold.t	Fri Sep 22 18:01:29 2017 +0200
+++ b/tests/test-topic-fold.t	Tue Sep 26 12:39:11 2017 +0200
@@ -39,6 +39,7 @@
   $ hg topic myfeature
   marked working directory as topic: myfeature
   $ mkcommit feature1
+  active topic 'myfeature' grew its first changeset
   $ mkcommit feature2
   $ logtopic
   @  2:d76a6166b18c835be9a487c5e21c7d260f0a1676
@@ -80,6 +81,7 @@
   $ hg topic myotherfeature
   marked working directory as topic: myotherfeature
   $ mkcommit feature4
+  active topic 'myotherfeature' grew its first changeset
   $ logtopic
   @  5:5ded4d6d578c37f339b0716de2e46e12ece7cbde
   |  topics: myotherfeature
--- a/tests/test-topic-push-concurrent-on.t	Fri Sep 22 18:01:29 2017 +0200
+++ b/tests/test-topic-push-concurrent-on.t	Tue Sep 26 12:39:11 2017 +0200
@@ -134,6 +134,7 @@
   $ echo aaa > ddd
   $ hg add ddd
   $ hg commit -m 'CD'
+  active topic 'babar' grew its first changeset
   $ hg log -G # keep track of phase because I saw some strange bug during developement
   @  4 default babar draft CD
   |
@@ -191,6 +192,7 @@
   $ echo aaa > eee
   $ hg add eee
   $ hg commit -m 'CE'
+  active topic 'celeste' grew its first changeset
   $ hg log -G # keep track of phase because I saw some strange bug during developement
   @  5 default celeste draft CE
   |
@@ -384,6 +386,7 @@
   $ hg topic topicA
   marked working directory as topic: topicA
   $ hg commit -m 'CA'
+  active topic 'topicA' grew its first changeset
   $ hg up 'desc(CBASE)'
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ echo aaa > bbb
@@ -391,6 +394,7 @@
   $ hg topic topicB
   marked working directory as topic: topicB
   $ hg commit -m 'CB'
+  active topic 'topicB' grew its first changeset
   $ cd ..
   $ hg push -R repoA repoB
   pushing to repoB
--- a/tests/test-topic-push.t	Fri Sep 22 18:01:29 2017 +0200
+++ b/tests/test-topic-push.t	Tue Sep 26 12:39:11 2017 +0200
@@ -130,6 +130,7 @@
   $ echo aaa > ddd
   $ hg add ddd
   $ hg commit -m 'CD'
+  active topic 'babar' grew its first changeset
   $ hg log -G # keep track of phase because I saw some strange bug during developement
   @  4 default babar draft CD
   |
@@ -242,6 +243,7 @@
   $ echo aaa > eee
   $ hg add eee
   $ hg commit -m 'CE'
+  active topic 'celeste' grew its first changeset
   $ hg log -G # keep track of phase because I saw some strange bug during developement
   @  5 default celeste draft CE
   |
@@ -435,6 +437,7 @@
   $ hg topic topicA
   marked working directory as topic: topicA
   $ hg commit -m 'CA'
+  active topic 'topicA' grew its first changeset
   $ hg up 'desc(CBASE)'
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ echo aaa > bbb
@@ -442,6 +445,7 @@
   $ hg topic topicB
   marked working directory as topic: topicB
   $ hg commit -m 'CB'
+  active topic 'topicB' grew its first changeset
   $ cd ..
   $ hg push -R repoA repoB
   pushing to repoB
--- a/tests/test-topic-rebase.t	Fri Sep 22 18:01:29 2017 +0200
+++ b/tests/test-topic-rebase.t	Tue Sep 26 12:39:11 2017 +0200
@@ -42,6 +42,7 @@
   $ hg topic myfeature
   marked working directory as topic: myfeature
   $ mkcommit feature1
+  active topic 'myfeature' grew its first changeset
   $ hg stack
   ### topic: myfeature
   ### branch: default
@@ -106,6 +107,7 @@
   marked working directory as topic: myotherfeature
   $ echo "B" >> file
   $ hg commit -m "myotherfeature1"
+  active topic 'myotherfeature' grew its first changeset
 
 Update the common file in default
   $ hg update --rev default
--- a/tests/test-topic-shelve.t	Fri Sep 22 18:01:29 2017 +0200
+++ b/tests/test-topic-shelve.t	Tue Sep 26 12:39:11 2017 +0200
@@ -18,6 +18,7 @@
    * testing-shelve
   $ hg ci -m "First commit" -A
   adding a
+  active topic 'testing-shelve' grew its first changeset
   $ hg topic
    * testing-shelve
   $ echo " World" >> a
--- a/tests/test-topic-stack-data.t	Fri Sep 22 18:01:29 2017 +0200
+++ b/tests/test-topic-stack-data.t	Tue Sep 26 12:39:11 2017 +0200
@@ -56,6 +56,7 @@
   $ hg topic baz
   marked working directory as topic: baz
   $ mkcommit baz_a
+  active topic 'baz' grew its first changeset
   $ mkcommit baz_b
 
 A simple topic with unstability
@@ -65,6 +66,7 @@
   $ hg topic fuz
   marked working directory as topic: fuz
   $ mkcommit fuz_a
+  active topic 'fuz' grew its first changeset
   $ mkcommit fuz_b
   $ mkcommit fuz_c
   $ hg up 'desc(fuz_a)'
@@ -78,6 +80,7 @@
   $ hg topic bar
   marked working directory as topic: bar
   $ mkcommit bar_a
+  active topic 'bar' grew its first changeset
   $ mkcommit bar_b
   $ mkcommit bar_c
   $ hg up 'desc(bar_b)'
@@ -95,6 +98,7 @@
   $ hg topic foo
   marked working directory as topic: foo
   $ mkcommit foo_a
+  active topic 'foo' grew its first changeset
   $ mkcommit foo_b
 
 Summary
--- a/tests/test-topic-stack.t	Fri Sep 22 18:01:29 2017 +0200
+++ b/tests/test-topic-stack.t	Tue Sep 26 12:39:11 2017 +0200
@@ -17,6 +17,7 @@
   $ echo aaa > aaa
   $ hg add aaa
   $ hg commit -m c_a
+  active topic 'other' grew its first changeset
   $ echo aaa > bbb
   $ hg add bbb
   $ hg commit -m c_b
@@ -24,6 +25,7 @@
   $ echo aaa > ccc
   $ hg add ccc
   $ hg commit -m c_c
+  active topic 'foo' grew its first changeset
   $ echo aaa > ddd
   $ hg add ddd
   $ hg commit -m c_d
@@ -575,6 +577,7 @@
   $ echo bbb > bbb
   $ hg commit -Am 'c_B'
   adding bbb
+  active topic 'red' grew its first changeset
   $ echo ccc > ccc
   $ hg commit -Am 'c_C'
   adding ccc
@@ -582,6 +585,7 @@
   $ echo ddd > ddd
   $ hg commit -Am 'c_D'
   adding ddd
+  active topic 'blue' grew its first changeset
   $ hg up 'desc("c_B")'
   switching to topic red
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
--- a/tests/test-topic-tutorial.t	Fri Sep 22 18:01:29 2017 +0200
+++ b/tests/test-topic-tutorial.t	Tue Sep 26 12:39:11 2017 +0200
@@ -151,6 +151,7 @@
   > EOF
 
   $ hg commit -m "adding condiments"
+  active topic 'food' grew its first changeset
 
   $ hg log --graph --rev 'topic("food")'
   @  changeset:   1:13900241408b
@@ -736,6 +737,7 @@
   marked working directory as topic: tools
   $ echo hammer >> shopping
   $ hg commit -m 'Adding hammer'
+  active topic 'tools' grew its first changeset
 
   $ echo saw >> shopping
   $ hg commit -m 'Adding saw'
@@ -754,6 +756,7 @@
   marked working directory as topic: drinks
   $ echo 'apple juice' >> shopping
   $ hg commit -m 'Adding apple juice'
+  active topic 'drinks' grew its first changeset
 
   $ echo 'orange juice' >> shopping
   $ hg commit -m 'Adding orange juice'
--- a/tests/test-topic.t	Fri Sep 22 18:01:29 2017 +0200
+++ b/tests/test-topic.t	Tue Sep 26 12:39:11 2017 +0200
@@ -150,6 +150,7 @@
 
   $ echo topic work >> alpha
   $ hg ci -m 'start on narf'
+  active topic 'narf' grew its first changeset
   $ hg co .^
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg topic fran
@@ -161,6 +162,7 @@
   fran
   $ echo >> fran work >> beta
   $ hg ci -m 'start on fran'
+  active topic 'fran' grew its first changeset
   $ hg co narf
   switching to topic narf
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -317,6 +319,7 @@
   $ hg topic query
   marked working directory as topic: query
   $ hg ci -m 'what is narf, pinky?'
+  active topic 'query' grew its first changeset
   $ hg log -Gl2
   @  changeset:   5:c01515cfc331
   |  tag:         tip
@@ -476,7 +479,6 @@
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files (+1 heads)
-  active topic 'query' is now empty
   (run 'hg heads' to see heads)
   $ hg topics
      fran
@@ -736,6 +738,7 @@
   $ 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
@@ -794,6 +797,7 @@
 
   $ 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()'
@@ -846,6 +850,7 @@
 
   $ hg topics --rev 't1::' changewut
   switching to topic changewut
+  active topic 'changewat' is now empty
   changed topic on 3 changes
 
   $ hg log -Gr 'draft()'
@@ -947,9 +952,11 @@
   $ hg add b
   $ hg topic topic1990
   $ hg ci -m "Added b" --config devel.default-date="631152000 0"
+  active topic 'topic1990' grew its first changeset
   $ hg add c
   $ hg topic topic2010
   $ hg ci -m "Added c" --config devel.default-date="1262304000 0"
+  active topic 'topic2010' grew its first changeset
 
   $ hg log -G
   @  changeset:   3:9048b194797d