~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Allow push --shallow to just work, and fix the testing HTTPServer to not be affected by chdir() calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
702
702
                'for the commit history. Only the work not present in that '
703
703
                'other branch is included in this shallow branch.',
704
704
            type=unicode),
 
705
        Option('shallow',
 
706
            help='Create a shallow branch with an automatic reference url. '
 
707
                'The chosen url is the parent branches public location. See '
 
708
                '--reference for more information.'),
705
709
        ]
706
710
    takes_args = ['location?']
707
711
    encoding_type = 'replace'
708
712
 
709
713
    def run(self, location=None, remember=False, overwrite=False,
710
714
        create_prefix=False, verbose=False, use_existing_dir=False,
711
 
        directory=None, reference=None):
 
715
        directory=None, reference=None, shallow=False):
712
716
        # FIXME: Way too big!  Put this into a function called from the
713
717
        # command.
714
718
        if directory is None:
715
719
            directory = '.'
 
720
        br_from = Branch.open_containing(directory)[0]
 
721
        # shallow branch where to refer to logic:
716
722
        if reference is not None:
717
723
            reference = urlutils.normalize_url(reference)
718
 
        br_from = Branch.open_containing(directory)[0]
 
724
        if shallow:
 
725
            parent = Branch.open(br_from.get_parent())
 
726
            reference = parent.get_public_branch()
 
727
        # where to push logic:
719
728
        stored_loc = br_from.get_push_location()
720
729
        if location is None:
721
730
            if stored_loc is None: