changeset 5527:0b3f910dfd17

mq: really remove undo after a qpush (and after a strip) For qpush, removeundo has to be called after the transaction has finished. strip may use unbundle, which also leaves an undo file. Fixes issue780.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Fri, 09 Nov 2007 20:21:35 -0200
parents d5b9c74c910e
children 6ffca2bf23da 61c230f81068
files hgext/mq.py tests/test-mq tests/test-mq-merge
diffstat 3 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Fri Nov 09 20:21:35 2007 -0200
+++ b/hgext/mq.py	Fri Nov 09 20:21:35 2007 -0200
@@ -456,6 +456,7 @@
                 raise
         finally:
             del tr, lock, wlock
+            self.removeundo(repo)
 
     def _apply(self, repo, series, list=False, update_status=True,
                strict=False, patchdir=None, merge=None, all_files={}):
@@ -527,7 +528,6 @@
                 self.ui.warn("fuzz found when applying patch, stopping\n")
                 err = 1
                 break
-        self.removeundo(repo)
         return (err, n)
 
     def delete(self, repo, patches, opts):
@@ -654,6 +654,9 @@
 
             self.removeundo(repo)
             repair.strip(self.ui, repo, rev, backup)
+            # strip may have unbundled a set of backed up revisions after
+            # the actual strip
+            self.removeundo(repo)
         finally:
             del lock, wlock
 
--- a/tests/test-mq	Fri Nov 09 20:21:35 2007 -0200
+++ b/tests/test-mq	Fri Nov 09 20:21:35 2007 -0200
@@ -1,5 +1,12 @@
 #!/bin/sh
 
+checkundo()
+{
+    if [ -f .hg/store/undo ]; then
+	echo ".hg/store/undo still exists after $1"
+    fi
+}
+
 echo "[extensions]" >> $HGRCPATH
 echo "mq=" >> $HGRCPATH
 
@@ -57,6 +64,7 @@
 hg init e
 cd e
 hg qnew A
+checkundo qnew
 echo foo > foo
 hg add foo
 hg qrefresh
@@ -100,14 +108,17 @@
 hg diff --nodates -q
 # restore things
 hg qrefresh
+checkundo qrefresh
 
 echo % qpop
 
 hg qpop
+checkundo qpop
 
 echo % qpush
 
 hg qpush
+checkundo qpush
 
 cd ..
 
@@ -394,6 +405,7 @@
 hg ci -m merge -d '0 0'
 hg log
 hg strip 1 2>&1 | sed 's/\(saving bundle to \).*/\1/'
+checkundo strip
 hg log
 cd ..
 
--- a/tests/test-mq-merge	Fri Nov 09 20:21:35 2007 -0200
+++ b/tests/test-mq-merge	Fri Nov 09 20:21:35 2007 -0200
@@ -7,6 +7,13 @@
     sed -e 's:\\:/:g' -e 's:[^ ]*/t/::g'
 }
 
+checkundo()
+{
+    if [ -f .hg/store/undo ]; then
+	echo ".hg/store/undo still exists after $1"
+    fi
+}
+
 echo "[extensions]" >> $HGRCPATH
 echo "hgext.mq=" >> $HGRCPATH
 
@@ -25,6 +32,7 @@
 
 # Save the patch queue so we can merge it later
 hg qsave -c -e 2>&1 | rewrite_path
+checkundo qsave
 
 # Update b and commit in an "update" changeset
 hg up -C init
@@ -36,6 +44,7 @@
 # The system cannot find the file specified => a
 hg manifest
 hg qpush -a -m 2>&1 | rewrite_path
+checkundo 'qpush -m'
 hg manifest
 
 # ensure status is correct after merge