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

[PATCH 4/6] Basic support for keeping a ref to the parent branch.

From
Yann Dirson <ydirson@altern.org>
Date
Jan 27, 2007, 17:22 UTC
Message-ID
<20070127172248.27183.82154.stgit@gandelf.nowhere.earth>
In-Reply-To
<20070127172129.27183.50432.stgit@gandelf.nowhere.earth>

This adds a framework to handle the parent branch of a stack, in addition to the parent remote, and to set them when creating a stack.

Signed-off-by: Yann Dirson <ydirson@altern.org>
---
 TODO           |    2 --
 stgit/stack.py |   24 +++++++++++++++++++++++-
 2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/TODO b/TODO
index 549bc9d..884b831 100644
--- a/TODO
+++ b/TODO
@@ -20,8 +20,6 @@ The future, when time allows or if someone else does them:
 - multiple heads in a patch - useful for forking a patch,
   synchronising with other patches (diff format or in other
   repositories)
-- "pull" argument should default to a sane value, "origin" is wrong in
-  many cases
 - commit directly to a patch which is not top
 - patch synchronisation between between branches (as some people,
   including me have the same patches based on different branches and
diff --git a/stgit/stack.py b/stgit/stack.py
index 026fc36..603c539 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -408,6 +408,26 @@ class Series(StgitObject):
     def __set_parent_remote(self, remote):
         value = config.set('branch.%s.remote' % self.__name, remote)
 
+    def get_parent_branch(self):
+        value = config.get('branch.%s.merge' % self.__name)
+        if value:
+            return value
+        elif rev_parse('heads/origin'):
+            return 'heads/origin'
+        else:
+            raise StackException, 'Cannot find a parent branch for "%s"' % self.__name
+
+    def __set_parent_branch(self, name):
+        config.set('branch.%s.merge' % self.__name, name)
+
+    def set_parent(self, remote, localbranch):
+        if localbranch:
+            self.__set_parent_branch(localbranch)
+            if remote:
+                self.__set_parent_remote(remote)
+        elif remote:
+            raise StackException, 'Remote "%s" without a branch cannot be used as parent' % remote
+
     def __patch_is_current(self, patch):
         return patch.get_name() == self.get_current()
 
@@ -456,7 +476,7 @@ class Series(StgitObject):
         """
         return os.path.isdir(self.__patch_dir)
 
-    def init(self, create_at=False):
+    def init(self, create_at=False, parent_remote=None, parent_branch=None):
         """Initialises the stgit series
         """
         bases_dir = os.path.join(self.__base_dir, 'refs', 'bases')
@@ -473,6 +493,8 @@ class Series(StgitObject):
 
         os.makedirs(self.__patch_dir)
 
+        self.set_parent(parent_remote, parent_branch)
+        
         create_dirs(bases_dir)
 
         self.create_empty_field('applied')
Previous: Yann DirsonNext: Yann Dirson
Message 5 of 7 in “[DRAFT 2] StGIT, remotes, and parent information”
  1. 0/7 [DRAFT 2] StGIT, remotes, and parent informationYann Dirson, Jan 27, 2007
  2. 1/6 Make stgit.config use git-repo-config.Yann Dirson, Jan 27, 2007
  3. 2/6 Move identification of parent branch's remote def up into stack class.Yann Dirson, Jan 27, 2007
  4. 3/6 Allows extraction of information about remotes.Yann Dirson, Jan 27, 2007
  5. 4/6 Basic support for keeping a ref to the parent branch.Yann Dirson, Jan 27, 2007
  6. 5/6 Have 'stg branch --create' record parent information.Yann Dirson, Jan 27, 2007
  7. 6/6 Make 'stg pull' use git-fetch and not git-pull.Yann Dirson, Jan 27, 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.