10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
11
# GNU General Public License for more details.
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
"""Functionality for controlling a Patch Queue Manager (pqm).
19
19
from bzrlib.commands import Command, register_command
20
20
from bzrlib.option import Option
21
from bzrlib.errors import BzrCommandError
24
version_info = (0, 0, 1, 'dev', 0)
22
from bzrlib.bzrdir import BzrDir
25
version_info = (1, 3, 0, 'dev', 0)
26
27
if version_info[3] == 'final':
27
28
version_string = '%d.%d.%d' % version_info[:3]
30
31
__version__ = version_string
33
class cmd_tarmac_land(Command):
34
"""Set the Merge Proposal to be processed by Tarmac.
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.
34
class cmd_pqm_submit(Command):
35
"""Submit the parent tree to the pqm.
38
$ echo "star-merge $PARENT $TARGET"
40
| mail pqm@somewhere -s "merge text"
42
But it pays attention to who the local committer is
43
(using their e-mail address), and uses the local
44
gpg signing configuration. (As well as target pqm
47
The reason we use 'parent' instead of the local branch
48
is that most likely the local branch is not a public
49
branch. And the branch must be available to the pqm.
51
This can be configured at the branch level using ~/.bazaar/locations.conf.
54
pqm_email = PQM <pqm@example.com>
55
pqm_user_email = User Name <user@example.com>
56
submit_branch = http://code.example.com/code/project/devel
57
# Set public_branch appropriately for all branches in repository:
58
public_branch = http://code.example.com/code/emurphy/project
59
public_branch:policy = appendpath
60
[/home/emurphy/repo/branch]
61
# Override public_branch for this repository:
62
public_branch = http://alternate.host.example.com/other/public/branch
64
smtp_server = host:port
68
If you don't specify the smtp server, the message will be sent via localhost.
41
71
takes_args = ['location?']
44
Option('dry-run', help='Display the commit message instead of sending.'),
47
help="This is a testfix (tags commit with [testfix])."),
50
help="Does not require QA (tags commit with [no-qa])."),
53
help="Incremental to other bug fix (tags commit with [incr])."),
57
"Rollback given revision number. (tags commit with "
58
"[rollback=revno]).")),
74
help='Message to use on merge to pqm. '
75
'Currently must be a single line because of pqm limits.',
78
Option('dry-run', help='Print request instead of sending.'),
79
Option('public-location', type=str,
80
help='Use this url as the public location to the pqm.'),
81
Option('submit-branch', type=str,
82
help='Use this url as the target submission branch.'),
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)
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."
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 "
89
except MissingBugsIncrementalError:
90
raise BzrCommandError(
91
"--incremental option requires bugs linked to the branch. "
92
"Link the bugs or remove the --incremental option.")
95
register_command(cmd_tarmac_land)
85
def run(self, location=None, message=None, public_location=None,
86
dry_run=False, submit_branch=None):
87
if __name__ != 'bzrlib.plugins.pqm':
88
from bzrlib import trace
89
trace.warning('The bzr-pqm plugin needs to be called'
90
' "bzrlib.plugins.pqm" not "%s"\n'
91
'Please rename the plugin.',
94
from bzrlib.plugins.pqm.pqm_submit import submit
98
tree, b, relpath = BzrDir.open_containing_tree_or_branch(location)
99
if relpath and not tree:
100
from bzrlib import errors
101
raise errors.BzrCommandError('No working tree was found, but we'
102
' were not given the exact path to'
104
' We found the branch at: %s'
106
submit(b, message=message, dry_run=dry_run,
107
public_location=public_location,
108
submit_location=submit_branch,
112
register_command(cmd_pqm_submit)
99
116
from bzrlib.tests import TestLoader
100
from unittest import TestSuite
102
from tests import test_tarmac_land
117
import test_pqm_submit
104
119
loader = TestLoader()
106
loader.loadTestsFromModule(test_tarmac_land),
120
return loader.loadTestsFromModule(test_pqm_submit)