git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[StGIT PATCH 2/4] Abstract a PatchSet object out of Series.

From
Yann Dirson <ydirson@altern.org>
Date
Jun 11, 2007, 00:33 UTC
Message-ID
<20070611003330.4736.69293.stgit@gandelf.nowhere.earth>
In-Reply-To
<20070611003117.4736.33551.stgit@gandelf.nowhere.earth>

The goal is to move into PatchSet all functionnality that is not dependant of Series being a real stack, paving the way for handling parallel (hydra) stacks, or any other way to organize patches. ---

 stgit/stack.py |  110 +++++++++++++++++++++++++++++---------------------------
 1 files changed, 56 insertions(+), 54 deletions(-)
diff --git a/stgit/stack.py b/stgit/stack.py
index 0d475da..35840e2 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -348,7 +348,62 @@ def update_to_current_format_version(branch, git_dir):
         raise StackException('Branch %s is at format version %d, expected %d'
                              % (branch, get_format_version(), FORMAT_VERSION))
 
-class Series(StgitObject):
+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):
     """Class including the operations on series
     """
     def __init__(self, name = None):
@@ -388,11 +443,6 @@ class Series(StgitObject):
         if not name or re.search('[^\w.-]', name):
             raise StackException, 'Invalid patch name: "%s"' % name
 
-    def get_name(self):
-        return self.__name
-    def set_name(self, name):
-        self.__name = name
-        
     def get_patch(self, name):
         """Return a Patch object for the given name
         """
@@ -444,40 +494,6 @@ class Series(StgitObject):
         # No bottommost patch, so just return HEAD
         return git.get_head()
 
-    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 get_parent_remote(self):
         value = config.get('branch.%s.remote' % self.get_name())
         if value:
@@ -547,20 +563,6 @@ class Series(StgitObject):
         return self.patch_applied(name) or self.patch_unapplied(name) \
                or self.patch_hidden(name)
 
-    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())))
-
     def init(self, create_at=False, parent_remote=None, parent_branch=None):
         """Initialises the stgit series
         """
Previous: Yann DirsonNext: Catalin Marinas
Message 3 of 14 in “Cleanups of the Series object.”
  1. 0/4 Cleanups of the Series object.Yann Dirson, Jun 11, 2007
  2. 1/4 Use get/set_name for a stack's name.Yann Dirson, Jun 11, 2007
  3. 2/4 Abstract a PatchSet object out of Series.Yann Dirson, Jun 11, 2007
  4. Catalin MarinasJun 12, 2007
  5. Yann DirsonJun 13, 2007
  6. Yann DirsonJun 14, 2007
  7. Catalin MarinasJun 19, 2007
  8. Catalin MarinasJun 19, 2007
  9. Yann DirsonJun 19, 2007
  10. Catalin MarinasJun 14, 2007
  11. Yann DirsonJun 15, 2007
  12. Catalin MarinasJun 19, 2007
  13. 3/4 Move stack format-version checks into Stack class.Yann Dirson, Jun 11, 2007
  14. 4/4 Rename branch.*.stgitformatversion to branch.*.stgit.stackformatversion.Yann Dirson, Jun 11, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.