Merge lp:~mars/tarmac/more-logging into lp:tarmac

Proposed by Māris Fogels
Status: Merged
Approved by: Paul Hummer
Approved revision: 382
Merged at revision: 380
Proposed branch: lp:~mars/tarmac/more-logging
Merge into: lp:tarmac
Diff against target: 74 lines (+38/-3)
1 file modified
tarmac/bin/commands.py (+38/-3)
To merge this branch: bzr merge lp:~mars/tarmac/more-logging
Reviewer Review Type Date Requested Status
Paul Hummer Approve
Review via email: mp+39667@code.launchpad.net

Commit message

Added additional debug logging to the authenticate and merge commands.

Description of the change

Hi,

This branch adds additional debug logging to the authenticate and merge commands.

With this patch users can run the 'tarmac merge --debug' command to see what the
program decides to do with the branches it finds, and why it decided to do it.
This solves a problem where new users may not understand why Tarmac is not
finding their branches. They later discover that the program silently skipped
their branches because the Launchpad commit message was not set. (This has
happened to me twice now, on two different Tarmac setups.)

I added the authentication logging to solve a problem with launchpadlib on
headless servers: the 'tarmac authenticate' command was not writing any log
output, and the launchpadlib commands were also failing - I did not know what
the program was doing. The additional logging makes it a bit easier to
understand that the call to launchpadlib is the problem.

To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) wrote :

This looks great. I'm actually wanting to move in a direction similar to what you did with _get_mergable_proposals_for_branch anyway, so this is a good start. Thanks for the patch!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tarmac/bin/commands.py'
2--- tarmac/bin/commands.py 2010-10-26 19:00:23 +0000
3+++ tarmac/bin/commands.py 2010-10-29 22:17:41 +0000
4@@ -66,15 +66,29 @@
5 else:
6 SERVICE_ROOT = EDGE_SERVICE_ROOT
7
8+ self.logger.debug(
9+ "Connecting to the Launchpad API at {0}".format(SERVICE_ROOT))
10+
11+ self.logger.debug(" Loading credentials from {0}".format(filename))
12 if not os.path.exists(filename):
13+ self.logger.debug(" No existing API credentials were found")
14+ self.logger.debug(" Fetching new credentials from {0}".format(
15+ SERVICE_ROOT))
16+
17 launchpad = Launchpad.get_token_and_login(
18 'Tarmac', SERVICE_ROOT, self.config.CACHE_HOME)
19 launchpad.credentials.save(file(filename, 'w'))
20+
21+ self.logger.debug(" Credentials saved to {0}".format(filename))
22 else:
23 credentials = Credentials()
24 credentials.load(open(filename))
25+ self.logger.debug(" Credentials loaded".format(filename))
26+
27 launchpad = Launchpad(
28 credentials, SERVICE_ROOT, self.config.CACHE_HOME)
29+
30+ self.logger.debug("Connected")
31 return launchpad
32
33
34@@ -136,9 +150,9 @@
35
36 lp_branch = self.launchpad.branches.getByUrl(url=branch_url)
37
38- proposals = [entry for entry in lp_branch.landing_candidates
39- if entry.queue_status == u'Approved' and
40- (imply_commit_message or entry.commit_message)]
41+ proposals = self._get_mergable_proposals_for_branch(
42+ lp_branch, imply_commit_message)
43+
44 if not proposals:
45 self.logger.info(
46 'No approved proposals found for %(branch_url)s' % {
47@@ -276,6 +290,27 @@
48 finally:
49 target.cleanup()
50
51+ def _get_mergable_proposals_for_branch(self, lp_branch,
52+ imply_commit_message):
53+ """Return a list of the mergable proposals for the given branch."""
54+ proposals = []
55+ for entry in lp_branch.landing_candidates:
56+ self.logger.debug("Considering merge proposal: {0}".format(entry))
57+
58+ if entry.queue_status != u'Approved':
59+ self.logger.debug(
60+ " Skipping proposal: status is {0}, not "
61+ "'Approved'".format(entry.queue_status))
62+ continue
63+
64+ if not imply_commit_message and not entry.commit_message:
65+ self.logger.debug(
66+ " Skipping proposal: proposal has no commit message")
67+ continue
68+
69+ proposals.append(entry)
70+ return proposals
71+
72 def _get_reviews(self, proposal):
73 """Get the set of reviews from the proposal."""
74 reviews = []

Subscribers

People subscribed via source and target branches