- if name:
- self.__name = name
- else:
- self.__name = git.get_head_file()
-
- if self.__name:
- base_dir = git.get_base_dir()
- self.__patch_dir = os.path.join(base_dir, 'patches',
- self.__name)
- self.__base_file = os.path.join(base_dir, 'refs', 'bases',
- self.__name)
- self.__applied_file = os.path.join(self.__patch_dir, 'applied')
- self.__unapplied_file = os.path.join(self.__patch_dir, 'unapplied')
- self.__current_file = os.path.join(self.__patch_dir, 'current')
- self.__descr_file = os.path.join(self.__patch_dir, 'description')
+ try:
+ if name:
+ self.__name = name
+ else:
+ self.__name = git.get_head_file()
+ self.__base_dir = basedir.get()
+ except git.GitException, ex:
+ raise StackException, 'GIT tree not initialised: %s' % ex
+
+ self.__series_dir = os.path.join(self.__base_dir, 'patches',
+ self.__name)
+ self.__refs_dir = os.path.join(self.__base_dir, 'refs', 'patches',
+ self.__name)
+ self.__base_file = os.path.join(self.__base_dir, 'refs', 'bases',
+ self.__name)
+
+ self.__applied_file = os.path.join(self.__series_dir, 'applied')
+ self.__unapplied_file = os.path.join(self.__series_dir, 'unapplied')
+ self.__current_file = os.path.join(self.__series_dir, 'current')
+ self.__descr_file = os.path.join(self.__series_dir, 'description')
+
+ # where this series keeps its patches
+ self.__patch_dir = os.path.join(self.__series_dir, 'patches')
+ if not os.path.isdir(self.__patch_dir):
+ self.__patch_dir = self.__series_dir
+
+ # if no __refs_dir, create and populate it (upgrade old repositories)
+ if self.is_initialised() and not os.path.isdir(self.__refs_dir):
+ os.makedirs(self.__refs_dir)
+ for patch in self.get_applied() + self.get_unapplied():
+ self.get_patch(patch).update_top_ref()
+
+ # trash directory
+ self.__trash_dir = os.path.join(self.__series_dir, 'trash')
+ if self.is_initialised() and not os.path.isdir(self.__trash_dir):
+ os.makedirs(self.__trash_dir)