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

[StGit PATCH 13/13] Remove the 'top' field

From
David Kågedal <davidk@lysator.liu.se>
Date
Sep 14, 2007, 22:32 UTC
Message-ID
<20070914223215.7001.80066.stgit@morpheus.local>
In-Reply-To
<20070914222819.7001.55921.stgit@morpheus.local>
The top is instead implicitly defined by the patch ref.
Signed-off-by: David Kågedal <davidk@lysator.liu.se>
---
 stgit/stack.py |   26 +++++++++-----------------
 1 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/stgit/stack.py b/stgit/stack.py
index 00b91c6..94d3eee 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -158,7 +158,6 @@ class Patch(StgitObject):
 
     def create(self):
         os.mkdir(self._dir())
-        self.create_empty_field('top')
 
     def delete(self):
         for f in os.listdir(self._dir()):
@@ -190,11 +189,6 @@ class Patch(StgitObject):
     def __update_log_ref(self, ref):
         git.set_ref(self.__log_ref, ref)
 
-    def update_top_ref(self):
-        top = self.get_top()
-        if top:
-            self.__update_top_ref(top)
-
     def get_old_bottom(self):
         return git.get_commit(self.get_old_top()).get_parent()
 
@@ -205,26 +199,18 @@ class Patch(StgitObject):
         return self._get_field('top.old')
 
     def get_top(self):
-        top = self._get_field('top')
-        try:
-            ref = git.rev_parse(self.__top_ref)
-        except:
-            ref = None
-        assert not ref or top == ref
-        return top
+        return git.rev_parse(self.__top_ref)
 
     def set_top(self, value, backup = False):
         if backup:
-            curr = self._get_field('top')
+            curr = self.get_top()
             self._set_field('top.old', curr)
-        self._set_field('top', value)
         self.__update_top_ref(value)
 
     def restore_old_boundaries(self):
         top = self._get_field('top.old')
 
         if top:
-            self._set_field('top', top)
             self.__update_top_ref(top)
             return True
         else:
@@ -436,7 +422,13 @@ class Series(PatchSet):
                 patch = patch.strip()
                 os.rename(os.path.join(branch_dir, patch),
                           os.path.join(patch_dir, patch))
-                Patch(patch, patch_dir, refs_base).update_top_ref()
+                topfield = os.path.join(patch_dir, patch, 'top')
+                if os.path.isfile(topfield):
+                    top = read_string(topfield, False)
+                else:
+                    top = None
+                if top:
+                    git.set_ref(refs_base + '/' + patch, top)
             set_format_version(1)
 
         # Update 1 -> 2.
Previous: David KågedalNext: Karl Hasselström
Message 22 of 30 in “Eliminate 'top' and 'bottom' files”
  1. 00/13 Eliminate 'top' and 'bottom' filesDavid Kågedal, Sep 14, 2007
  2. 01/13 Add some more tests of "stg status" outputDavid Kågedal, Sep 14, 2007
  3. 02/13 Clear up semantics of tree_statusDavid Kågedal, Sep 14, 2007
  4. 03/13 Moved that status function to the status command fileDavid Kågedal, Sep 14, 2007
  5. David KågedalSep 14, 2007
  6. 04/13 Split Series.push_patch in twoDavid Kågedal, Sep 14, 2007
  7. 05/13 Remove dead code from push_empty_patchDavid Kågedal, Sep 14, 2007
  8. 06/13 Refactor Series.push_patchDavid Kågedal, Sep 14, 2007
  9. 07/13 Clean up Series.refresh_patchDavid Kågedal, Sep 14, 2007
  10. 08/13 Add a 'bottom' parameter to Series.refresh_patch and use itDavid Kågedal, Sep 14, 2007
  11. 09/13 Clear up the semantics of Series.new_patchDavid Kågedal, Sep 14, 2007
  12. Catalin MarinasOct 8, 2007
  13. Karl HasselströmOct 8, 2007
  14. Catalin MarinasOct 9, 2007
  15. David KågedalOct 10, 2007
  16. Catalin MarinasOct 11, 2007
  17. Karl HasselströmOct 10, 2007
  18. Karl HasselströmOct 10, 2007
  19. 10/13 Refactor Series.new_patchDavid Kågedal, Sep 14, 2007
  20. 11/13 Check bottom and invariantsDavid Kågedal, Sep 14, 2007
  21. 12/13 Remove the 'bottom' fieldDavid Kågedal, Sep 14, 2007
  22. 13/13 Remove the 'top' fieldDavid Kågedal, Sep 14, 2007
  23. Karl HasselströmSep 15, 2007
  24. David KågedalSep 16, 2007
  25. Karl HasselströmSep 17, 2007
  26. Karl HasselströmSep 15, 2007
  27. Catalin MarinasSep 16, 2007
  28. David KågedalSep 16, 2007
  29. Karl HasselströmSep 17, 2007
  30. David KågedalSep 16, 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.