stackupgrade.py had an undefined reference to StackException. stgit/stack.py and stgit/lib/stack.py both defined StackException classes. To untangle potential circular dependencies between stack, lib.stack and lib.stackupgrade, we move StackException to the dependency-less stgit.exception module where it can be imported by all modules.
Signed-off-by: Peter Grayson <[email protected]> --- stgit/exception.py | 5 ++++- stgit/lib/log.py | 9 +++++---- stgit/lib/stack.py | 5 ++--- stgit/lib/stackupgrade.py | 1 + stgit/stack.py | 5 +---- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/stgit/exception.py b/stgit/exception.py index 9933e641..e26da84e 100644 --- a/stgit/exception.py +++ b/stgit/exception.py @@ -1,3 +1,6 @@ class StgException(Exception): """Base class for all StGit exceptions.""" - pass + + +class StackException(StgException): + """Exception raised by L{stack} objects.""" diff --git a/stgit/lib/log.py b/stgit/lib/log.py index d876ff60..6c707f2a 100644 --- a/stgit/lib/log.py +++ b/stgit/lib/log.py @@ -101,11 +101,12 @@ mainly ease of visualization.""" import re from stgit.lib import git, stack as libstack -from stgit import exception, utils +from stgit import utils +from stgit.exception import StgException, StackException from stgit.out import out import StringIO -class LogException(exception.StgException): +class LogException(StgException): pass class LogParseException(LogException): @@ -362,7 +363,7 @@ def compat_log_entry(msg): try: repo = default_repo() stack = repo.get_stack(repo.current_branch_name) - except (libstack.StackException, git.RepositoryException), e: + except (StackException, git.RepositoryException) as e: out.warn(str(e), 'Could not write to stack log') else: if repo.default_index.conflicts() and stack.patchorder.applied: @@ -518,7 +519,7 @@ def compat_log_external_mods(): return try: stack = repo.get_stack(repo.current_branch_name) - except exception.StgException: + except StgException: # Stack doesn't exist, so we can't log. return log_external_mods(stack) diff --git a/stgit/lib/stack.py b/stgit/lib/stack.py index a72ee229..f9a4454b 100644 --- a/stgit/lib/stack.py +++ b/stgit/lib/stack.py @@ -1,12 +1,11 @@ """A Python class hierarchy wrapping the StGit on-disk metadata.""" import os.path -from stgit import exception, utils +from stgit import utils +from stgit.exception import StackException from stgit.lib import git, stackupgrade from stgit.config import config -class StackException(exception.StgException): - """Exception raised by L{stack} objects.""" class Patch(object): """Represents an StGit patch. This class is mainly concerned with diff --git a/stgit/lib/stackupgrade.py b/stgit/lib/stackupgrade.py index 4b437dc0..daa176ba 100644 --- a/stgit/lib/stackupgrade.py +++ b/stgit/lib/stackupgrade.py @@ -2,6 +2,7 @@ import os.path from stgit import utils from stgit.out import out from stgit.config import config +from stgit.exception import StackException # The current StGit metadata format version. FORMAT_VERSION = 2 diff --git a/stgit/stack.py b/stgit/stack.py index f79f76fe..7782f3ff 100644 --- a/stgit/stack.py +++ b/stgit/stack.py @@ -20,7 +20,7 @@ along with this program; if not, see http://www.gnu.org/licenses/. import sys, os, re from email.Utils import formatdate -from stgit.exception import * +from stgit.exception import StackException from stgit.utils import * from stgit.out import * from stgit.run import * @@ -29,9 +29,6 @@ from stgit.config import config from shutil import copyfile from stgit.lib import git as libgit, stackupgrade -# stack exception class -class StackException(StgException): - pass class FilterUntil: def __init__(self): _______________________________________________ stgit-users mailing list [email protected] https://mail.gna.org/listinfo/stgit-users
