crt_series initialisation changed
authorCatalin Marinas <catalin.marinas@gmail.com>
Thu, 14 Jul 2005 16:21:44 +0000 (17:21 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Thu, 14 Jul 2005 16:21:44 +0000 (17:21 +0100)
The current model does not allow running any command outside a GIT tree.
Even 'help' fails. The simple hack is to use setattr to initialise
crt_series in a module. The other option would be to initialise it in
every command file but I'm too lazy to do it.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/commands/common.py
stgit/main.py

index 160dd37..293bd2e 100644 (file)
@@ -30,14 +30,6 @@ class CmdException(Exception):
     pass
 
 
-# Global variables
-try:
-    crt_series = stack.Series()
-except (IOError, stack.StackException, git.GitException), err:
-    print >> sys.stderr, err
-    sys.exit(2)
-
-
 # Utility functions
 def git_id(string):
     """Return the GIT id
index eb5e63f..071c33a 100644 (file)
@@ -118,6 +118,11 @@ def main():
                           option_list = command.options)
     options, args = parser.parse_args()
     try:
+        # the lines below are a simple way to avoid an exception when
+        # stgit is run outside an initialised tree
+        stgit.commands.common.crt_series = stack.Series()
+        setattr(command, 'crt_series', stgit.commands.common.crt_series)
+
         command.func(parser, options, args)
     except (IOError, CmdException, stack.StackException, git.GitException), \
                err: