mercurial/patch.py
changeset 24057 696d0fd77d94
parent 24056 ae453d166d51
child 24058 d1fcff9400c9
equal deleted inserted replaced
24056:ae453d166d51 24057:696d0fd77d94
  1794                             copyop = 'rename'
  1794                             copyop = 'rename'
  1795                             gone.add(f1)
  1795                             gone.add(f1)
  1796                         else:
  1796                         else:
  1797                             copyop = 'copy'
  1797                             copyop = 'copy'
  1798                         content1 = getfilectx(f1, ctx1).data()
  1798                         content1 = getfilectx(f1, ctx1).data()
  1799                     else:
       
  1800                         losedatafn(f)
       
  1801                 else:
       
  1802                     if not opts.git and flag2:
       
  1803                         losedatafn(f)
       
  1804                 binary = util.binary(content1) or util.binary(content2)
  1799                 binary = util.binary(content1) or util.binary(content2)
  1805                 if not opts.git and binary:
       
  1806                     losedatafn(f)
       
  1807                 if not opts.git and not content2:
       
  1808                     # regular diffs cannot represent new empty file
       
  1809                     losedatafn(f)
       
  1810             elif f in removedset:
  1800             elif f in removedset:
  1811                 if opts.git:
  1801                 if opts.git:
  1812                     # have we already reported a copy above?
  1802                     # have we already reported a copy above?
  1813                     if (f in copyto and copyto[f] in addedset
  1803                     if (f in copyto and copyto[f] in addedset
  1814                         and copy[copyto[f]] == f):
  1804                         and copy[copyto[f]] == f):
  1816                     else:
  1806                     else:
  1817                         flag1 = ctx1.flags(f)
  1807                         flag1 = ctx1.flags(f)
  1818                         binary = util.binary(content1)
  1808                         binary = util.binary(content1)
  1819                 else:
  1809                 else:
  1820                     binary = util.binary(content1)
  1810                     binary = util.binary(content1)
  1821                     if not content1 or binary:
       
  1822                         # regular diffs cannot represent empty file deletion
       
  1823                         losedatafn(f)
       
  1824             else:
  1811             else:
  1825                 flag1 = ctx1.flags(f)
  1812                 flag1 = ctx1.flags(f)
  1826                 flag2 = ctx2.flags(f)
  1813                 flag2 = ctx2.flags(f)
  1827                 binary = util.binary(content1) or util.binary(content2)
  1814                 binary = util.binary(content1) or util.binary(content2)
  1828                 if not opts.git and (binary or flag2 != flag1):
  1815 
  1829                     losedatafn(f)
  1816         if losedatafn and not opts.git:
       
  1817             if (binary or
       
  1818                 # copy/rename
       
  1819                 f in copy or
       
  1820                 # empty file creation
       
  1821                 (content1 is None and not content2) or
       
  1822                 # empty file deletion
       
  1823                 (not content1 and content2 is None) or
       
  1824                 # create with flags
       
  1825                 (content1 is None and flag2) or
       
  1826                 # change flags
       
  1827                 (content1 is not None and content2 is not None and
       
  1828                  flag1 != flag2)):
       
  1829                 losedatafn(f)
  1830 
  1830 
  1831         path1 = posixpath.join(prefix, f1)
  1831         path1 = posixpath.join(prefix, f1)
  1832         path2 = posixpath.join(prefix, f2)
  1832         path2 = posixpath.join(prefix, f2)
  1833         header = []
  1833         header = []
  1834         if opts.git:
  1834         if opts.git: