diff hgext/evolve.py @ 1160:e29a813f6af5 stable

Make next/prev only move bookmarks optionally
author Ryan McElroy <rmcelroy@fb.com>
date Wed, 29 Oct 2014 10:34:08 -0700
parents 5951969400ce
children 5c07f464981e
line wrap: on
line diff
--- a/hgext/evolve.py	Tue Nov 11 12:38:49 2014 +0000
+++ b/hgext/evolve.py	Wed Oct 29 10:34:08 2014 -0700
@@ -1584,9 +1584,10 @@
 shorttemplate = '[{rev}] {desc|firstline}\n'
 
 @command('^previous',
-         [],
-         '')
-def cmdprevious(ui, repo):
+         [('B', 'move-bookmark', False,
+             _('Move current active bookmark after update'))],
+         '[-B]')
+def cmdprevious(ui, repo, **opts):
     """update to parent and display summary lines"""
     wkctx = repo[None]
     wparents = wkctx.parents()
@@ -1598,11 +1599,14 @@
     if len(parents) == 1:
         p = parents[0]
         bm = bookmarks.readcurrent(repo)
-        shouldmove = bm is not None and bookmarks.iscurrent(repo, bm)
+        shouldmove = opts.get('move_bookmark') and bm is not None
         ret = hg.update(repo, p.rev())
-        if not ret and shouldmove:
-            repo._bookmarks[bm] = p.node()
-            repo._bookmarks.write()
+        if not ret:
+            if shouldmove:
+                repo._bookmarks[bm] = p.node()
+                repo._bookmarks.write()
+            else:
+                bookmarks.unsetcurrent(repo)
         displayer.show(p)
         return 0
     else:
@@ -1612,9 +1616,10 @@
         return 1
 
 @command('^next',
-         [],
-         '')
-def cmdnext(ui, repo):
+         [('B', 'move-bookmark', False,
+             _('Move current active bookmark after update'))],
+         '[-B]')
+def cmdnext(ui, repo, **opts):
     """update to child and display summary lines"""
     wkctx = repo[None]
     wparents = wkctx.parents()
@@ -1629,11 +1634,14 @@
     if len(children) == 1:
         c = children[0]
         bm = bookmarks.readcurrent(repo)
-        shouldmove = bm is not None and bookmarks.iscurrent(repo, bm)
+        shouldmove = opts.get('move_bookmark') and bm is not None
         ret = hg.update(repo, c.rev())
-        if not ret and shouldmove:
-            repo._bookmarks[bm] = c.node()
-            repo._bookmarks.write()
+        if not ret:
+            if shouldmove:
+                repo._bookmarks[bm] = c.node()
+                repo._bookmarks.write()
+            else:
+                bookmarks.unsetcurrent(repo)
         displayer.show(c)
         return 0
     else: