+ remove_file_and_dirs(os.path.join(basedir.get(), 'refs', 'heads'),
+ name)
+
+def rename_branch(from_name, to_name):
+ """Rename a git branch
+ """
+ if not branch_exists(from_name):
+ raise GitException, 'Branch "%s" does not exist' % from_name
+ if branch_exists(to_name):
+ raise GitException, 'Branch "%s" already exists' % to_name
+
+ if get_head_file() == from_name:
+ set_head_file(to_name)
+ rename(os.path.join(basedir.get(), 'refs', 'heads'),
+ from_name, to_name)