Previous patch adds support for a separate patch directory in each branch. Let's give users an option to convert their old branches to new style ones and back. Signed-off-by: Chuck Lever <cel@netapp.com> --- stgit/commands/branch.py | 11 +++++++++++ stgit/stack.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 0 deletions(-) diff --git a/stgit/commands/branch.py b/stgit/commands/branch.py index 6a551e4..ef44349 100644 --- a/stgit/commands/branch.py +++ b/stgit/commands/branch.py @@ -45,6 +45,9 @@ options = [make_option('-c', '--create', make_option('--clone', help = 'clone the contents of the current branch', action = 'store_true'), + make_option('--convert', + help = 'switch between old and new format branches', + action = 'store_true'), make_option('--delete', help = 'delete an existing development branch', action = 'store_true'), @@ -150,6 +153,14 @@ def func(parser, options, args): return + elif options.convert: + + if len(args) != 0: + parser.error('incorrect number of arguments') + + crt_series.convert() + return + elif options.delete: if len(args) != 1: diff --git a/stgit/stack.py b/stgit/stack.py index 89a2413..145f93c 100644 --- a/stgit/stack.py +++ b/stgit/stack.py @@ -410,6 +410,42 @@ class Series: os.makedirs(os.path.join(self.__series_dir, 'patches')) self.__begin_stack_check() + def convert(self): + """Either convert to use a separate patch directory, or + unconvert to place the patches in the same directory with + series control files + """ + if self.__patch_dir == self.__series_dir: + print 'Converting old-style to new-style... ', + sys.stdout.flush() + + self.__patch_dir = os.path.join(self.__series_dir, 'patches') + os.makedirs(self.__patch_dir) + + for p in self.get_applied() + self.get_unapplied(): + src = os.path.join(self.__series_dir, p) + dest = os.path.join(self.__patch_dir, p) + os.rename(src, dest) + + print 'done' + + else: + print 'Converting new-style to old-style... ', + sys.stdout.flush() + + for p in self.get_applied() + self.get_unapplied(): + src = os.path.join(self.__patch_dir, p) + dest = os.path.join(self.__series_dir, p) + os.rename(src, dest) + + if not os.listdir(self.__patch_dir): + os.rmdir(self.__patch_dir) + print 'done' + else: + print 'Patch directory %s is not empty.' % self.__name + + self.__patch_dir = self.__series_dir + def rename(self, to_name): """Renames a series """ - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.htmlReceived on Mon Jan 30 05:14:12 2006
This archive was generated by hypermail 2.1.8 : 2006-01-30 05:17:51 EST