##// END OF EJS Templates
MQ: tidy up if a qpush is interrupted....
Bryan O'Sullivan -
r4418:0532491f default
parent child Browse files
Show More
@@ -421,7 +421,27 b' class queue:'
421 421 return (True, files, fuzz)
422 422
423 423 def apply(self, repo, series, list=False, update_status=True,
424 strict=False, patchdir=None, merge=None, wlock=None):
424 strict=False, patchdir=None, merge=None, wlock=None,
425 all_files={}):
426 tr = repo.transaction()
427 try:
428 ret = self._apply(tr, repo, series, list, update_status,
429 strict, patchdir, merge, wlock,
430 all_files=all_files)
431 tr.close()
432 self.save_dirty()
433 return ret
434 except:
435 try:
436 tr.abort()
437 finally:
438 repo.reload()
439 repo.wreload()
440 raise
441
442 def _apply(self, tr, repo, series, list=False, update_status=True,
443 strict=False, patchdir=None, merge=None, wlock=None,
444 all_files={}):
425 445 # TODO unify with commands.py
426 446 if not patchdir:
427 447 patchdir = self.path
@@ -429,7 +449,6 b' class queue:'
429 449 if not wlock:
430 450 wlock = repo.wlock()
431 451 lock = repo.lock()
432 tr = repo.transaction()
433 452 n = None
434 453 for patchname in series:
435 454 pushable, reason = self.pushable(patchname)
@@ -454,6 +473,7 b' class queue:'
454 473 message = '\n'.join(message)
455 474
456 475 (patcherr, files, fuzz) = self.patch(repo, pf)
476 all_files.update(files)
457 477 patcherr = not patcherr
458 478
459 479 if merge and files:
@@ -492,7 +512,6 b' class queue:'
492 512 self.ui.warn("fuzz found when applying patch, stopping\n")
493 513 err = 1
494 514 break
495 tr.close()
496 515 return (err, n)
497 516
498 517 def delete(self, repo, patches, opts):
@@ -827,10 +846,25 b' class queue:'
827 846 else:
828 847 end = self.series.index(patch, start) + 1
829 848 s = self.series[start:end]
830 if mergeq:
831 ret = self.mergepatch(repo, mergeq, s, wlock)
832 else:
833 ret = self.apply(repo, s, list, wlock=wlock)
849 all_files = {}
850 try:
851 if mergeq:
852 ret = self.mergepatch(repo, mergeq, s, wlock)
853 else:
854 ret = self.apply(repo, s, list, wlock=wlock,
855 all_files=all_files)
856 except:
857 self.ui.warn(_('cleaning up working directory...'))
858 node = repo.dirstate.parents()[0]
859 hg.revert(repo, node, None, wlock)
860 unknown = repo.status(wlock=wlock)[4]
861 # only remove unknown files that we know we touched or
862 # created while patching
863 for f in unknown:
864 if f in all_files:
865 util.unlink(repo.wjoin(f))
866 self.ui.warn(_('done\n'))
867 raise
834 868 top = self.applied[-1].name
835 869 if ret[0]:
836 870 self.ui.write("Errors during apply, please fix and refresh %s\n" %
@@ -1791,7 +1825,6 b' def push(ui, repo, patch=None, **opts):'
1791 1825 ui.warn("merging with queue at: %s\n" % mergeq.path)
1792 1826 ret = q.push(repo, patch, force=opts['force'], list=opts['list'],
1793 1827 mergeq=mergeq)
1794 q.save_dirty()
1795 1828 return ret
1796 1829
1797 1830 def pop(ui, repo, patch=None, **opts):
General Comments 0
You need to be logged in to leave comments. Login now