From: Chuck Lever Date: Wed, 21 Sep 2005 18:01:43 +0000 (-0400) Subject: "stg series" on an un-inited branch gives weird error X-Git-Tag: v0.14.3~659 X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/commitdiff_plain/40e65b928d0429090a39843c1a81dec31f4d38e2?hp=7c09df84663028d46af9d79d0cbb37532f94deb8 "stg series" on an un-inited branch gives weird error If I try an "stg series" command on a repository that hasn't yet been initialized, I get a non-intuitive error message: stg series: [Errno 2] No such file or directory: '/home/cel/src/git/main/.git/patches/master/applied' This patch replaces the message with a reasonable explanation. Signed-off-by: Chuck Lever --- diff --git a/stgit/stack.py b/stgit/stack.py index 7109186..2e36d88 100644 --- a/stgit/stack.py +++ b/stgit/stack.py @@ -249,8 +249,7 @@ class Series: """Class including the operations on series """ def __init__(self, name = None): - """Takes a series name as the parameter. A valid .git/patches/name - directory should exist + """Takes a series name as the parameter. """ if name: self.__name = name @@ -297,12 +296,18 @@ class Series: return name def get_applied(self): + if not os.path.isfile(self.__applied_file): + raise StackException, \ + 'No StGIT metadata found. Try "stg init" first' f = file(self.__applied_file) names = [line.strip() for line in f.readlines()] f.close() return names def get_unapplied(self): + if not os.path.isfile(self.__unapplied_file): + raise StackException, \ + 'No StGIT metadata found. Try "stg init" first' f = file(self.__unapplied_file) names = [line.strip() for line in f.readlines()] f.close()