topic: restrict 'hg prev' to current topic unless --no-topic is passed
authorPierre-Yves David <pierre-yves.david@fb.com>
Thu, 17 Mar 2016 11:31:55 -0700
changeset 1629 548195454683
parent 1628 db19b1dc5c45
child 1630 35c666ef724e
topic: restrict 'hg prev' to current topic unless --no-topic is passed This is far from perfect but a good start
README
hgext/evolve.py
tests/test-evolve-topic.t
--- a/README	Thu Mar 17 11:25:01 2016 -0700
+++ b/README	Thu Mar 17 11:31:55 2016 -0700
@@ -58,9 +58,10 @@
 
 5.4.0 -- 
 
-- Some collaboration with the topic experimental extensions
-  - hg evolve --all with consider all trouble in your current topic
-  - preserve 'topic' during evolve
+- Some collaboration with the topic experimental extensions,
+  - hg evolve --all with consider all trouble in your current topic,
+  - preserve 'topic' during evolve,
+  - 'next' and 'prev' restrict themself to the current topic by default,
 
 5.3.0 -- 2016-02-11
 
--- a/hgext/evolve.py	Thu Mar 17 11:25:01 2016 -0700
+++ b/hgext/evolve.py	Thu Mar 17 11:31:55 2016 -0700
@@ -2100,8 +2100,14 @@
             raise
 
     parents = wparents[0].parents()
+    topic = getattr(repo, 'currenttopic', '')
+    if topic and not opts.get("no_topic", False):
+        parents = [ctx for ctx in parents if ctx.topic() == topic]
     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
-    if len(parents) == 1:
+    if not parents:
+        ui.warn(_('no parent in topic "%s"\n') % topic)
+        ui.warn(_('(do you want --no-topic)\n'))
+    elif len(parents) == 1:
         p = parents[0]
         bm = bmactive(repo)
         shouldmove = opts.get('move_bookmark') and bm is not None
@@ -2138,6 +2144,7 @@
              _('move active bookmark after update')),
           ('', 'merge', False, _('bring uncommitted change along')),
           ('', 'evolve', False, _('evolve the next changeset if necessary')),
+          ('', 'no-topic', False, _('ignore topic and move topologically')),
           ('n', 'dry-run', False,
               _('do not perform actions, just print what would be done'))],
               '[OPTION]...')
--- a/tests/test-evolve-topic.t	Thu Mar 17 11:25:01 2016 -0700
+++ b/tests/test-evolve-topic.t	Thu Mar 17 11:31:55 2016 -0700
@@ -214,3 +214,10 @@
   switching to topic bar
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   [16] add ggg
+  $ hg prev
+  no parent in topic "bar"
+  (do you want --no-topic)
+  $ hg prev --no-topic
+  switching to topic foo
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  [15] add fff