Merge lp:~flacoste/charm-tools/promulgate into lp:~charmers/charm-tools/trunk

Proposed by Francis J. Lacoste
Status: Merged
Merged at revision: 61
Proposed branch: lp:~flacoste/charm-tools/promulgate
Merge into: lp:~charmers/charm-tools/trunk
Diff against target: 119 lines (+115/-0)
1 file modified
scripts/promulgate (+115/-0)
To merge this branch: bzr merge lp:~flacoste/charm-tools/promulgate
Reviewer Review Type Date Requested Status
Clint Byrum (community) Approve
Review via email: mp+64611@code.launchpad.net

Description of the change

Hi,

This adds a scripts/promulgate that will make a package branch the official
formula branch. (It will also set the branch status to Mature and the branch
reviewer to ensemble-composers.)

Once it's possible to retrieve the list of official package branches from a
distribution, the getall script could use that instead of having to maintain
the list of branches in-tree.

Any ~ensemble-composers can run it and it's run as:

scripts/promulgate <formula_dir>

It uses the bzr push location as the LP branch to make official, so depending
on your bzr configuration, you might need to specify the LP branch to use:

scripts/promulgate -b lp:~ensemble-composers/oneiric/formula/trunk <formula_dir>

Let me know if you have any questions.

To post a comment you must log in.
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

This is great, thanks Francis! Merged.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'scripts/promulgate'
--- scripts/promulgate 1970-01-01 00:00:00 +0000
+++ scripts/promulgate 2011-06-14 21:22:27 +0000
@@ -0,0 +1,115 @@
1#!/usr/bin/python
2#
3# promulgate - makes a formula recipe branch the official one
4#
5# Copyright (C) 2011 Canonical Ltd.
6# Author: Francis J. Lacoste <francis.lacoste@canonical.com>
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21
22from launchpadlib.launchpad import Launchpad
23
24import os
25import sys
26
27from optparse import OptionParser
28
29from bzrlib import bzrdir
30from bzrlib.plugins.launchpad import lp_api
31
32import yaml
33
34import logging
35
36DISTRIBUTION = 'principia'
37REVIEW_TEAM_NAME = 'ensemble-composers'
38OFFICIAL_BRANCH_POCKET = 'Release'
39OFFICAL_BRANCH_STATUS = 'Mature'
40
41def main(argv):
42 parser = OptionParser(usage='usage: %prog [options] <formula_dir>')
43 parser.add_option(
44 '-b', '--branch', dest='branch', default=None,
45 help='The location of the formula public branch. Will be determined '
46 'from the bzr configuration if omitted.')
47 parser.add_option(
48 '-t', '--lp-instance', dest='lp_instance', default='production',
49 help="The Launchpad instance to use. Defaults to production, but "
50 "staging' or 'qastaging' might be used for testing.")
51 parser.add_option(
52 '-v', '--verbose', dest='verbose', action='count', default=0,
53 help='Increase verbosity level.')
54 options, args = parser.parse_args()
55 if len(args) != 1:
56 parser.error('missing formula directory')
57 return 1
58
59 if options.verbose >= 2:
60 level = logging.DEBUG
61 elif options.verbose >= 1:
62 level = logging.INFO
63 else:
64 level = logging.WARNING
65 logging.basicConfig(level=level, format='%(levelname)s:%(message)s')
66
67 formula_dir = args[0]
68 formula_metadata = os.path.join(formula_dir, 'metadata.yaml')
69 if not os.access(formula_metadata, os.R_OK):
70 logging.error("can't read formula metadata: %s", formula_metadata)
71
72 with open(formula_metadata, 'r') as metadata:
73 formula = yaml.load(metadata)
74
75 logging.debug('login with %s launchpad:', options.lp_instance)
76 lp = Launchpad.login_with('promulgate', options.lp_instance)
77
78 if options.branch is None:
79 tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
80 formula_dir)
81 formula_branch = lp_api.load_branch(lp, branch)
82 if formula_branch is None:
83 logging.error("can't determine Launchpad branch from bzr branch")
84 return 1
85 else:
86 formula_branch = lp.branches.getByUrl(url=options.branch)
87 if formula_branch is None:
88 logging.error("can't find branch on Launchpad: %s", options.branch)
89 return 1
90
91 logging.info(
92 "Setting status %s of to %s", formula_branch.bzr_identity,
93 OFFICAL_BRANCH_STATUS)
94 formula_branch.lifecycle_status = OFFICAL_BRANCH_STATUS
95 logging.info(
96 "Setting reviewer %s of to %s", formula_branch.bzr_identity,
97 REVIEW_TEAM_NAME)
98 formula_branch.reviewer = lp.people[REVIEW_TEAM_NAME]
99 formula_branch.lp_save()
100
101 principia_series = lp.distributions[DISTRIBUTION].current_series
102 lp_formula = principia_series.getSourcePackage(name=formula['name'])
103 logging.info(
104 'Setting %s as the official branch for %s',
105 formula_branch.bzr_identity, lp_formula.name)
106 lp_formula.setBranch(branch=formula_branch, pocket=OFFICIAL_BRANCH_POCKET)
107
108 return 0
109
110
111
112
113if __name__ == '__main__':
114 sys.exit(main(sys.argv))
115

Subscribers

People subscribed via source and target branches