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
287
from bzrlib.trace import info
288
293
from bzrlib.workingtree import WorkingTree
290
295
if directory is None:
295
300
except NoWorkingTree:
296
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()):
309
raise errors.UncommittedChanges(
310
source_wt, more='Use --no-strict to force the push.')
311
if source_wt.last_revision() != source_wt.branch.last_revision():
312
# The tree has lost sync with its branch, there is little
313
# chance that the user is aware of it but he can still force
314
# the push with --no-strict
315
raise errors.OutOfDateTree(
316
source_wt, more='Use --no-strict to force the push.')
298
317
stored_loc = source_branch.get_push_location()
299
318
if location is None:
300
319
if stored_loc is None: