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

Subscribers

People subscribed via source and target branches