contrib/simplemerge
changeset 48755 6ae3c97a0919
parent 48752 109fec7bf7de
child 48758 7dad4665d223
--- a/contrib/simplemerge	Thu Feb 10 15:48:01 2022 -0800
+++ b/contrib/simplemerge	Fri Jan 14 08:17:13 2022 -0800
@@ -15,6 +15,7 @@
     fancyopts,
     simplemerge,
     ui as uimod,
+    util,
 )
 from mercurial.utils import procutil, stringutil
 
@@ -116,18 +117,21 @@
     _verifytext(base_input, ui, quiet=quiet, allow_binary=allow_binary)
     _verifytext(other_input, ui, quiet=quiet, allow_binary=allow_binary)
 
-    sys.exit(
-        simplemerge.simplemerge(
-            ui,
-            local_input,
-            base_input,
-            other_input,
-            mode,
-            quiet=True,
-            allow_binary=allow_binary,
-            print_result=opts.get(b'print'),
-        )
+    merged_text, conflicts = simplemerge.simplemerge(
+        ui,
+        local_input,
+        base_input,
+        other_input,
+        mode,
+        quiet=True,
+        allow_binary=allow_binary,
+        print_result=opts.get(b'print'),
     )
+    if opts.get(b'print'):
+        ui.fout.write(merged_text)
+    else:
+        util.writefile(local, merged_text)
+    sys.exit(1 if conflicts else 0)
 except ParseError as e:
     e = stringutil.forcebytestr(e)
     procutil.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e))