changeset 1849:9218f91619f6

topic: note when switching topics
author Matt Mackall <mpm@selenic.com>
date Wed, 10 Jun 2015 16:44:49 -0500
parents 9a81657deec2
children 0da6bf86b718
files src/topic/__init__.py tests/test-topic.t
diffstat 2 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/topic/__init__.py	Wed Jun 10 16:32:20 2015 -0500
+++ b/src/topic/__init__.py	Wed Jun 10 16:44:49 2015 -0500
@@ -131,6 +131,7 @@
 def updatewrap(orig, ui, repo, *args, **kwargs):
     ret = orig(ui, repo, *args, **kwargs)
     pctx = repo['.']
+    ot = repo.currenttopic
     if pctx.phase() == phases.public and repo.vfs.exists('topic'):
         repo.vfs.unlink('topic')
     else:
@@ -139,6 +140,8 @@
         if t and pctx.phase() > phases.public:
             with repo.vfs.open('topic', 'w') as f:
                 f.write(t)
+            if t != ot:
+                ui.status(_("switching to topic %s\n") % t)
     return ret
 
 extensions.wrapcommand(commands.table, 'update', updatewrap)
--- a/tests/test-topic.t	Wed Jun 10 16:32:20 2015 -0500
+++ b/tests/test-topic.t	Wed Jun 10 16:44:49 2015 -0500
@@ -50,6 +50,7 @@
   created new head
   $ hg co narf
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  switching to topic narf
   $ hg topic
      fran
    * narf
@@ -215,6 +216,7 @@
   $ cd ../pinky
   $ hg co query
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  switching to topic query
   $ echo answer >> alpha
   $ hg ci -m 'Narf is like `zort` or `poit`!'
   $ hg merge narf
@@ -418,6 +420,7 @@
 
   $ hg co fran
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  switching to topic fran
   $ hg topics
    * fran
   $ hg topics --clear