add set_branch() to switch branches
authorGuido Günther <agx@sigxcpu.org>
Fri, 31 Oct 2008 08:51:12 +0000 (09:51 +0100)
committerGuido Guenther <agx@sigxcpu.org>
Fri, 31 Oct 2008 08:51:12 +0000 (09:51 +0100)
gbp/git_utils.py

index 204e2626b7327a7168c1629c64852bc574ca77f3..90926f00749d99e3254f7c96621fd12cffd43d88 100644 (file)
@@ -5,7 +5,7 @@
 
 import subprocess
 import os.path
-from command_wrappers import (GitAdd, GitRm, copy_from)
+from command_wrappers import (GitAdd, GitRm, GitCheckoutBranch, copy_from)
 import dateutil.parser
 import calendar
 
@@ -66,6 +66,12 @@ class GitRepository(object):
             if line.startswith('*'):
                 return line.split(' ', 1)[1].strip()
 
+    def set_branch(self, branch):
+        """switch to branch 'branch'"""
+        self.__check_path()
+        if self.get_branch() != branch:
+            GitCheckoutBranch(branch)()
+
     def is_clean(self):
         """does the repository contain any uncommitted modifications"""
         self.__check_path()