273
273
takes_args = ['location?']
274
takes_options = ['remember', Option('directory',
275
help='Branch to push from, '
276
'rather than the one containing the working directory.',
280
Option('no-rebase', help="Do not rebase after push.")]
277
help='Branch to push from, '
278
'rather than the one containing the working directory.',
282
Option('no-rebase', help="Do not rebase after push."),
284
help='Refuse to push if there are uncommitted changes in'
285
' the working tree, --no-strict disables the check.'),
282
def run(self, location=None, remember=False, directory=None,
288
def run(self, location=None, remember=False, directory=None,
289
no_rebase=False, strict=None):
284
290
from bzrlib import urlutils
285
291
from bzrlib.bzrdir import BzrDir
286
292
from bzrlib.errors import BzrCommandError, NoWorkingTree
294
300
except NoWorkingTree:
295
301
source_branch = Branch.open(directory)
304
strict = source_branch.get_config(
305
).get_user_option_as_bool('dpush_strict')
306
if strict is None: strict = True # default value
307
if strict and source_wt is not None:
308
if (source_wt.has_changes(source_wt.basis_tree())
309
or len(source_wt.get_parent_ids()) > 1):
310
raise errors.UncommittedChanges(
311
source_wt, more='Use --no-strict to force the push.')
312
if source_wt.last_revision() != source_wt.branch.last_revision():
313
# The tree has lost sync with its branch, there is little
314
# chance that the user is aware of it but he can still force
315
# the push with --no-strict
316
raise errors.OutOfDateTree(
317
source_wt, more='Use --no-strict to force the push.')
297
318
stored_loc = source_branch.get_push_location()
298
319
if location is None:
299
320
if stored_loc is None: