repair: remove undo files after strip
authorIdan Kamara <idankk86@gmail.com>
Tue, 06 Mar 2012 18:43:05 +0200
changeset 16237 b5c0c7d0f83f
parent 16236 97efd26eb957
child 16238 e8eecfe37d4e
repair: remove undo files after strip
mercurial/repair.py
--- a/mercurial/repair.py	Tue Mar 06 18:42:52 2012 +0200
+++ b/mercurial/repair.py	Tue Mar 06 18:43:05 2012 +0200
@@ -56,7 +56,7 @@
 
 def strip(ui, repo, node, backup="all"):
     cl = repo.changelog
-    # TODO delete the undo files, and handle undo of merge sets
+    # TODO handle undo of merge sets
     striprev = cl.rev(node)
 
     keeppartialbundle = backup == 'strip'
@@ -142,6 +142,14 @@
             if not keeppartialbundle:
                 os.unlink(chgrpfile)
 
+        # remove undo files
+        for undofile in repo.undofiles():
+            try:
+                os.unlink(undofile)
+            except OSError, e:
+                if e.errno != errno.ENOENT:
+                    ui.warn(_('error removing %s: %s\n') % (undofile, str(e)))
+
         for m in updatebm:
             bm[m] = repo['.'].node()
         bookmarks.write(repo)