workdir: override cmd_branch
authorSteven Walter <swalter@lpdev.prtdev.lexmark.com>
Fri, 20 Feb 2009 15:28:56 +0000 (20 10:28 -0500)
committerSteven Walter <swalter@lpdev.prtdev.lexmark.com>
Fri, 20 Feb 2009 15:28:56 +0000 (20 10:28 -0500)
Prevent deleting a branch that is checked-out in another working copy

plugins/workdir.py

index 9b4b3d6..51acd1b 100644 (file)
@@ -110,6 +110,19 @@ class WorkdirPlugin(YapCore):
 
         print "Workdir created at %s for branch %s" % (workdir, branch)
 
+    def cmd_branch(self, *args, **flags):
+       if '-d' in flags:
+           branch = flags['-d']
+           repodir = self._get_repodir()
+           self._lock_branch(branch, repodir)
+       else:
+           branch = None
+
+       super(WorkdirPlugin, self).cmd_branch(*args, **flags)
+
+       if branch:
+           self._unlock_branch(branch)
+
     def cmd_switch(self, branch, *args, **flags):
         self._check_git()