~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/foreign.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-02 18:01:05 UTC
  • mfrom: (4724.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20091002180105-oeomf71t7l9gpv6g
(vila) Add a --strict option to dpush

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
294
300
        except NoWorkingTree:
295
301
            source_branch = Branch.open(directory)
296
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(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: