Patchwork [3,of,4,V2] merge-tools: make premerge valid values extensible

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 6, 2014, 12:07 a.m.
Message ID <ec36b2fda1e546f1f94a.1407283623@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5276/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 6, 2014, 12:07 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 ec36b2fda1e546f1f94af26b3d501ea85c2613a7
# Parent  c59783e15c14e8c5417d379cebae1be0b815fdca
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,28 +176,29 @@  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)
         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! "