[Updated] D12149: filemerge: when not keeping premerge, don't write markers to context

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Feb 15 12:56:48 UTC 2022


Closed by commit rHG86e4b86df932: filemerge: when not keeping premerge, don't write markers to context (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D12149?vs=32139&id=32193

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D12149/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D12149

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -411,7 +411,7 @@
         raise error.Abort(msg)
 
 
-def _premerge(repo, local, other, base, toolconf, backup):
+def _premerge(repo, local, other, base, toolconf):
     tool, toolpath, binary, symlink, scriptfn = toolconf
     if symlink or local.fctx.isabsent() or other.fctx.isabsent():
         return 1
@@ -445,15 +445,13 @@
         merged_text, conflicts = simplemerge.simplemerge(
             ui, local, base, other, mode=mode
         )
-        # fcd.flags() already has the merged flags (done in
-        # mergestate.resolve())
-        local.fctx.write(merged_text, local.fctx.flags())
+        if not conflicts or premerge in validkeep:
+            # fcd.flags() already has the merged flags (done in
+            # mergestate.resolve())
+            local.fctx.write(merged_text, local.fctx.flags())
         if not conflicts:
             ui.debug(b" premerge successful\n")
             return 0
-        if premerge not in validkeep:
-            # restore from backup and try again
-            _restorebackup(local.fctx, backup)
     return 1  # continue merging
 
 
@@ -879,12 +877,6 @@
     }
 
 
-def _restorebackup(fcd, backup):
-    # TODO: Add a workingfilectx.write(otherfilectx) path so we can use
-    # util.copy here instead.
-    fcd.write(backup.data(), fcd.flags())
-
-
 def _makebackup(repo, ui, wctx, fcd):
     """Makes and returns a filectx-like object for ``fcd``'s backup file.
 
@@ -1123,7 +1115,6 @@
                 other,
                 base,
                 toolconf,
-                backup,
             )
             # we're done if premerge was successful (r is 0)
             if not r:



To: martinvonz, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220215/75d417c2/attachment-0002.html>


More information about the Mercurial-patches mailing list