workdir: cleanup after ourselves if branch -d fails
authorSteven Walter <swalter@lpdev.prtdev.lexmark.com>
Wed, 11 Mar 2009 14:05:09 +0000 (11 10:05 -0400)
committerSteven Walter <swalter@lpdev.prtdev.lexmark.com>
Wed, 11 Mar 2009 14:05:09 +0000 (11 10:05 -0400)
This may happen in the case of a leaf branch

plugins/workdir.py

index 51acd1b..a2b51ab 100644 (file)
@@ -118,10 +118,11 @@ class WorkdirPlugin(YapCore):
        else:
            branch = None
 
-       super(WorkdirPlugin, self).cmd_branch(*args, **flags)
-
-       if branch:
-           self._unlock_branch(branch)
+       try:
+           super(WorkdirPlugin, self).cmd_branch(*args, **flags)
+       finally:
+           if branch:
+               self._unlock_branch(branch)
 
     def cmd_switch(self, branch, *args, **flags):
         self._check_git()