mercurial/patch.py
changeset 12577 05210e955bef
parent 12345 e0ee3e822a9a
parent 12576 1c9bb7e00f71
child 12645 d7452292f9d3
equal deleted inserted replaced
12573:be4b0a397470 12577:05210e955bef
  1182         elif state == 'git':
  1182         elif state == 'git':
  1183             for gp in values:
  1183             for gp in values:
  1184                 gp.path = pathstrip(gp.path, strip - 1)[1]
  1184                 gp.path = pathstrip(gp.path, strip - 1)[1]
  1185                 if gp.oldpath:
  1185                 if gp.oldpath:
  1186                     gp.oldpath = pathstrip(gp.oldpath, strip - 1)[1]
  1186                     gp.oldpath = pathstrip(gp.oldpath, strip - 1)[1]
  1187                 if gp.op in ('COPY', 'RENAME'):
  1187                 # Binary patches really overwrite target files, copying them
       
  1188                 # will just make it fails with "target file exists"
       
  1189                 if gp.op in ('COPY', 'RENAME') and not gp.binary:
  1188                     copyfn(gp.oldpath, gp.path, cwd)
  1190                     copyfn(gp.oldpath, gp.path, cwd)
  1189                 changed[gp.path] = gp
  1191                 changed[gp.path] = gp
  1190         else:
  1192         else:
  1191             raise util.Abort(_('unsupported parser state: %s') % state)
  1193             raise util.Abort(_('unsupported parser state: %s') % state)
  1192 
  1194 
  1528                 else:
  1530                 else:
  1529                     if opts.git:
  1531                     if opts.git:
  1530                         header.append('new file mode %s\n' % mode)
  1532                         header.append('new file mode %s\n' % mode)
  1531                     elif ctx2.flags(f):
  1533                     elif ctx2.flags(f):
  1532                         losedatafn(f)
  1534                         losedatafn(f)
       
  1535                 # In theory, if tn was copied or renamed we should check
       
  1536                 # if the source is binary too but the copy record already
       
  1537                 # forces git mode.
  1533                 if util.binary(tn):
  1538                 if util.binary(tn):
  1534                     if opts.git:
  1539                     if opts.git:
  1535                         dodiff = 'binary'
  1540                         dodiff = 'binary'
  1536                     else:
  1541                     else:
  1537                         losedatafn(f)
  1542                         losedatafn(f)
  1547                          and copy[copyto[f]] == f)):
  1552                          and copy[copyto[f]] == f)):
  1548                         dodiff = False
  1553                         dodiff = False
  1549                     else:
  1554                     else:
  1550                         header.append('deleted file mode %s\n' %
  1555                         header.append('deleted file mode %s\n' %
  1551                                       gitmode[man1.flags(f)])
  1556                                       gitmode[man1.flags(f)])
  1552                 elif not to:
  1557                 elif not to or util.binary(to):
  1553                     # regular diffs cannot represent empty file deletion
  1558                     # regular diffs cannot represent empty file deletion
  1554                     losedatafn(f)
  1559                     losedatafn(f)
  1555             else:
  1560             else:
  1556                 oflag = man1.flags(f)
  1561                 oflag = man1.flags(f)
  1557                 nflag = ctx2.flags(f)
  1562                 nflag = ctx2.flags(f)