##// END OF EJS Templates
patch: map changed files to patchmeta directly
Patrick Mezard -
r7150:6d1d61bb default
parent child Browse files
Show More
@@ -925,7 +925,7 b' def iterhunks(ui, fp, sourcefile=None):'
925 try:
925 try:
926 if context == None and x.startswith('***************'):
926 if context == None and x.startswith('***************'):
927 context = True
927 context = True
928 gpatch = changed.get(bfile[2:], (None, None))[1]
928 gpatch = changed.get(bfile[2:])
929 create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD'
929 create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD'
930 remove = bfile == '/dev/null' or gpatch and gpatch.op == 'DELETE'
930 remove = bfile == '/dev/null' or gpatch and gpatch.op == 'DELETE'
931 current_hunk = hunk(x, hunknum + 1, lr, context, create, remove)
931 current_hunk = hunk(x, hunknum + 1, lr, context, create, remove)
@@ -938,7 +938,7 b' def iterhunks(ui, fp, sourcefile=None):'
938 emitfile = False
938 emitfile = False
939 yield 'file', (afile, bfile, current_hunk)
939 yield 'file', (afile, bfile, current_hunk)
940 elif state == BFILE and x.startswith('GIT binary patch'):
940 elif state == BFILE and x.startswith('GIT binary patch'):
941 current_hunk = binhunk(changed[bfile[2:]][1])
941 current_hunk = binhunk(changed[bfile[2:]])
942 hunknum += 1
942 hunknum += 1
943 if emitfile:
943 if emitfile:
944 emitfile = False
944 emitfile = False
@@ -954,11 +954,11 b' def iterhunks(ui, fp, sourcefile=None):'
954 fp, dopatch, gitpatches = scangitpatch(fp, x)
954 fp, dopatch, gitpatches = scangitpatch(fp, x)
955 yield 'git', gitpatches
955 yield 'git', gitpatches
956 for gp in gitpatches:
956 for gp in gitpatches:
957 changed[gp.path] = (gp.op, gp)
957 changed[gp.path] = gp
958 # else error?
958 # else error?
959 # copy/rename + modify should modify target, not source
959 # copy/rename + modify should modify target, not source
960 gitop = changed.get(bfile[2:], (None, None))[0]
960 gp = changed.get(bfile[2:])
961 if gitop in ('COPY', 'DELETE', 'RENAME'):
961 if gp and gp.op in ('COPY', 'DELETE', 'RENAME'):
962 afile = bfile
962 afile = bfile
963 gitworkdone = True
963 gitworkdone = True
964 newfile = True
964 newfile = True
@@ -1026,7 +1026,7 b' def applydiff(ui, fp, changed, strip=1, '
1026 current_hunk = values
1026 current_hunk = values
1027 ret = current_file.apply(current_hunk, reverse)
1027 ret = current_file.apply(current_hunk, reverse)
1028 if ret >= 0:
1028 if ret >= 0:
1029 changed.setdefault(current_file.fname, (None, None))
1029 changed.setdefault(current_file.fname, None)
1030 if ret > 0:
1030 if ret > 0:
1031 err = 1
1031 err = 1
1032 elif state == 'file':
1032 elif state == 'file':
@@ -1052,7 +1052,7 b' def applydiff(ui, fp, changed, strip=1, '
1052 src, dst = [util.canonpath(cwd, cwd, x)
1052 src, dst = [util.canonpath(cwd, cwd, x)
1053 for x in [gp.oldpath, gp.path]]
1053 for x in [gp.oldpath, gp.path]]
1054 copyfile(src, dst)
1054 copyfile(src, dst)
1055 changed[gp.path] = (gp.op, gp)
1055 changed[gp.path] = gp
1056 else:
1056 else:
1057 raise util.Abort(_('unsupported parser state: %s') % state)
1057 raise util.Abort(_('unsupported parser state: %s') % state)
1058
1058
@@ -1087,13 +1087,15 b' def updatedir(ui, repo, patches):'
1087 if cwd:
1087 if cwd:
1088 cfiles = [util.pathto(repo.root, cwd, f) for f in patches.keys()]
1088 cfiles = [util.pathto(repo.root, cwd, f) for f in patches.keys()]
1089 for f in patches:
1089 for f in patches:
1090 ctype, gp = patches[f]
1090 gp = patches[f]
1091 if ctype == 'RENAME':
1091 if not gp:
1092 continue
1093 if gp.op == 'RENAME':
1092 copies.append((gp.oldpath, gp.path))
1094 copies.append((gp.oldpath, gp.path))
1093 removes[gp.oldpath] = 1
1095 removes[gp.oldpath] = 1
1094 elif ctype == 'COPY':
1096 elif gp.op == 'COPY':
1095 copies.append((gp.oldpath, gp.path))
1097 copies.append((gp.oldpath, gp.path))
1096 elif ctype == 'DELETE':
1098 elif gp.op == 'DELETE':
1097 removes[gp.path] = 1
1099 removes[gp.path] = 1
1098 for src, dst in copies:
1100 for src, dst in copies:
1099 repo.copy(src, dst)
1101 repo.copy(src, dst)
@@ -1101,12 +1103,12 b' def updatedir(ui, repo, patches):'
1101 if removes:
1103 if removes:
1102 repo.remove(util.sort(removes), True)
1104 repo.remove(util.sort(removes), True)
1103 for f in patches:
1105 for f in patches:
1104 ctype, gp = patches[f]
1106 gp = patches[f]
1105 if gp and gp.mode:
1107 if gp and gp.mode:
1106 islink, isexec = gp.mode
1108 islink, isexec = gp.mode
1107 dst = os.path.join(repo.root, gp.path)
1109 dst = os.path.join(repo.root, gp.path)
1108 # patch won't create empty files
1110 # patch won't create empty files
1109 if ctype == 'ADD' and not os.path.exists(dst):
1111 if gp.op == 'ADD' and not os.path.exists(dst):
1110 flags = (isexec and 'x' or '') + (islink and 'l' or '')
1112 flags = (isexec and 'x' or '') + (islink and 'l' or '')
1111 repo.wwrite(gp.path, '', flags)
1113 repo.wwrite(gp.path, '', flags)
1112 else:
1114 else:
General Comments 0
You need to be logged in to leave comments. Login now