From 9ac099092c5760f69d7a2c79336bacd91e2f3540 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Thu, 14 Jul 2005 17:21:44 +0100 Subject: [PATCH] crt_series initialisation changed 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 --- stgit/commands/common.py | 8 -------- stgit/main.py | 5 +++++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/stgit/commands/common.py b/stgit/commands/common.py index 160dd37..293bd2e 100644 --- a/stgit/commands/common.py +++ b/stgit/commands/common.py @@ -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 diff --git a/stgit/main.py b/stgit/main.py index eb5e63f..071c33a 100644 --- a/stgit/main.py +++ b/stgit/main.py @@ -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: -- 2.11.0