changeset 1629:548195454683

topic: restrict 'hg prev' to current topic unless --no-topic is passed This is far from perfect but a good start
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 17 Mar 2016 11:31:55 -0700
parents db19b1dc5c45
children 35c666ef724e
files README hgext/evolve.py tests/test-evolve-topic.t
diffstat 3 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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