chiark / gitweb /
"stg series" on an un-inited branch gives weird error
authorChuck Lever <cel@netapp.com>
Wed, 21 Sep 2005 18:01:43 +0000 (14:01 -0400)
committerCatalin Marinas <catalin.marinas@gmail.com>
Wed, 21 Sep 2005 20:56:38 +0000 (21:56 +0100)
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 <cel@netapp.com>
stgit/stack.py

index 71091860a9bb0dc6514250ac2d8fa84880a62227..2e36d88452512877456ed8bbe7568b3d0e0c89c3 100644 (file)
@@ -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()