[PATCH 1 of 2] filemerge: extract conflict marker searching into its own function

Gregory Szorc gregory.szorc at gmail.com
Sat Aug 30 12:41:37 CDT 2014


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1409418673 -7200
#      Sat Aug 30 19:11:13 2014 +0200
# Node ID 55c81bbb9b76fe941faea87e77b0a5c95d4425f2
# Parent  188b8aa2120b03eead618ba150319074f4e3b42b
filemerge: extract conflict marker searching into its own function

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -433,10 +433,9 @@ def filemerge(repo, mynode, orig, fcd, f
         return r
 
     if not r and (_toolbool(ui, tool, "checkconflicts") or
                   'conflicts' in _toollist(ui, tool, "check")):
-        if re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data(),
-                     re.MULTILINE):
+        if haveconflictmarkers(fcd):
             r = 1
 
     checked = False
     if 'prompt' in _toollist(ui, tool, "check"):
@@ -465,6 +464,11 @@ def filemerge(repo, mynode, orig, fcd, f
     util.unlink(b)
     util.unlink(c)
     return r
 
+def hasconflictmarkers(fctx):
+    """Whether data from a filecontext has conflict markers."""
+    return re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fctx.data(),
+                     re.MULTILINE)
+
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = internals.values()


More information about the Mercurial-devel mailing list