print 'Branch "%s" has been deleted.' % doomed_name
-def rename_branch(from_name, to_name):
- if from_name == 'master':
- raise CmdException, 'Renaming the master branch is not allowed'
-
- to_patchdir = os.path.join(git.base_dir, 'patches', to_name)
- if os.path.isdir(to_patchdir):
- raise CmdException, '"%s" already exists' % to_patchdir
- to_base = os.path.join(git.base_dir, 'refs', 'bases', to_name)
- if os.path.isfile(to_base):
- raise CmdException, '"%s" already exists' % to_base
-
- git.rename_branch(from_name, to_name)
-
- from_patchdir = os.path.join(git.base_dir, 'patches', from_name)
- if os.path.isdir(from_patchdir):
- os.rename(from_patchdir, to_patchdir)
- from_base = os.path.join(git.base_dir, 'refs', 'bases', from_name)
- if os.path.isfile(from_base):
- os.rename(from_base, to_base)
-
- print 'Renamed branch "%s" as "%s".' % (from_name, to_name)
-
def func(parser, options, args):
if options.create:
if len(args) != 2:
parser.error('incorrect number of arguments')
- rename_branch(args[0], args[1])
+
+ stack.Series(args[0]).rename(args[1])
+
+ print 'Renamed branch "%s" as "%s".' % (args[0], args[1])
+
return
elif options.unprotect:
create_empty_file(self.__descr_file)
self.__begin_stack_check()
+ def rename(self, to_name):
+ """Renames a series
+ """
+ to_stack = Series(to_name)
+ if os.path.isdir(to_stack.__patch_dir):
+ raise StackException, '"%s" already exists' % to_stack.__patch_dir
+ if os.path.isfile(to_stack.__base_file):
+ raise StackException, '"%s" already exists' % to_stack.__base_file
+
+ git.rename_branch(self.__name, to_name)
+
+ if os.path.isdir(self.__patch_dir):
+ os.rename(self.__patch_dir, to_stack.__patch_dir)
+ if os.path.isfile(self.__base_file):
+ os.rename(self.__base_file, to_stack.__base_file)
+
+ self.__init__(to_name)
+
def delete(self, force = False):
"""Deletes an stgit series
"""