~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/foreign.py

MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
271
271
    """
272
272
    hidden = True
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.',
277
 
            short_name='d',
278
 
            type=unicode,
279
 
            ),
280
 
            Option('no-rebase', help="Do not rebase after push.")]
 
274
    takes_options = [
 
275
        'remember',
 
276
        Option('directory',
 
277
               help='Branch to push from, '
 
278
               'rather than the one containing the working directory.',
 
279
               short_name='d',
 
280
               type=unicode,
 
281
               ),
 
282
        Option('no-rebase', help="Do not rebase after push."),
 
283
        Option('strict',
 
284
               help='Refuse to push if there are uncommitted changes in'
 
285
               ' the working tree, --no-strict disables the check.'),
 
286
        ]
281
287
 
282
 
    def run(self, location=None, remember=False, directory=None, 
283
 
            no_rebase=False):
 
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
289
294
 
290
295
        if directory is None:
295
300
        except NoWorkingTree:
296
301
            source_branch = Branch.open(directory)
297
302
            source_wt = None
 
303
        if strict is None:
 
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: