1186 match = cmdutil.matchfiles(repo, util.unique(c[0] + c[1] + c[2])) |
1186 match = cmdutil.matchfiles(repo, util.unique(c[0] + c[1] + c[2])) |
1187 chunks = patch.diff(repo, patchparent, match=match, |
1187 chunks = patch.diff(repo, patchparent, match=match, |
1188 changes=c, opts=self.diffopts()) |
1188 changes=c, opts=self.diffopts()) |
1189 for chunk in chunks: |
1189 for chunk in chunks: |
1190 patchf.write(chunk) |
1190 patchf.write(chunk) |
1191 patchf.rename() |
1191 |
1192 |
1192 try: |
1193 repo.dirstate.setparents(*cparents) |
1193 copies = {} |
1194 copies = {} |
1194 for dst in a: |
1195 for dst in a: |
1195 src = repo.dirstate.copied(dst) |
1196 src = repo.dirstate.copied(dst) |
1196 if src is not None: |
1197 if src is not None: |
1197 copies.setdefault(src, []).append(dst) |
1198 copies.setdefault(src, []).append(dst) |
1198 repo.dirstate.add(dst) |
1199 repo.dirstate.add(dst) |
1199 # remember the copies between patchparent and tip |
1200 # remember the copies between patchparent and tip |
1200 # this may be slow, so don't do it if we're not tracking copies |
1201 # this may be slow, so don't do it if we're not tracking copies |
1201 if self.diffopts().git: |
1202 if self.diffopts().git: |
1202 for dst in aaa: |
1203 for dst in aaa: |
1203 f = repo.file(dst) |
1204 f = repo.file(dst) |
1204 src = f.renamed(man[dst]) |
1205 src = f.renamed(man[dst]) |
1205 if src: |
1206 if src: |
1206 copies.setdefault(src[0], []).extend(copies.get(dst, [])) |
1207 copies.setdefault(src[0], []).extend(copies.get(dst, [])) |
1207 if dst in a: |
1208 if dst in a: |
1208 copies[src[0]].append(dst) |
1209 copies[src[0]].append(dst) |
1209 # we can't copy a file created by the patch itself |
1210 # we can't copy a file created by the patch itself |
1210 if dst in copies: |
1211 if dst in copies: |
1211 del copies[dst] |
1212 del copies[dst] |
1212 for src, dsts in copies.iteritems(): |
1213 for src, dsts in copies.iteritems(): |
1213 for dst in dsts: |
1214 for dst in dsts: |
1214 repo.dirstate.copy(src, dst) |
1215 repo.dirstate.copy(src, dst) |
1215 for f in r: |
1216 for f in r: |
1216 repo.dirstate.remove(f) |
1217 repo.dirstate.remove(f) |
1217 # if the patch excludes a modified file, mark that |
1218 # if the patch excludes a modified file, mark that |
1218 # file with mtime=0 so status can see it. |
1219 # file with mtime=0 so status can see it. |
1219 mm = [] |
1220 mm = [] |
1220 for i in xrange(len(m)-1, -1, -1): |
1221 for i in xrange(len(m)-1, -1, -1): |
1221 if not matchfn(m[i]): |
1222 if not matchfn(m[i]): |
1222 mm.append(m[i]) |
1223 mm.append(m[i]) |
1223 del m[i] |
1224 del m[i] |
1224 for f in m: |
1225 for f in m: |
1225 repo.dirstate.normal(f) |
1226 repo.dirstate.normal(f) |
1226 for f in mm: |
1227 for f in mm: |
1227 repo.dirstate.normallookup(f) |
1228 repo.dirstate.normallookup(f) |
1228 for f in forget: |
1229 for f in forget: |
1229 repo.dirstate.forget(f) |
1230 repo.dirstate.forget(f) |
1230 |
1231 |
1231 if not msg: |
1232 if not msg: |
1232 if not ph.message: |
1233 if not ph.message: |
1233 message = "[mq]: %s\n" % patchfn |
1234 message = "[mq]: %s\n" % patchfn |
1234 else: |
|
1235 message = "\n".join(ph.message) |
1235 else: |
1236 else: |
1236 message = "\n".join(ph.message) |
1237 message = msg |
1237 else: |
1238 |
1238 message = msg |
1239 user = ph.user or changes[1] |
1239 |
1240 |
1240 user = ph.user or changes[1] |
1241 # assumes strip can roll itself back if interrupted |
1241 |
1242 repo.dirstate.setparents(*cparents) |
1242 self.applied.pop() |
1243 self.applied.pop() |
1243 self.applied_dirty = 1 |
1244 self.applied_dirty = 1 |
1244 self.strip(repo, top, update=False, |
1245 self.strip(repo, top, update=False, |
1245 backup='strip') |
1246 backup='strip') |
1246 n = repo.commit(match.files(), message, user, ph.date, |
1247 except: |
1247 match=match, force=1) |
1248 repo.dirstate.invalidate() |
1248 self.applied.append(statusentry(revlog.hex(n), patchfn)) |
1249 raise |
1249 self.removeundo(repo) |
1250 |
|
1251 try: |
|
1252 # might be nice to attempt to roll back strip after this |
|
1253 patchf.rename() |
|
1254 n = repo.commit(match.files(), message, user, ph.date, |
|
1255 match=match, force=1) |
|
1256 self.applied.append(statusentry(revlog.hex(n), patchfn)) |
|
1257 except: |
|
1258 ctx = repo[cparents[0]] |
|
1259 repo.dirstate.rebuild(ctx.node(), ctx.manifest()) |
|
1260 self.save_dirty() |
|
1261 self.ui.warn(_('refresh interrupted while patch was popped! ' |
|
1262 '(revert --all, qpush to recover)\n')) |
|
1263 raise |
1250 else: |
1264 else: |
1251 self.printdiff(repo, patchparent, fp=patchf) |
1265 self.printdiff(repo, patchparent, fp=patchf) |
1252 patchf.rename() |
1266 patchf.rename() |
1253 added = repo.status()[1] |
1267 added = repo.status()[1] |
1254 for a in added: |
1268 for a in added: |