Merge lp:~thedac/codetree/raise-exceptions-on-errors into lp:~codetree-maintainers/codetree/master

Proposed by David Ames
Status: Rejected
Rejected by: Matthew Wedgwood
Proposed branch: lp:~thedac/codetree/raise-exceptions-on-errors
Merge into: lp:~codetree-maintainers/codetree/master
Diff against target: 78 lines (+22/-17)
1 file modified
codetree/handlers.py (+22/-17)
To merge this branch: bzr merge lp:~thedac/codetree/raise-exceptions-on-errors
Reviewer Review Type Date Requested Status
Matthew Wedgwood Pending
Review via email: mp+186414@code.launchpad.net

Description of the change

Currently, bzr actions fail quietly
In the context of mojo we need them to fail explicitly

Very open to better solutions or if there is a grand plan for exception handling

To post a comment you must log in.
Revision history for this message
Matthew Wedgwood (mew) wrote :

This has been incorporated into https://code.launchpad.net/~mew/codetree/fixes-with-thedac/+merge/186454, with the ability for the user to choose the behavior when an operation fails.

Unmerged revisions

27. By David Ames

Raise expceptions on failures

26. By David Ames

Branch only to the revno requested

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'codetree/handlers.py' (properties changed: -x to +x)
2--- codetree/handlers.py 2013-09-14 18:28:43 +0000
3+++ codetree/handlers.py 2013-09-18 18:17:15 +0000
4@@ -15,14 +15,15 @@
5
6
7 def log_failure(cmd, message):
8- try:
9- with open(os.devnull) as devnull:
10- logging.info(message)
11- check_output(cmd, stderr=devnull)
12- except CalledProcessError as e:
13- logging.error(e.output)
14- except OSError as e:
15- logging.error(e.message)
16+ try:
17+ logging.info(message)
18+ check_output(cmd)
19+ except CalledProcessError as e:
20+ logging.error(e)
21+ raise BaseException(e)
22+ except OSError as e:
23+ logging.error(e)
24+ raise OSError(e)
25
26
27 class SourceHandler(object):
28@@ -55,18 +56,20 @@
29 parent_dir = os.path.dirname(dest)
30 if parent_dir and not os.path.exists(parent_dir):
31 os.makedirs(parent_dir)
32- cmd = ('bzr', 'branch', self.source, dest)
33+ cmd = ['bzr', 'branch', self.source, dest]
34+ if self.revno:
35+ cmd.insert(2, '-r')
36+ cmd.insert(3, self.revno)
37 log_failure(cmd, "Branching {} to {}".format(self.source, dest))
38
39 def update_branch(self, dest):
40 cmd = ("bzr", "pull", "-d", dest)
41 log_failure(cmd, "Updating {} from parent ({})".format(dest, self.source))
42
43- def revno_branch(self, dest, revno):
44- cmd = ('bzr', 'update', dest, '-r', revno)
45- log_failure(cmd, "Checking out revision {} of {}".format(revno, self.source))
46-
47 def is_same_branch(self, dest):
48+ # Add trailing '/' if missing
49+ if self.source[-1] != '/':
50+ self.source += '/'
51 bzr_cmd = ("bzr", "info", dest)
52 grep_cmd = ("grep", "parent branch")
53 bzr_call = Popen(bzr_cmd, stdout=PIPE)
54@@ -81,6 +84,10 @@
55 def get(self, dest, options=None):
56 if not options:
57 options = {}
58+ if "revno" in options:
59+ self.revno = options["revno"]
60+ else:
61+ self.revno = None
62
63 if os.path.exists(dest):
64 # if the parent is the same, update the branch
65@@ -91,12 +98,10 @@
66 shutil.rmtree(dest)
67 self.checkout_branch(dest)
68 else:
69- logging.info("Skipping existing dest {}".format(dest))
70- return False
71+ logging.info("Dest, {}, exists but has a different parent ".format(dest))
72+ raise BaseException("Dest, {}, exists but has a different parent".format(dest))
73 else:
74 self.checkout_branch(dest)
75- if "revno" in options:
76- self.revno_branch(dest, options["revno"])
77
78 return True
79

Subscribers

People subscribed via source and target branches

to all changes: