mercurial/patch.py
changeset 8461 88f317e7d280
parent 8396 d7a77ad9bcce
child 8526 f78eadbb5769
equal deleted inserted replaced
8460:d4c545dc6f87 8461:88f317e7d280
  1031 def updatedir(ui, repo, patches, similarity=0):
  1031 def updatedir(ui, repo, patches, similarity=0):
  1032     '''Update dirstate after patch application according to metadata'''
  1032     '''Update dirstate after patch application according to metadata'''
  1033     if not patches:
  1033     if not patches:
  1034         return
  1034         return
  1035     copies = []
  1035     copies = []
  1036     removes = {}
  1036     removes = set()
  1037     cfiles = patches.keys()
  1037     cfiles = patches.keys()
  1038     cwd = repo.getcwd()
  1038     cwd = repo.getcwd()
  1039     if cwd:
  1039     if cwd:
  1040         cfiles = [util.pathto(repo.root, cwd, f) for f in patches.keys()]
  1040         cfiles = [util.pathto(repo.root, cwd, f) for f in patches.keys()]
  1041     for f in patches:
  1041     for f in patches:
  1042         gp = patches[f]
  1042         gp = patches[f]
  1043         if not gp:
  1043         if not gp:
  1044             continue
  1044             continue
  1045         if gp.op == 'RENAME':
  1045         if gp.op == 'RENAME':
  1046             copies.append((gp.oldpath, gp.path))
  1046             copies.append((gp.oldpath, gp.path))
  1047             removes[gp.oldpath] = 1
  1047             removes.add(gp.oldpath)
  1048         elif gp.op == 'COPY':
  1048         elif gp.op == 'COPY':
  1049             copies.append((gp.oldpath, gp.path))
  1049             copies.append((gp.oldpath, gp.path))
  1050         elif gp.op == 'DELETE':
  1050         elif gp.op == 'DELETE':
  1051             removes[gp.path] = 1
  1051             removes.add(gp.path)
  1052     for src, dst in copies:
  1052     for src, dst in copies:
  1053         repo.copy(src, dst)
  1053         repo.copy(src, dst)
  1054     removes = removes.keys()
       
  1055     if (not similarity) and removes:
  1054     if (not similarity) and removes:
  1056         repo.remove(sorted(removes), True)
  1055         repo.remove(sorted(removes), True)
  1057     for f in patches:
  1056     for f in patches:
  1058         gp = patches[f]
  1057         gp = patches[f]
  1059         if gp and gp.mode:
  1058         if gp and gp.mode:
  1238         copy, diverge = copies.copies(repo, ctx1, ctx2, repo[nullid])
  1237         copy, diverge = copies.copies(repo, ctx1, ctx2, repo[nullid])
  1239         copy = copy.copy()
  1238         copy = copy.copy()
  1240         for k, v in copy.items():
  1239         for k, v in copy.items():
  1241             copy[v] = k
  1240             copy[v] = k
  1242 
  1241 
  1243     gone = {}
  1242     gone = set()
  1244     gitmode = {'l': '120000', 'x': '100755', '': '100644'}
  1243     gitmode = {'l': '120000', 'x': '100755', '': '100644'}
  1245 
  1244 
  1246     for f in sorted(modified + added + removed):
  1245     for f in sorted(modified + added + removed):
  1247         to = None
  1246         to = None
  1248         tn = None
  1247         tn = None
  1260                     a = copy[f]
  1259                     a = copy[f]
  1261                     omode = gitmode[man1.flags(a)]
  1260                     omode = gitmode[man1.flags(a)]
  1262                     _addmodehdr(header, omode, mode)
  1261                     _addmodehdr(header, omode, mode)
  1263                     if a in removed and a not in gone:
  1262                     if a in removed and a not in gone:
  1264                         op = 'rename'
  1263                         op = 'rename'
  1265                         gone[a] = 1
  1264                         gone.add(a)
  1266                     else:
  1265                     else:
  1267                         op = 'copy'
  1266                         op = 'copy'
  1268                     header.append('%s from %s\n' % (op, a))
  1267                     header.append('%s from %s\n' % (op, a))
  1269                     header.append('%s to %s\n' % (op, f))
  1268                     header.append('%s to %s\n' % (op, f))
  1270                     to = getfilectx(a, ctx1).data()
  1269                     to = getfilectx(a, ctx1).data()