Patchwork [1,of,4,mergedriver] filemerge: don't try to copy files known to be absent

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 20, 2015, 9:20 a.m.
Message ID <cf179a8119caf19611b7.1448011238@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11540/
State Accepted
Headers show

Comments

Siddharth Agarwal - Nov. 20, 2015, 9:20 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1447488046 28800
#      Sat Nov 14 00:00:46 2015 -0800
# Node ID cf179a8119caf19611b75b97b2215c14add2b69f
# Parent  0f33bdf524b161a58eda4f129bae5c7cf1eb367e
# Available At http://42.netv6.net/sid0-wip/hg/
#              hg pull http://42.netv6.net/sid0-wip/hg/ -r cf179a8119ca
filemerge: don't try to copy files known to be absent

We set 'back' to None in this case, so we need to handle that as well.

Patch

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -600,9 +600,12 @@  def _filemerge(premerge, repo, mynode, o
     a = repo.wjoin(fd)
     b = temp("base", fca)
     c = temp("other", fco)
-    back = cmdutil.origpath(ui, repo, a)
-    if premerge:
-        util.copyfile(a, back)
+    if not fcd.isabsent():
+        back = cmdutil.origpath(ui, repo, a)
+        if premerge:
+            util.copyfile(a, back)
+    else:
+        back = None
     files = (a, b, c, back)
 
     r = 1
@@ -630,7 +633,7 @@  def _filemerge(premerge, repo, mynode, o
 
         return True, r, deleted
     finally:
-        if not r:
+        if not r and back is not None:
             util.unlink(back)
         util.unlink(b)
         util.unlink(c)
@@ -655,13 +658,13 @@  def _check(r, ui, tool, fcd, files):
     if not r and not checked and (_toolbool(ui, tool, "checkchanged") or
                                   'changed' in
                                   _toollist(ui, tool, "check")):
-        if filecmp.cmp(a, back):
+        if back is not None and filecmp.cmp(a, back):
             if ui.promptchoice(_(" output file %s appears unchanged\n"
                                  "was merge successful (yn)?"
                                  "$$ &Yes $$ &No") % fd, 1):
                 r = 1
 
-    if _toolbool(ui, tool, "fixeol"):
+    if back is not None and _toolbool(ui, tool, "fixeol"):
         _matcheol(a, back)
 
     return r