chiark / gitweb /
Refactor crt_series creation
authorKarl Hasselström <kha@treskal.com>
Mon, 8 Oct 2007 05:46:27 +0000 (07:46 +0200)
committerKarl Hasselström <kha@treskal.com>
Mon, 8 Oct 2007 07:52:56 +0000 (09:52 +0200)
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 <kha@treskal.com>
stgit/commands/clone.py
stgit/commands/common.py
stgit/main.py

index a150010676afa379061381b76bf9904f8e325c12..c3b0bbea3358d7e630011f2f95cf43b9b2e757e9 100644 (file)
@@ -29,7 +29,7 @@ usage = """%prog [options] <repository> <dir>
 Clone a GIT <repository> into the local <dir> and initialise the
 patch stack."""
 
-directory = DirectoryAnywhere()
+directory = DirectoryAnywhere(needs_current_series = False)
 options = []
 
 
index 27ef465785217ca40a76cdc7676de6b9a43e52a1..652039f859830f298c576fab7daf27fcbe7b2c3a 100644 (file)
@@ -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:
index 8e0021726086275531f0bc2f3d2f432400dd4a06..db327f19f208409d9be0773d4c89db0ff1270ce2 100644 (file)
@@ -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: