changeset 4207:b7e66db28571

Remove undo log after mq operations that rollback would break
author Brendan Cully <brendan@kublai.com>
date Tue, 13 Mar 2007 21:50:42 -0700
parents 65aabd9f16f0
children bd9b84b9a84b
files hgext/mq.py
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Tue Mar 13 16:27:34 2007 -0700
+++ b/hgext/mq.py	Tue Mar 13 21:50:42 2007 -0700
@@ -306,6 +306,15 @@
             message.insert(0, subject)
         return (message, comments, user, date, diffstart > 1)
 
+    def removeundo(self, repo):
+        undo = repo.sjoin('undo')
+        if not os.path.exists(undo):
+            return
+        try:
+            os.unlink(undo)
+        except OSError, inst:
+            self.ui.warn('error removing undo: %s\n' % str(inst))
+
     def printdiff(self, repo, node1, node2=None, files=None,
                   fp=None, changes=None, opts={}):
         fns, matchfn, anypats = cmdutil.matchpats(repo, files, opts)
@@ -349,6 +358,7 @@
             patchf.write(comments)
         self.printdiff(repo, head, n, fp=patchf)
         patchf.close()
+        self.removeundo(repo)
         return (0, n)
 
     def qparents(self, repo, rev=None):
@@ -381,6 +391,7 @@
             pname = ".hg.patches.merge.marker"
             n = repo.commit(None, '[mq]: merge marker', user=None, force=1,
                             wlock=wlock)
+            self.removeundo(repo)
             self.applied.append(statusentry(revlog.hex(n), pname))
             self.applied_dirty = 1
 
@@ -488,6 +499,7 @@
                 err = 1
                 break
         tr.close()
+        self.removeundo(repo)
         return (err, n)
 
     def delete(self, repo, patches, opts):
@@ -586,6 +598,7 @@
         if r: r.add([patch])
         if commitfiles:
             self.refresh(repo, short=True)
+        self.removeundo(repo)
 
     def strip(self, repo, rev, update=True, backup="all", wlock=None):
         def limitheads(chlog, stop):
@@ -709,6 +722,7 @@
         change = chlog.read(rev)
         chlog.strip(revnum, revnum)
         repo.manifest.strip(repo.manifest.rev(change[0]), revnum)
+        self.removeundo(repo)
         if saveheads:
             self.ui.status("adding branch\n")
             commands.unbundle(self.ui, repo, "file:%s" % chgrpfile,
@@ -1086,6 +1100,7 @@
                             force=1, wlock=wlock)
             self.applied[-1] = statusentry(revlog.hex(n), patchfn)
             self.applied_dirty = 1
+            self.removeundo(repo)
         else:
             self.printdiff(repo, patchparent, fp=patchf)
             patchf.close()
@@ -1268,6 +1283,7 @@
             return 1
         self.applied.append(statusentry(revlog.hex(n),'.hg.patches.save.line'))
         self.applied_dirty = 1
+        self.removeundo(undo)
 
     def full_series_end(self):
         if len(self.applied) > 0: