Merge lp:~maxb/bzr-builddeb/dch-fail-exception into lp:bzr-builddeb

Proposed by Max Bowsher
Status: Merged
Approved by: James Westby
Approved revision: 559
Merged at revision: 561
Proposed branch: lp:~maxb/bzr-builddeb/dch-fail-exception
Merge into: lp:bzr-builddeb
Diff against target: 77 lines (+22/-8)
3 files modified
cmds.py (+6/-2)
errors.py (+7/-0)
merge_upstream.py (+9/-6)
To merge this branch: bzr merge lp:~maxb/bzr-builddeb/dch-fail-exception
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+61031@code.launchpad.net

Description of the change

Currently when bzr-builddeb's invocation of dch fails, it eats the cause. This tries to reveal it a bit more.

I'm pretty sure trace.note(exception) isn't quite the right thing to be doing - advice gratefully accepted.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmds.py'
2--- cmds.py 2011-04-29 22:32:59 +0000
3+++ cmds.py 2011-05-15 17:24:32 +0000
4@@ -67,6 +67,7 @@
5 )
6 from bzrlib.plugins.builddeb.errors import (
7 BuildFailedError,
8+ DchError,
9 MissingChangelogError,
10 NoPreviousUpload,
11 PackageVersionNotPresent,
12@@ -541,8 +542,11 @@
13 changelog):
14 from bzrlib.plugins.builddeb.merge_upstream import (
15 changelog_add_new_version)
16- if not changelog_add_new_version(tree, version, distribution_name,
17- changelog, package):
18+ try:
19+ changelog_add_new_version(tree, version, distribution_name,
20+ changelog, package)
21+ except DchError, e:
22+ note(e)
23 raise BzrCommandError('Adding a new changelog stanza after the '
24 'merge had completed failed. Add the new changelog '
25 'entry yourself, review the merge, and then commit.')
26
27=== modified file 'errors.py'
28--- errors.py 2011-04-08 18:47:10 +0000
29+++ errors.py 2011-05-15 17:24:32 +0000
30@@ -224,3 +224,10 @@
31
32 _fmt = ("Build refused because there are unknown files in the tree. "
33 "To list all known files, run 'bzr unknowns'.")
34+
35+
36+class DchError(BzrError):
37+ _fmt = 'There was an error using dch: %(error)s.'
38+
39+ def __init__(self, error):
40+ BzrError.__init__(self, error=error)
41
42=== modified file 'merge_upstream.py'
43--- merge_upstream.py 2011-04-29 12:54:58 +0000
44+++ merge_upstream.py 2011-05-15 17:24:32 +0000
45@@ -34,6 +34,11 @@
46 # Prior to 0.1.15 the debian module was called debian_bundle
47 from debian_bundle.changelog import Version
48
49+from bzrlib.plugins.builddeb.errors import (
50+ DchError,
51+ )
52+
53+
54 TAG_PREFIX = "upstream-"
55
56
57@@ -83,7 +88,6 @@
58 :param distribution_name: Distribution name (debian, ubuntu, ...)
59 :param changelog: Changelog object
60 :param package: Package name
61- :return: Whether an entry was successfully added
62 """
63 assert isinstance(upstream_version, str), \
64 "upstream_version should be a str, not %s" % str(
65@@ -99,8 +103,7 @@
66 "--package", package, entry_description]
67 if not tree.has_filename("debian/changelog"):
68 argv.append("--create")
69- proc = subprocess.Popen(argv, cwd=tree.basedir)
70- proc.wait()
71- # FIXME: Raise insightful exception here rather than just checking
72- # return code.
73- return proc.returncode == 0
74+ proc = subprocess.Popen(argv, cwd=tree.basedir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
75+ (stdout, stderr) = proc.communicate()
76+ if proc.returncode != 0:
77+ raise DchError("Adding changelog entry failed: %s" % stderr)

Subscribers

People subscribed via source and target branches