diff mercurial/hg.py @ 42970:1ad3ebb39c61

merge: replace magic strings with NAMED_CONSTANTS (API) .. api:: `mercurial.hg.update*` and `mercurial.merge.update` now expect a value from a set of NAMED_CONSTANTS (`merge.UPDATECHECK_*` constants) rather than a collection of magic strings. As of now, the values are the same, but code should be prepared for these values to change in the future. Differential Revision: https://phab.mercurial-scm.org/D6877
author Augie Fackler <augie@google.com>
date Wed, 25 Sep 2019 10:53:10 -0400
parents 268662aac075
children ee1ef76d7339
line wrap: on
line diff
--- a/mercurial/hg.py	Wed Sep 25 12:59:26 2019 +0200
+++ b/mercurial/hg.py	Wed Sep 25 10:53:10 2019 -0400
@@ -897,21 +897,26 @@
     :clean: whether changes in the working directory can be discarded
     :updatecheck: how to deal with a dirty working directory
 
-    Valid values for updatecheck are (None => linear):
+    Valid values for updatecheck are the UPDATECHECK_* constants
+    defined in the merge module. Passing `None` will result in using the
+    configured default.
 
-     * abort: abort if the working directory is dirty
-     * none: don't check (merge working directory changes into destination)
-     * linear: check that update is linear before merging working directory
+     * ABORT: abort if the working directory is dirty
+     * NONE: don't check (merge working directory changes into destination)
+     * LINEAR: check that update is linear before merging working directory
                changes into destination
-     * noconflict: check that the update does not result in file merges
+     * NO_CONFLICT: check that the update does not result in file merges
 
     This returns whether conflict is detected at updating or not.
     """
     if updatecheck is None:
         updatecheck = ui.config('commands', 'update.check')
-        if updatecheck not in ('abort', 'none', 'linear', 'noconflict'):
+        if updatecheck not in (mergemod.UPDATECHECK_ABORT,
+                               mergemod.UPDATECHECK_NONE,
+                               mergemod.UPDATECHECK_LINEAR,
+                               mergemod.UPDATECHECK_NO_CONFLICT):
             # If not configured, or invalid value configured
-            updatecheck = 'linear'
+            updatecheck = mergemod.UPDATECHECK_LINEAR
     with repo.wlock():
         movemarkfrom = None
         warndest = False
@@ -923,9 +928,9 @@
         if clean:
             ret = _clean(repo, checkout)
         else:
-            if updatecheck == 'abort':
+            if updatecheck == mergemod.UPDATECHECK_ABORT:
                 cmdutil.bailifchanged(repo, merge=False)
-                updatecheck = 'none'
+                updatecheck = mergemod.UPDATECHECK_NONE
             ret = _update(repo, checkout, updatecheck=updatecheck)
 
         if not ret and movemarkfrom: