diff hgext/evolve.py @ 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
line wrap: on
line diff
--- 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]...')