changeset 3781:e73a73b27f3e stable

prev: respect `commands.update.check` config option in `hg prev` (issue5808) `commands.update.check` config option determines what level of checking should be done when we update to another revision. When we set this config option to `noconflict`, it updates your working directory to a specified revision only when there will be no conflicts which is a very nice behavior. This patch adds logic to respect the config option so that we can have that nice behavior with `hg prev` too. It turns out, we just needed to use hg.updatetotally() and add some cases to check config option. Right now, we only respect the config if value is set to `noconflict`. Otherwise we fallback to the default behavior. This is a part of fixing issue5808. Test changes demonstrate the fix.
author Pulkit Goyal <7895pulkit@gmail.com>
date Sun, 03 Jun 2018 02:36:24 +0530
parents 9da11755d615
children 27cf636b2f4d
files hgext3rd/evolve/__init__.py tests/test-prev-next.t
diffstat 2 files changed, 13 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/__init__.py	Sun Jun 03 02:50:55 2018 +0530
+++ b/hgext3rd/evolve/__init__.py	Sun Jun 03 02:36:24 2018 +0530
@@ -973,7 +973,7 @@
             repo.ui.write(_('hg bookmark %s -r %s;\n')
                           % (bookmark, target))
     else:
-        ret = hg.update(repo, target.rev())
+        ret = hg.updatetotally(repo.ui, repo, target.node(), None)
         if not ret:
             tr = lock = None
             try:
@@ -1050,11 +1050,15 @@
         if len(wparents) != 1:
             raise error.Abort(_('merge in progress'))
         if not opts['merge']:
-            try:
-                cmdutil.bailifchanged(repo)
-            except error.Abort as exc:
-                exc.hint = _('do you want --merge?')
-                raise
+            # we only skip the check if noconflict is set
+            if ui.config('commands', 'update.check') == 'noconflict':
+                pass
+            else:
+                try:
+                    cmdutil.bailifchanged(repo)
+                except error.Abort as exc:
+                    exc.hint = _('do you want --merge?')
+                    raise
 
         displayer = compat.changesetdisplayer(ui, repo,
                                               {'template': shorttemplate})
--- a/tests/test-prev-next.t	Sun Jun 03 02:50:55 2018 +0530
+++ b/tests/test-prev-next.t	Sun Jun 03 02:36:24 2018 +0530
@@ -397,11 +397,10 @@
 
   $ echo bar > wat
   $ hg prev
-  abort: uncommitted changes
-  (do you want --merge?)
-  [255]
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  [1] added foo
   $ hg diff
-  diff -r ac3de1218820 wat
+  diff -r cf959ce4e1ff wat
   --- a/wat	Thu Jan 01 00:00:00 1970 +0000
   +++ b/wat	Thu Jan 01 00:00:00 1970 +0000
   @@ -1,1 +1,1 @@
@@ -410,10 +409,6 @@
 
 testing for `hg next`
 
-  $ echo hi > wat
-  $ hg up .^
-  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ echo bar > wat
   $ hg next
   abort: uncommitted changes
   (do you want --merge?)