From 44a01a58ae27599d95932972c5137764478b9020 Mon Sep 17 00:00:00 2001 Message-Id: <44a01a58ae27599d95932972c5137764478b9020.1715267236.git.mdw@distorted.org.uk> From: Mark Wooding Date: Mon, 8 Oct 2007 07:46:27 +0200 Subject: [PATCH] Refactor crt_series creation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Organization: Straylight/Edgeware From: Karl Hasselström Instead of hard-coding in main.py which commands do and don't need a current series, let them speak for themselves. Signed-off-by: Karl Hasselström --- stgit/commands/clone.py | 2 +- stgit/commands/common.py | 2 ++ stgit/main.py | 5 ++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/stgit/commands/clone.py b/stgit/commands/clone.py index a150010..c3b0bbe 100644 --- a/stgit/commands/clone.py +++ b/stgit/commands/clone.py @@ -29,7 +29,7 @@ usage = """%prog [options] Clone a GIT into the local and initialise the patch stack.""" -directory = DirectoryAnywhere() +directory = DirectoryAnywhere(needs_current_series = False) options = [] diff --git a/stgit/commands/common.py b/stgit/commands/common.py index 27ef465..652039f 100644 --- a/stgit/commands/common.py +++ b/stgit/commands/common.py @@ -497,6 +497,8 @@ class DirectoryException(StgException): pass class _Directory(object): + def __init__(self, needs_current_series = True): + self.needs_current_series = needs_current_series @readonly_constant_property def git_dir(self): try: diff --git a/stgit/main.py b/stgit/main.py index 8e00217..db327f1 100644 --- a/stgit/main.py +++ b/stgit/main.py @@ -271,9 +271,8 @@ def main(): directory.setup() config_setup() - # 'clone' doesn't expect an already initialised GIT tree. A Series - # object will be created after the GIT tree is cloned - if cmd != 'clone': + # Some commands don't (always) need an initialized series. + if directory.needs_current_series: if hasattr(options, 'branch') and options.branch: command.crt_series = Series(options.branch) else: -- [mdw]