~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Vincent Ladeuil
  • Date: 2009-06-10 12:38:51 UTC
  • mto: (4452.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4453.
  • Revision ID: v.ladeuil+lp@free.fr-20090610123851-ftix8vy3p054jlwn
Fix bug #284038 by adding a --strict option to push.

* tests/branch_implementations/test_push.py:
(EmptyPushSmartEffortTests.test_empty_branch_command): Fix
semi-unrelated get_url() misuse.

* tests/blackbox/test_push.py:
(TestPushRedirect.test_push_gracefully_handles_too_many_redirects):
Test push command behavior with respect to uncommitted changes and
--strict option.

* builtins.py:
(cmd_push): Add a '--strict' option to check uncommitted changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1021
1021
                'for the commit history. Only the work not present in the '
1022
1022
                'referenced branch is included in the branch created.',
1023
1023
            type=unicode),
 
1024
        Option('strict',
 
1025
               help='Refuse to push if there are uncommitted changes in'
 
1026
               ' the working tree.'),
1024
1027
        ]
1025
1028
    takes_args = ['location?']
1026
1029
    encoding_type = 'replace'
1028
1031
    def run(self, location=None, remember=False, overwrite=False,
1029
1032
        create_prefix=False, verbose=False, revision=None,
1030
1033
        use_existing_dir=False, directory=None, stacked_on=None,
1031
 
        stacked=False):
 
1034
        stacked=False, strict=None):
1032
1035
        from bzrlib.push import _show_push_branch
1033
1036
 
1034
 
        # Get the source branch and revision_id
1035
1037
        if directory is None:
1036
1038
            directory = '.'
1037
 
        br_from = Branch.open_containing(directory)[0]
 
1039
        # Get the source branch
 
1040
        tree, br_from = bzrdir.BzrDir.open_tree_or_branch(directory)
 
1041
        if strict is None:
 
1042
            strict = br_from.get_config().get_user_option('push_strict')
 
1043
        if strict:
 
1044
            changes = tree.changes_from(tree.basis_tree())
 
1045
            if changes.has_changed():
 
1046
                raise errors.UncommittedChanges(tree)
 
1047
        # Get the tip's revision_id
1038
1048
        revision = _get_one_revision('push', revision)
1039
1049
        if revision is not None:
1040
1050
            revision_id = revision.in_history(br_from).rev_id