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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Copyright (C) 2005, 2006, 2007 by Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
"""Functionality for controlling a Patch Queue Manager (pqm).
"""

from bzrlib.commands import Command, register_command
from bzrlib.option import Option

from bzrlib.bzrdir import BzrDir


version_info = (0, 92, 0, 'dev', 0)
__version__ = '.'.join(str(v) for v in version_info)


class cmd_pqm_submit(Command):
    """Submit the parent tree to the pqm.

    This acts like:
        $ echo "star-merge $PARENT $TARGET"
            | gpg --cl
            | mail pqm@somewhere -s "merge text"

    But it pays attention to who the local committer is
    (using their e-mail address), and uses the local
    gpg signing configuration. (As well as target pqm
    settings, etc.)

    The reason we use 'parent' instead of the local branch
    is that most likely the local branch is not a public
    branch. And the branch must be available to the pqm.

    This can be configured at the branch level using ~/.bazaar/locations.conf.
    Here is an example:
        [/home/emurphy/repo]
        pqm_email = PQM <pqm@example.com>
        pqm_user_email = User Name <user@example.com>
        submit_branch = http://code.example.com/code/project/devel
        # Set public_branch appropriately for all branches in repository:
        public_branch = http://code.example.com/code/emurphy/project
        public_branch:policy = appendpath
        [/home/emurphy/repo/branch]
        # Override public_branch for this repository:
        public_branch = http://alternate.host.example.com/other/public/branch

        smtp_server = host:port
        smtp_username =
        smtp_password =

    If you don't specify the smtp server, the message will be sent via localhost.
    """

    takes_args = ['location?']
    takes_options = [
        Option('message',
               help='Message to use on merge to pqm.  '
                    'Currently must be a single line because of pqm limits.',
               short_name='m',
               type=str),
        Option('dry-run', help='Print request instead of sending.'),
        Option('public-location', type=str,
               help='Use this url as the public location to the pqm.'),
        ]

    def run(self, location=None, message=None, public_location=None, dry_run=False):
        from bzrlib.plugins.pqm.pqm_submit import submit

        if location is None:
            location = '.'
        # If we are simply specifying '.' then
        # we want to open the local branch.
        # all other uses require an exact path
        if location == '.':
            bzrdir = BzrDir.open_containing('.')[0]
        else:
            bzrdir = BzrDir.open(location)

        b = bzrdir.open_branch()
        submit(b, message=message, dry_run=dry_run, public_location=public_location)


register_command(cmd_pqm_submit)


def test_suite():
    from bzrlib.tests import TestLoader
    import test_pqm_submit

    loader = TestLoader()
    return loader.loadTestsFromModule(test_pqm_submit)