[PATCH 1 of 3 checkunknown] merge: factor out code to get checkunknown config

Siddharth Agarwal sid0 at fb.com
Tue Jan 12 20:40:44 CST 2016


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1452651155 28800
#      Tue Jan 12 18:12:35 2016 -0800
# Node ID e3ac8a047a74694082be679ac80a1b7ed86387fd
# Parent  edd2615ad226c14f6904fc1738c3dc36431db223
# Available At http://42.netv6.net/sid0-wip/hg/
#              hg pull http://42.netv6.net/sid0-wip/hg/ -r e3ac8a047a74
merge: factor out code to get checkunknown config

We're going to reuse this code shortly.

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -557,6 +557,16 @@ class mergestate(object):
         Meant for use by custom merge drivers."""
         self._results[f] = 0, 'g'
 
+def _getcheckunknownconfig(repo, section, name):
+    config = repo.ui.config(section, name, default='abort')
+    valid = ['abort', 'ignore', 'warn']
+    if config not in valid:
+        validstr = ', '.join(["'" + v + "'" for v in valid])
+        raise error.ConfigError(_("%s.%s not valid "
+                                  "('%s' is none of %s)")
+                                % (section, name, config, validstr))
+    return config
+
 def _checkunknownfile(repo, wctx, mctx, f, f2=None):
     if f2 is None:
         f2 = f
@@ -573,14 +583,7 @@ def _checkunknownfiles(repo, wctx, mctx,
     """
     conflicts = set()
     if not force:
-        config = repo.ui.config('merge', 'checkunknown', default='abort')
-        valid = ['abort', 'ignore', 'warn']
-        if config not in valid:
-            validstr = ', '.join(["'" + v + "'" for v in valid])
-            raise error.ConfigError(_("merge.checkunknown not valid "
-                                      "('%s' is none of %s)")
-                                    % (config, validstr))
-
+        config = _getcheckunknownconfig(repo, 'merge', 'checkunknown')
         for f, (m, args, msg) in actions.iteritems():
             if m in ('c', 'dc'):
                 if _checkunknownfile(repo, wctx, mctx, f):


More information about the Mercurial-devel mailing list