--- 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