##// 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 return (True, files, fuzz)
421 return (True, files, fuzz)
422
422
423 def apply(self, repo, series, list=False, update_status=True,
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 # TODO unify with commands.py
445 # TODO unify with commands.py
426 if not patchdir:
446 if not patchdir:
427 patchdir = self.path
447 patchdir = self.path
@@ -429,7 +449,6 b' class queue:'
429 if not wlock:
449 if not wlock:
430 wlock = repo.wlock()
450 wlock = repo.wlock()
431 lock = repo.lock()
451 lock = repo.lock()
432 tr = repo.transaction()
433 n = None
452 n = None
434 for patchname in series:
453 for patchname in series:
435 pushable, reason = self.pushable(patchname)
454 pushable, reason = self.pushable(patchname)
@@ -454,6 +473,7 b' class queue:'
454 message = '\n'.join(message)
473 message = '\n'.join(message)
455
474
456 (patcherr, files, fuzz) = self.patch(repo, pf)
475 (patcherr, files, fuzz) = self.patch(repo, pf)
476 all_files.update(files)
457 patcherr = not patcherr
477 patcherr = not patcherr
458
478
459 if merge and files:
479 if merge and files:
@@ -492,7 +512,6 b' class queue:'
492 self.ui.warn("fuzz found when applying patch, stopping\n")
512 self.ui.warn("fuzz found when applying patch, stopping\n")
493 err = 1
513 err = 1
494 break
514 break
495 tr.close()
496 return (err, n)
515 return (err, n)
497
516
498 def delete(self, repo, patches, opts):
517 def delete(self, repo, patches, opts):
@@ -827,10 +846,25 b' class queue:'
827 else:
846 else:
828 end = self.series.index(patch, start) + 1
847 end = self.series.index(patch, start) + 1
829 s = self.series[start:end]
848 s = self.series[start:end]
830 if mergeq:
849 all_files = {}
831 ret = self.mergepatch(repo, mergeq, s, wlock)
850 try:
832 else:
851 if mergeq:
833 ret = self.apply(repo, s, list, wlock=wlock)
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 top = self.applied[-1].name
868 top = self.applied[-1].name
835 if ret[0]:
869 if ret[0]:
836 self.ui.write("Errors during apply, please fix and refresh %s\n" %
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 ui.warn("merging with queue at: %s\n" % mergeq.path)
1825 ui.warn("merging with queue at: %s\n" % mergeq.path)
1792 ret = q.push(repo, patch, force=opts['force'], list=opts['list'],
1826 ret = q.push(repo, patch, force=opts['force'], list=opts['list'],
1793 mergeq=mergeq)
1827 mergeq=mergeq)
1794 q.save_dirty()
1795 return ret
1828 return ret
1796
1829
1797 def pop(ui, repo, patch=None, **opts):
1830 def pop(ui, repo, patch=None, **opts):
General Comments 0
You need to be logged in to leave comments. Login now