next: respect `commands.update.check` config option in `hg next` (issue5808) stable
authorPulkit Goyal <7895pulkit@gmail.com>
Sun, 03 Jun 2018 02:37:13 +0530
branchstable
changeset 3782 27cf636b2f4d
parent 3781 e73a73b27f3e
child 3783 313484606461
next: respect `commands.update.check` config option in `hg next` (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 next` 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.
hgext3rd/evolve/__init__.py
tests/test-prev-next.t
--- a/hgext3rd/evolve/__init__.py	Sun Jun 03 02:36:24 2018 +0530
+++ b/hgext3rd/evolve/__init__.py	Sun Jun 03 02:37:13 2018 +0530
@@ -1113,11 +1113,15 @@
             cmdutil.bailifchanged(repo)
 
         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
 
         children = [ctx for ctx in wparents[0].children() if not ctx.obsolete()]
         topic = _getcurrenttopic(repo)
@@ -1204,7 +1208,7 @@
         if shouldmove:
             ui.write(_('hg bookmark %s -r %s;\n') % (bm, children))
     else:
-        ret = hg.update(repo, children)
+        ret = hg.updatetotally(ui, repo, children.node(), None)
         if not ret:
             lock = tr = None
             try:
--- a/tests/test-prev-next.t	Sun Jun 03 02:36:24 2018 +0530
+++ b/tests/test-prev-next.t	Sun Jun 03 02:37:13 2018 +0530
@@ -410,11 +410,10 @@
 testing for `hg next`
 
   $ hg next
-  abort: uncommitted changes
-  (do you want --merge?)
-  [255]
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  [2] added bar
   $ hg diff
-  diff -r cf959ce4e1ff wat
+  diff -r ac3de1218820 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 @@