~ursinha/lp-qa-tools/bzr-tarmacland

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: John Arbash Meinel
  • Date: 2006-10-11 04:26:15 UTC
  • Revision ID: john@arbash-meinel.com-20061011042615-7fd3306127c63132
Add GPL copyright

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 by Canonical Ltd
 
1
# Copyright (C) 2005, 2006 by Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
12
#
13
 
# You should have received a copy of the GNU General Public License along
14
 
# with this program; if not, write to the Free Software Foundation, Inc.,
15
 
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
 
"""Functionality for updating merge proposals for Tarmac submission.
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
"""Add functionality for controlling a Patch Queue Manager (pqm).
 
17
 
 
18
This adds a few configuration options. All of these
 
19
are accessible at the Branch level.
 
20
 
 
21
# The email address of the Patch Queue Manager
 
22
pqm_email = pqm@pqm.ubuntu.com
 
23
 
 
24
# The pqm managed branch to merge these changes into
 
25
pqm_branch = http://bazaar-ng.org/bzr/bzr.dev/
 
26
 
 
27
# The branch we will be submitting to the pqm
 
28
# This is custom because the publically accessible location
 
29
# is frequently not this or parent, because they usually
 
30
# need write access, and the public location is readonly
 
31
# The preferred submission locations are:
 
32
#   1) public_branch
 
33
#   2) push_location
 
34
#   3) parent
 
35
#   4) this.base
 
36
public_branch = None
 
37
 
 
38
# This is the smtp server that should be used for
 
39
# outgoing mail. If not set, or set to the empty
 
40
# string, then the email will be sent directly to
 
41
# the pqm machine
 
42
smtp_server = localhost
 
43
# You can also use 
 
44
# smtp_server = host:port 
17
45
"""
18
46
 
 
47
import os
 
48
 
19
49
from bzrlib.commands import Command, register_command
20
50
from bzrlib.option import Option
21
 
from bzrlib.errors import BzrCommandError
22
 
 
23
 
 
24
 
version_info = (0, 0, 1, 'dev', 0)
25
 
 
26
 
if version_info[3] == 'final':
27
 
    version_string = '%d.%d.%d' % version_info[:3]
28
 
else:
29
 
    version_string = '%d.%d.%d%s%d' % version_info
30
 
__version__ = version_string
31
 
 
32
 
 
33
 
class cmd_tarmac_land(Command):
34
 
    """Set the Merge Proposal to be processed by Tarmac.
35
 
 
36
 
    The branch will be handled by Tarmac according to the merge proposal.  If
37
 
    there is more than one one outstanding proposal for the branch, its
38
 
    location must be specified.
 
51
import bzrlib.errors as errors
 
52
 
 
53
from bzrlib.bzrdir import BzrDir
 
54
 
 
55
 
 
56
class cmd_pqm_submit(Command):
 
57
    """Submit the parent tree to the pqm.
 
58
 
 
59
    This acts like:
 
60
        $ echo "star-merge $PARENT $TARGET" 
 
61
            | gpg --cl 
 
62
            | mail pqm@somewhere -s "merge text"
 
63
 
 
64
    But it pays attention to who the local committer is 
 
65
    (using their e-mail address), and uses the local
 
66
    gpg signing configuration. (As well as target pqm
 
67
    settings, etc.)
 
68
 
 
69
    The reason we use 'parent' instead of the local branch
 
70
    is that most likely the local branch is not a public
 
71
    branch. And the branch must be available to the pqm.
39
72
    """
40
73
 
41
74
    takes_args = ['location?']
42
 
 
43
 
    takes_options = [
44
 
        Option('dry-run', help='Display the commit message instead of sending.'),
45
 
        Option(
46
 
            'testfix',
47
 
            help="This is a testfix (tags commit with [testfix])."),
48
 
        Option(
49
 
            'no-qa',
50
 
            help="Does not require QA (tags commit with [no-qa])."),
51
 
        Option(
52
 
            'incremental',
53
 
            help="Incremental to other bug fix (tags commit with [incr])."),
54
 
        Option(
55
 
            'rollback', type=int,
56
 
            help=(
57
 
                "Rollback given revision number. (tags commit with "
58
 
                "[rollback=revno]).")),
59
 
        ]
60
 
 
61
 
    def run(self, location=None, dry_run=False, testfix=False,
62
 
            no_qa=False, incremental=False, rollback=None):
63
 
        from bzrlib.plugins.tarmac_land.tarmac_land import Submitter
64
 
        from bzrlib import branch as _mod_branch
65
 
        from bzrlib.plugins.tarmac_land.tarmac_land import (
66
 
            MissingReviewError, MissingBugsError, MissingBugsIncrementalError)
67
 
 
68
 
        if dry_run:
69
 
            outf = self.outf
 
75
    takes_options = ['message',
 
76
                     Option('dry-run', help='Print request instead of sending'),
 
77
                     Option('public-location', type=str,
 
78
                         help='Use this url as the public location to the pqm.'),
 
79
                    ]
 
80
 
 
81
    def run(self, location=None, message=None, public_location=None, dry_run=False):
 
82
        from pqm_submit import submit
 
83
 
 
84
        if location is None:
 
85
            location = '.'
 
86
        # If we are simply specifying '.' then
 
87
        # we want to open the local branch.
 
88
        # all other uses require an exact path
 
89
        if location == '.':
 
90
            bzrdir = BzrDir.open_containing('.')[0]
70
91
        else:
71
 
            outf = None
72
 
 
73
 
        branch = _mod_branch.Branch.open_containing('.')[0]
74
 
        if rollback and (no_qa or incremental):
75
 
            print "--rollback option used. Ignoring --no-qa and --incremental."
76
 
        try:
77
 
            submitter = Submitter(branch, location, testfix, no_qa,
78
 
                incremental, rollback=rollback).run(outf)
79
 
        except MissingReviewError:
80
 
            raise BzrCommandError(
81
 
                "Cannot land branches that haven't got approved code "
82
 
                "reviews. Get an 'Approved' vote so we can fill in the "
83
 
                "[r=REVIEWER] section.")
84
 
        except MissingBugsError:
85
 
            raise BzrCommandError(
86
 
                "Branch doesn't have linked bugs and doesn't have no-qa "
87
 
                "option set. Use --no-qa, or link the related bugs to the "
88
 
                "branch.")
89
 
        except MissingBugsIncrementalError:
90
 
            raise BzrCommandError(
91
 
                "--incremental option requires bugs linked to the branch. "
92
 
                "Link the bugs or remove the --incremental option.")
93
 
 
94
 
 
95
 
register_command(cmd_tarmac_land)
 
92
            bzrdir = BzrDir.open(location)
 
93
 
 
94
        b = bzrdir.open_branch()
 
95
        submit(b, message=message, dry_run=dry_run, public_location=public_location)
 
96
 
 
97
 
 
98
register_command(cmd_pqm_submit)
96
99
 
97
100
 
98
101
def test_suite():
99
 
    from bzrlib.tests import TestLoader
100
 
    from unittest import TestSuite
101
 
 
102
 
    from tests import test_tarmac_land
 
102
    from bzrlib.tests import TestSuite, TestLoader
 
103
    import test_pqm_submit
103
104
 
104
105
    loader = TestLoader()
105
 
    return TestSuite([
106
 
        loader.loadTestsFromModule(test_tarmac_land),
107
 
        ])
 
106
    return loader.loadTestsFromModule(loader)