From: Yann Dirson <ydirson@altern.org>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [PATCH 3/5] Basic support for keeping a ref to the parent branch.
Date: Sat, 27 Jan 2007 12:21:27 +0100 [thread overview]
Message-ID: <20070127112127.16475.31003.stgit@gandelf.nowhere.earth> (raw)
In-Reply-To: <20070127104024.16475.81445.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 | 27 ++++++++++++++++++++++++++-
2 files changed, 26 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 e801f42..9d4f881 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -410,6 +410,29 @@ class Series(StgitObject):
config.add_section(section)
config.set(section, 'remote', remote)
+ def get_parent_branch(self):
+ section = 'branch "%s"' % self.__name
+ if config.has_option(section, 'merge'):
+ return config.get(section, 'merge')
+ 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):
+ section = 'branch "%s"' % self.__name
+ if not config.has_section(section):
+ config.add_section(section)
+ config.set(section, 'merge', 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()
@@ -458,7 +481,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')
@@ -475,6 +498,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')
next prev parent reply other threads:[~2007-01-27 11:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-27 11:21 [PATCH 0/5] [DRAFT] StGIT, remotes, and parent information Yann Dirson
2007-01-27 11:21 ` [PATCH 1/5] Move identification of parent branch's remote def up into stack class Yann Dirson
2007-01-27 11:21 ` [PATCH 2/5] Allows extraction of information about remotes Yann Dirson
2007-01-27 11:21 ` Yann Dirson [this message]
2007-01-27 11:21 ` [PATCH 4/5] Have 'stg branch --create' record parent information Yann Dirson
2007-01-27 11:21 ` [PATCH 5/5] Make 'stg pull' use git-fetch and not git-pull Yann Dirson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070127112127.16475.31003.stgit@gandelf.nowhere.earth \
--to=ydirson@altern.org \
--cc=catalin.marinas@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).