Fix removal of series with non-existant trash dir.
authorYann Dirson <ydirson@altern.org>
Wed, 6 Jun 2007 21:05:17 +0000 (23:05 +0200)
committerCatalin Marinas <catalin.marinas@gmail.com>
Thu, 7 Jun 2007 21:44:18 +0000 (22:44 +0100)
Otherwise it is not possible to delete a stack that never had a patch
deleted (eg. a newborn stack).

Signed-off-by: Yann Dirson <ydirson@altern.org>
stgit/stack.py

index ed54671..a6d16f2 100644 (file)
@@ -680,10 +680,11 @@ class Series(StgitObject):
             for p in patches:
                 Patch(p, self.__patch_dir, self.__refs_dir).delete()
 
-            # remove the trash directory
-            for fname in os.listdir(self.__trash_dir):
-                os.remove(os.path.join(self.__trash_dir, fname))
-            os.rmdir(self.__trash_dir)
+            # remove the trash directory if any
+            if os.path.exists(self.__trash_dir):
+                for fname in os.listdir(self.__trash_dir):
+                    os.remove(os.path.join(self.__trash_dir, fname))
+                os.rmdir(self.__trash_dir)
 
             # FIXME: find a way to get rid of those manual removals
             # (move functionality to StgitObject ?)