1
# Copyright (C) 2005-2008 by Canonical Ltd
1
# Copyright (C) 2006-2010 by Canonical Ltd
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
19
19
from bzrlib.commands import Command, register_command
20
20
from bzrlib.option import Option
21
from bzrlib.errors import BzrCommandError
23
24
version_info = (1, 4, 0, 'dev', 0)
84
85
def run(self, location=None, message=None, public_location=None,
85
86
dry_run=False, submit_branch=None, ignore_local=False):
86
from bzrlib import errors, trace, bzrdir
87
from bzrlib import trace, bzrdir
87
88
if __name__ != 'bzrlib.plugins.pqm':
88
89
trace.warning('The bzr-pqm plugin needs to be called'
89
90
' "bzrlib.plugins.pqm" not "%s"\n'
104
105
self.add_cleanup(b.unlock)
105
106
if relpath and not tree and location != '.':
106
raise errors.BzrCommandError(
107
raise BzrCommandError(
107
108
'No working tree was found, but we were not given the '
108
109
'exact path to the branch.\n'
109
110
'We found a branch at: %s' % (b.base,))
110
111
if message is None:
111
raise errors.BzrCommandError(
112
raise BzrCommandError(
112
113
'You must supply a commit message for the pqm to use.')
113
114
submit(b, message=message, dry_run=dry_run,
114
115
public_location=public_location,
126
127
takes_args = ['location?']
128
takes_options = [Option(
129
'dry-run', help='Display the PQM message instead of sending.')]
130
Option('dry-run', help='Display the PQM message instead of sending.'),
133
help="This is a testfix (tags commit with [testfix])."),
136
help="Does not require QA (tags commit with [no-qa])."),
139
help="Incremental to other bug fix (tags commit with [incr])."),
131
def run(self, location=None, dry_run=False):
142
def run(self, location=None, dry_run=False, testfix=False,
143
no_qa=False, incremental=False):
132
144
from bzrlib.plugins.pqm.lpland import Submitter
133
145
from bzrlib import branch as _mod_branch
146
from bzrlib.plugins.pqm.lpland import (
147
MissingReviewError, MissingBugsError, MissingBugsIncrementalError)
150
if no_qa and incremental:
151
raise BzrCommandError(
152
"--no-qa and --incremental cannot be given at the same time.")
134
154
branch = _mod_branch.Branch.open_containing('.')[0]
139
submitter = Submitter(branch, location).run(outf)
160
submitter = Submitter(branch, location, testfix, no_qa, incremental
162
except MissingReviewError:
163
raise BzrCommandError(
164
"Cannot land branches that haven't got approved code "
165
"reviews. Get an 'Approved' vote so we can fill in the "
166
"[r=REVIEWER] section.")
167
except MissingBugsError:
168
raise BzrCommandError(
169
"Branch doesn't have linked bugs and doesn't have no-qa "
170
"option set. Use --no-qa, or link the related bugs to the "
172
except MissingBugsIncrementalError:
173
raise BzrCommandError(
174
"--incremental option requires bugs linked to the branch. "
175
"Link the bugs or remove the --incremental option.")
142
178
register_command(cmd_pqm_submit)