changeset 1427:fcc467ca740e

next/prev: require --merge to move with uncommitted changes This should previous common mistake.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 23 Jun 2015 15:26:51 -0700
parents 6db55f28c965
children 20a3b0b27bfe
files README hgext/evolve.py tests/test-prev-next.t
diffstat 3 files changed, 39 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/README	Tue Jun 23 15:32:47 2015 -0700
+++ b/README	Tue Jun 23 15:26:51 2015 -0700
@@ -64,6 +64,7 @@
 - evolve: `hg evolve --all` only evolve changeset that will end up as
           descendant of the current working copy. The old behavior of `--all`
           in now in `--all --any`.
+- next/prev: requires `--merge` to move with uncommited changes
 
 5.1.5 -- 2015-06-23
 
--- a/hgext/evolve.py	Tue Jun 23 15:32:47 2015 -0700
+++ b/hgext/evolve.py	Tue Jun 23 15:26:51 2015 -0700
@@ -1950,7 +1950,8 @@
 
 @command('^previous',
          [('B', 'move-bookmark', False,
-             _('Move active bookmark after update'))],
+             _('Move active bookmark after update')),
+          ('', 'merge', False, _('bring uncommited change along'))],
          '[-B]')
 def cmdprevious(ui, repo, **opts):
     """update to parent and display summary lines"""
@@ -1958,6 +1959,12 @@
     wparents = wkctx.parents()
     if len(wparents) != 1:
         raise util.Abort('merge in progress')
+    if not opts['merge']:
+        try:
+            cmdutil.bailifchanged(repo)
+        except error.Abort, exc:
+            exc.hint = _('do you want --merge?')
+            raise
 
     parents = wparents[0].parents()
     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
@@ -1982,7 +1989,8 @@
 
 @command('^next',
          [('B', 'move-bookmark', False,
-             _('Move active bookmark after update'))],
+             _('Move active bookmark after update')),
+          ('', 'merge', False, _('bring uncommited change along'))],
          '[-B]')
 def cmdnext(ui, repo, **opts):
     """update to child and display summary lines"""
@@ -1990,6 +1998,12 @@
     wparents = wkctx.parents()
     if len(wparents) != 1:
         raise util.Abort('merge in progress')
+    if not opts['merge']:
+        try:
+            cmdutil.bailifchanged(repo)
+        except error.Abort, exc:
+            exc.hint = _('do you want --merge?')
+            raise
 
     children = [ctx for ctx in wparents[0].children() if not ctx.obsolete()]
     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
--- a/tests/test-prev-next.t	Tue Jun 23 15:32:47 2015 -0700
+++ b/tests/test-prev-next.t	Tue Jun 23 15:26:51 2015 -0700
@@ -82,3 +82,25 @@
   $ hg bookmarks
      mark                      2:4e26ef31f919
      no-move                   2:4e26ef31f919
+
+
+Behavior with local modification
+--------------------------------
+
+  $ echo foo > modified-bar
+  $ hg add modified-bar
+  $ hg prev
+  abort: uncommitted changes
+  (do you want --merge?)
+  [255]
+  $ hg prev --merge
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  [0] added a
+  $ hg next
+  abort: uncommitted changes
+  (do you want --merge?)
+  [255]
+  $ hg next --merge
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  [1] added b
+