diff mercurial/patch.py @ 19973:1184edaead7a stable

patch: ensure valid git diffs if source/destination file is missing (issue4046) This is arguably a workaround, a better fix may be in the repo to ensure that it won't list a file 'modified' unless there is a file context for the previous version.
author Johan Bjork <jbjoerk@gmail.com>
date Sun, 13 Oct 2013 08:38:30 -0400
parents 7032dcff290c
children cd79d9ab5e42
line wrap: on
line diff
--- a/mercurial/patch.py	Sun Oct 27 00:24:25 2013 +0900
+++ b/mercurial/patch.py	Sun Oct 13 08:38:30 2013 -0400
@@ -1703,7 +1703,7 @@
             tn = getfilectx(f, ctx2).data()
         a, b = f, f
         if opts.git or losedatafn:
-            if f in added:
+            if f in added or (f in modified and to is None):
                 mode = gitmode[ctx2.flags(f)]
                 if f in copy or f in copyto:
                     if opts.git:
@@ -1739,7 +1739,7 @@
                 if not opts.git and not tn:
                     # regular diffs cannot represent new empty file
                     losedatafn(f)
-            elif f in removed:
+            elif f in removed or (f in modified and tn is None):
                 if opts.git:
                     # have we already reported a copy above?
                     if ((f in copy and copy[f] in added