[PATCH 2 of 2] filemerge: detect merge tool aborts

Steve Borho steve at borho.org
Mon Feb 4 20:27:09 CST 2008


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1202177707 21600
# Node ID 532093498c8f7953d01a1bc3d874deee24d8be24
# Parent  bb87b78bf30a6c3642b04e3a42aea8775fb78f38
filemerge: detect merge tool aborts

Some merge tools return 0 even if they do not write an output file.
This patch tries to at least recognize that the merge failed.

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -7,7 +7,7 @@
 
 from node import *
 from i18n import _
-import util, os, tempfile, context, simplemerge, re
+import util, os, tempfile, context, simplemerge, re, filecmp
 
 def _toolstr(ui, tool, part, default=""):
     return ui.config("merge-tools", tool + "." + part, default)
@@ -199,6 +199,11 @@
     if r:
         repo.ui.warn(_("merging %s failed!\n") % fd)
     else:
+        if filecmp.cmp(repo.wjoin(fd), back):
+            if ui.prompt(_(" output file %s appears unchanged\n"
+                "was merge successful (yn)?") % fd,
+                _("[yn]"), _("n")) != _("y"):
+                r = 1
         os.unlink(back)
 
     os.unlink(b)


More information about the Mercurial-devel mailing list