mercurial/patch.py
changeset 24101 1ea90d140ee3
parent 24058 d1fcff9400c9
child 24102 00280a2b8b9a
equal deleted inserted replaced
24100:7f23e67e9c38 24101:1ea90d140ee3
  1783         if f not in removedset:
  1783         if f not in removedset:
  1784             content2 = getfilectx(f, ctx2).data()
  1784             content2 = getfilectx(f, ctx2).data()
  1785         f1, f2 = f, f
  1785         f1, f2 = f, f
  1786         if opts.git or losedatafn:
  1786         if opts.git or losedatafn:
  1787             if f in addedset:
  1787             if f in addedset:
       
  1788                 f1 = None
  1788                 flag2 = ctx2.flags(f)
  1789                 flag2 = ctx2.flags(f)
  1789                 if f in copy:
  1790                 if f in copy:
  1790                     if opts.git:
  1791                     if opts.git:
  1791                         f1 = copy[f]
  1792                         f1 = copy[f]
  1792                         flag1 = ctx1.flags(f1)
  1793                         flag1 = ctx1.flags(f1)
  1795                             gone.add(f1)
  1796                             gone.add(f1)
  1796                         else:
  1797                         else:
  1797                             copyop = 'copy'
  1798                             copyop = 'copy'
  1798                         content1 = getfilectx(f1, ctx1).data()
  1799                         content1 = getfilectx(f1, ctx1).data()
  1799             elif f in removedset:
  1800             elif f in removedset:
       
  1801                 f2 = None
  1800                 if opts.git:
  1802                 if opts.git:
  1801                     # have we already reported a copy above?
  1803                     # have we already reported a copy above?
  1802                     if (f in copyto and copyto[f] in addedset
  1804                     if (f in copyto and copyto[f] in addedset
  1803                         and copy[copyto[f]] == f):
  1805                         and copy[copyto[f]] == f):
  1804                         continue
  1806                         continue
  1813         if losedatafn and not opts.git:
  1815         if losedatafn and not opts.git:
  1814             if (binary or
  1816             if (binary or
  1815                 # copy/rename
  1817                 # copy/rename
  1816                 f in copy or
  1818                 f in copy or
  1817                 # empty file creation
  1819                 # empty file creation
  1818                 (content1 is None and not content2) or
  1820                 (not f1 and not content2) or
  1819                 # empty file deletion
  1821                 # empty file deletion
  1820                 (not content1 and content2 is None) or
  1822                 (not content1 and not f2) or
  1821                 # create with flags
  1823                 # create with flags
  1822                 (content1 is None and flag2) or
  1824                 (not f1 and flag2) or
  1823                 # change flags
  1825                 # change flags
  1824                 (content1 is not None and content2 is not None and
  1826                 (f1 and f2 and flag1 != flag2)):
  1825                  flag1 != flag2)):
       
  1826                 losedatafn(f)
  1827                 losedatafn(f)
  1827 
  1828 
  1828         path1 = posixpath.join(prefix, f1)
  1829         path1 = posixpath.join(prefix, f1 or f2)
  1829         path2 = posixpath.join(prefix, f2)
  1830         path2 = posixpath.join(prefix, f2 or f1)
  1830         header = []
  1831         header = []
  1831         if opts.git:
  1832         if opts.git:
  1832             header.append('diff --git %s%s %s%s' %
  1833             header.append('diff --git %s%s %s%s' %
  1833                           (aprefix, path1, bprefix, path2))
  1834                           (aprefix, path1, bprefix, path2))
  1834             if content1 is None: # added
  1835             if not f1: # added
  1835                 header.append('new file mode %s' % gitmode[flag2])
  1836                 header.append('new file mode %s' % gitmode[flag2])
  1836             elif content2 is None: # removed
  1837             elif not f2: # removed
  1837                 header.append('deleted file mode %s' % gitmode[flag1])
  1838                 header.append('deleted file mode %s' % gitmode[flag1])
  1838             else:  # modified/copied/renamed
  1839             else:  # modified/copied/renamed
  1839                 mode1, mode2 = gitmode[flag1], gitmode[flag2]
  1840                 mode1, mode2 = gitmode[flag1], gitmode[flag2]
  1840                 if mode1 != mode2:
  1841                 if mode1 != mode2:
  1841                     header.append('old mode %s' % mode1)
  1842                     header.append('old mode %s' % mode1)