+class PatchSet(StgitObject):
+ def get_name(self):
+ return self.__name
+ def set_name(self, name):
+ self.__name = name
+
+ def get_head(self):
+ """Return the head of the branch
+ """
+ crt = self.get_current_patch()
+ if crt:
+ return crt.get_top()
+ else:
+ return self.get_base()
+
+ def get_protected(self):
+ return os.path.isfile(os.path.join(self._dir(), 'protected'))
+
+ def protect(self):
+ protect_file = os.path.join(self._dir(), 'protected')
+ if not os.path.isfile(protect_file):
+ create_empty_file(protect_file)
+
+ def unprotect(self):
+ protect_file = os.path.join(self._dir(), 'protected')
+ if os.path.isfile(protect_file):
+ os.remove(protect_file)
+
+ def __branch_descr(self):
+ return 'branch.%s.description' % self.get_name()
+
+ def get_description(self):
+ return config.get(self.__branch_descr()) or ''
+
+ def set_description(self, line):
+ if line:
+ config.set(self.__branch_descr(), line)
+ else:
+ config.unset(self.__branch_descr())
+
+ def head_top_equal(self):
+ """Return true if the head and the top are the same
+ """
+ crt = self.get_current_patch()
+ if not crt:
+ # we don't care, no patches applied
+ return True
+ return git.get_head() == crt.get_top()
+
+ def is_initialised(self):
+ """Checks if series is already initialised
+ """
+ return bool(config.get(format_version_key(self.get_name())))
+
+
+class Series(PatchSet):