Merge lp:~abentley/launchpad/qa-ready into lp:launchpad

Proposed by Aaron Bentley
Status: Merged
Merged at revision: not available
Proposed branch: lp:~abentley/launchpad/qa-ready
Merge into: lp:launchpad
Diff against target: 93 lines (+89/-0)
1 file modified
utilities/qa-ready (+89/-0)
To merge this branch: bzr merge lp:~abentley/launchpad/qa-ready
Reviewer Review Type Date Requested Status
Paul Hummer (community) code Approve
Review via email: mp+20162@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) wrote :

= Summary =
Implement a script that shows when a branch is ready to be QA-ed.

== Proposed fix ==
This branch provides a new script, qa-ready that shows whether a branch has
been deployed on edge and staging.

== Pre-implementation notes ==
Briefly discussed with Thumper

== Implementation details ==
The revno-determining strategies are stolen from the existing on-edge script.
Because the Launchpad repository has ghosts revisions, bzrlib will look for
them in remote branches. So I've provided a configuration option
"local_location" that lets you specify the local location of your stable and
db-stable branches.

== Tests ==
None

== Demo and Q/A ==
None

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  utilities/qa-ready

Revision history for this message
Paul Hummer (rockstar) wrote :

<rockstar> abentley, I thought there was a page that had only the revno on it. Did that not pan out?
<abentley> rockstar, I don't think there's any such page.
<rockstar> abentley, okay.
<rockstar> abentley, the use of a bzr transport to screen scrape confuses me. What does it provide that a regular urllib or something doesn't?
<rockstar> Also, it sure would be nice if we had a successful-updates.txt for edge.
<rockstar> (not your problem though)
<abentley> rockstar, it respects all the configuration data that bzr does, so if you have proxies or things set up for bzr, those will apply to the transport also.
<rockstar> abentley, ah, okay.
<abentley> rockstar, also, it's familiar, and I don't see any reason *not* to use it.
<rockstar> abentley, that's the reason I would have suspected, but the former is also a very good reason.
<rockstar> s/suspected/expected/
<rockstar> abentley, was there a technical reason is_present appears after main?
<abentley> rockstar, no.
<rockstar> abentley, so, it's not a big deal, but I usually expect functions to be defined before I see the calls. It's still valid python, but hard to follow. Would you mind just bumping is_present above main?
<abentley> rockstar, sure.
<rockstar> abentley, r=rockstar

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'utilities/qa-ready'
--- utilities/qa-ready 1970-01-01 00:00:00 +0000
+++ utilities/qa-ready 2010-02-25 19:13:18 +0000
@@ -0,0 +1,89 @@
1#!/usr/bin/python2.5
2#
3# Copyright 2010 Canonical Ltd. This software is licensed under the
4# GNU Affero General Public License version 3 (see the file LICENSE).
5
6import re
7import sys
8
9from bzrlib.branch import Branch
10from bzrlib.config import LocationConfig
11from bzrlib.transport import get_transport
12
13
14class UsageError(Exception):
15 """Raised when the user makes a dumb error."""
16
17
18def get_staging_revision():
19 """Get the revision of db-stable deployed on staging.
20
21 :return: The staging revno as an int. Corresponds to a revision of
22 lp:launchpad/db-stable.
23 """
24 t = get_transport('https://staging.launchpad.net/')
25 last_line = t.get_bytes('successful-updates.txt').splitlines()[-1]
26 return int(last_line.split()[-1])
27
28
29def get_edge_revision():
30 """Get the revision of stable deployed on edge.
31
32 :return: The edge revno as an int. Corresponds to a revision of
33 lp:launchpad/stable.
34 """
35 t = get_transport('https://edge.launchpad.net/')
36 html = t.get_bytes('index.html')
37 revision_re = re.compile(r'\(r(\d+)\)')
38 for line in html.splitlines():
39 matches = revision_re.search(line)
40 if matches:
41 return int(matches.group(1))
42 raise ValueError("Could not find revision number on edge home page")
43
44
45def is_present(local_branch, deployed_location, deployed_revno):
46 local_mirror = LocationConfig(deployed_location).get_user_option(
47 'local_location')
48 if local_mirror is None:
49 print (
50 'Please configure a local_location for %s in locations.conf '
51 'to improve performance.' % deployed_location)
52 deployed_branch = Branch.open(deployed_location)
53 else:
54 deployed_branch = Branch.open(local_mirror)
55 deployed_branch.lock_read()
56 try:
57 deployed_rev_id = deployed_branch.get_rev_id(deployed_revno)
58 graph = local_branch.repository.get_graph(deployed_branch.repository)
59 return graph.is_ancestor(local_branch.last_revision(), deployed_rev_id)
60 finally:
61 deployed_branch.unlock()
62
63
64
65stable = 'bzr+ssh://bazaar.launchpad.net/~launchpad-pqm/launchpad/stable'
66dbstable = 'bzr+ssh://bazaar.launchpad.net/~launchpad-pqm/launchpad/db-stable'
67def main(argv):
68 if len(sys.argv) > 1:
69 location = sys.argv[1]
70 else:
71 location = '.'
72 b = Branch.open_containing(location)[0]
73 b.lock_read()
74 try:
75 print 'Branch: %s' % b.base
76 print 'Deployed on edge: %s' % is_present(
77 b, stable, get_edge_revision())
78 print 'Deployed on staging: %s' % is_present(
79 b, dbstable, get_staging_revision())
80 finally:
81 b.unlock()
82
83
84if __name__ == '__main__':
85 try:
86 sys.exit(main(sys.argv[1:]))
87 except UsageError, e:
88 print 'ERROR: %s' % e
89 sys.exit(1)