~thedac/codetree/branch-checking-and-handling

« back to all changes in this revision

Viewing changes to codetree/handlers.py

  • Committer: David Ames
  • Date: 2013-10-31 22:44:53 UTC
  • Revision ID: david.ames@canonical.com-20131031224453-lgpzhw2iea3eagsc
Handle empty directories and branches starting with lp: with better error handling

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
        self.message = message
22
22
        self.original_exception = original_exception
23
23
 
 
24
class NotABranch(Exception):
 
25
        pass
 
26
 
24
27
class NotSameBranch(Exception):
25
28
    pass
26
29
 
120
123
    def get(self, dest, options=None):
121
124
        if not options:
122
125
            options = {}
123
 
 
 
126
        if not self.is_bzr_branch(self.source):
 
127
            raise NotABranch("{} is not a bzr branch. Is it a private branch? Check permissions on the branch.".format(self.source))
124
128
        if os.path.exists(dest):
125
 
            if not self.is_bzr_branch(self.source):
126
 
                print("{} is not a bzr branch. Is it a private branch? check permissions on the branch.".format(dest))
127
 
                return False
128
129
            if not self.is_bzr_branch(dest):
129
 
                print("{} is not a bzr branch, it may be an empty directory".format(dest))
 
130
                raise NotABranch("{} is not a bzr branch, it may be an empty directory".format(dest))
130
131
                return False
131
132
            # if the parent is the same, update the branch
132
133
            if self.is_same_branch(dest):