~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

Merge bzr.dev and tree-file-ids-as-tuples.

Show diffs side-by-side

added added

removed removed

Lines of Context:
625
625
 
626
626
    def create_branch(self, name=None, repository=None,
627
627
                      append_revisions_only=None):
 
628
        if name is None:
 
629
            name = self._get_selected_branch()
628
630
        # as per meta1 formats - just delegate to the format object which may
629
631
        # be parameterised.
630
632
        real_branch = self._format.get_branch_format().initialize(self,
677
679
        b = self.open_branch(name=name)
678
680
        return b._format
679
681
 
 
682
    def get_branches(self, possible_transports=None, ignore_fallbacks=False):
 
683
        path = self._path_for_remote_call(self._client)
 
684
        try:
 
685
            response, handler = self._call_expecting_body(
 
686
                'BzrDir.get_branches', path)
 
687
        except errors.UnknownSmartMethod:
 
688
            self._ensure_real()
 
689
            return self._real_bzrdir.get_branches()
 
690
        if response[0] != "success":
 
691
            raise errors.UnexpectedSmartServerResponse(response)
 
692
        body = bencode.bdecode(handler.read_body_bytes())
 
693
        ret = {}
 
694
        for (name, value) in body.iteritems():
 
695
            ret[name] = self._open_branch(name, value[0], value[1],
 
696
                possible_transports=possible_transports,
 
697
                ignore_fallbacks=ignore_fallbacks)
 
698
        return ret
 
699
 
 
700
    def set_branch_reference(self, target_branch, name=None):
 
701
        """See BzrDir.set_branch_reference()."""
 
702
        self._ensure_real()
 
703
        return self._real_bzrdir.set_branch_reference(target_branch, name=name)
 
704
 
680
705
    def get_branch_reference(self, name=None):
681
706
        """See BzrDir.get_branch_reference()."""
682
707
        if name is not None:
722
747
        """See BzrDir._get_tree_branch()."""
723
748
        return None, self.open_branch(name=name)
724
749
 
725
 
    def open_branch(self, name=None, unsupported=False,
726
 
                    ignore_fallbacks=False, possible_transports=None):
727
 
        if unsupported:
728
 
            raise NotImplementedError('unsupported flag support not implemented yet.')
729
 
        if self._next_open_branch_result is not None:
730
 
            # See create_branch for details.
731
 
            result = self._next_open_branch_result
732
 
            self._next_open_branch_result = None
733
 
            return result
734
 
        response = self._get_branch_reference()
735
 
        if response[0] == 'ref':
 
750
    def _open_branch(self, name, kind, location_or_format,
 
751
                     ignore_fallbacks=False, possible_transports=None):
 
752
        if kind == 'ref':
736
753
            # a branch reference, use the existing BranchReference logic.
737
754
            format = BranchReferenceFormat()
738
755
            return format.open(self, name=name, _found=True,
739
 
                location=response[1], ignore_fallbacks=ignore_fallbacks,
 
756
                location=location_or_format, ignore_fallbacks=ignore_fallbacks,
740
757
                possible_transports=possible_transports)
741
 
        branch_format_name = response[1]
 
758
        branch_format_name = location_or_format
742
759
        if not branch_format_name:
743
760
            branch_format_name = None
744
761
        format = RemoteBranchFormat(network_name=branch_format_name)
746
763
            setup_stacking=not ignore_fallbacks, name=name,
747
764
            possible_transports=possible_transports)
748
765
 
 
766
    def open_branch(self, name=None, unsupported=False,
 
767
                    ignore_fallbacks=False, possible_transports=None):
 
768
        if unsupported:
 
769
            raise NotImplementedError('unsupported flag support not implemented yet.')
 
770
        if self._next_open_branch_result is not None:
 
771
            # See create_branch for details.
 
772
            result = self._next_open_branch_result
 
773
            self._next_open_branch_result = None
 
774
            return result
 
775
        response = self._get_branch_reference()
 
776
        if name is None:
 
777
            name = self._get_selected_branch()
 
778
        return self._open_branch(name, response[0], response[1],
 
779
            possible_transports=possible_transports,
 
780
            ignore_fallbacks=ignore_fallbacks)
 
781
 
749
782
    def _open_repo_v1(self, path):
750
783
        verb = 'BzrDir.find_repository'
751
784
        response = self._call(verb, path)
3102
3135
 
3103
3136
    def initialize(self, a_bzrdir, name=None, repository=None,
3104
3137
                   append_revisions_only=None):
 
3138
        if name is None:
 
3139
            name = a_bzrdir._get_selected_branch()
3105
3140
        # 1) get the network name to use.
3106
3141
        if self._custom_format:
3107
3142
            network_name = self._custom_format.network_name()
3122
3157
        # Creating on a remote bzr dir.
3123
3158
        # 2) try direct creation via RPC
3124
3159
        path = a_bzrdir._path_for_remote_call(a_bzrdir._client)
3125
 
        if name is not None:
 
3160
        if name != "":
3126
3161
            # XXX JRV20100304: Support creating colocated branches
3127
3162
            raise errors.NoColocatedBranchSupport(self)
3128
3163
        verb = 'BzrDir.create_branch'