comparison 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
comparison
equal deleted inserted replaced
19972:1e13a5a9c66e 19973:1184edaead7a
1701 to = getfilectx(f, ctx1).data() 1701 to = getfilectx(f, ctx1).data()
1702 if f not in removed: 1702 if f not in removed:
1703 tn = getfilectx(f, ctx2).data() 1703 tn = getfilectx(f, ctx2).data()
1704 a, b = f, f 1704 a, b = f, f
1705 if opts.git or losedatafn: 1705 if opts.git or losedatafn:
1706 if f in added: 1706 if f in added or (f in modified and to is None):
1707 mode = gitmode[ctx2.flags(f)] 1707 mode = gitmode[ctx2.flags(f)]
1708 if f in copy or f in copyto: 1708 if f in copy or f in copyto:
1709 if opts.git: 1709 if opts.git:
1710 if f in copy: 1710 if f in copy:
1711 a = copy[f] 1711 a = copy[f]
1737 else: 1737 else:
1738 losedatafn(f) 1738 losedatafn(f)
1739 if not opts.git and not tn: 1739 if not opts.git and not tn:
1740 # regular diffs cannot represent new empty file 1740 # regular diffs cannot represent new empty file
1741 losedatafn(f) 1741 losedatafn(f)
1742 elif f in removed: 1742 elif f in removed or (f in modified and tn is None):
1743 if opts.git: 1743 if opts.git:
1744 # have we already reported a copy above? 1744 # have we already reported a copy above?
1745 if ((f in copy and copy[f] in added 1745 if ((f in copy and copy[f] in added
1746 and copyto[copy[f]] == f) or 1746 and copyto[copy[f]] == f) or
1747 (f in copyto and copyto[f] in added 1747 (f in copyto and copyto[f] in added