Patchwork [6,of,7] merge-tools: make premerge valid values extensible

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 5, 2014, 12:28 a.m.
Message ID <3becac234386b2ea0f5d.1407198492@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5262/
State Superseded
Commit b36c60cfe46f9db4d1237ac94a93f80562e1a800
Headers show

Comments

Pierre-Yves David - Aug. 5, 2014, 12:28 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1407196719 25200
#      Mon Aug 04 16:58:39 2014 -0700
# Node ID 3becac234386b2ea0f5d70f906b4daa1f7e0e6ae
# Parent  04480d872e4d83132d6c2d74d65261e4a2c5b1f7
merge-tools: make premerge valid values extensible

We want to introduce a version leaving merge3 style markers.

Patch

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -176,29 +176,30 @@  def _premerge(repo, toolconf, files, lab
         return 1
     a, b, c, back = files
 
     ui = repo.ui
 
+    validkeep = ['keep']
+
     # do we attempt to simplemerge first?
     try:
         premerge = _toolbool(ui, tool, "premerge", not binary)
     except error.ConfigError:
         premerge = _toolstr(ui, tool, "premerge").lower()
-        valid = 'keep'.split()
-        if premerge not in valid:
-            _valid = ', '.join(["'" + v + "'" for v in valid])
+        if premerge not in validkeep:
+            _valid = ', '.join(["'" + v + "'" for v in validkeep])
             raise error.ConfigError(_("%s.premerge not valid "
                                       "('%s' is neither boolean nor %s)") %
                                     (tool, premerge, _valid))
 
     if premerge:
         r = simplemerge.simplemerge(ui, a, b, c, quiet=True, label=labels,
                                     no_minimal=True)
         if not r:
             ui.debug(" premerge successful\n")
             return 0
-        if premerge != 'keep':
+        if premerge not in validkeep:
             util.copyfile(back, a) # restore from backup and try again
     return 1 # continue merging
 
 @internaltool('merge', True,
               _("merging %s incomplete! "