59
59
from bzrlib.repository import RepositoryWriteLockResult, _LazyListJoin
60
60
from bzrlib.serializer import format_registry as serializer_format_registry
61
61
from bzrlib.trace import mutter, note, warning, log_exception_quietly
62
from bzrlib.versionedfile import ChunkedContentFactory, FulltextContentFactory
62
from bzrlib.versionedfile import FulltextContentFactory
65
65
_DEFAULT_SEARCH_DEPTH = 100
114
114
supports_workingtrees = False
116
colocated_branches = False
116
118
def __init__(self):
117
119
_mod_bzrdir.BzrDirMetaFormat1.__init__(self)
118
120
# XXX: It's a bit ugly that the network name is here, because we'd
626
628
def create_branch(self, name=None, repository=None,
627
629
append_revisions_only=None):
631
name = self._get_selected_branch()
633
raise errors.NoColocatedBranchSupport(self)
628
634
# as per meta1 formats - just delegate to the format object which may
629
635
# be parameterised.
630
636
real_branch = self._format.get_branch_format().initialize(self,
650
656
def destroy_branch(self, name=None):
651
657
"""See BzrDir.destroy_branch"""
659
name = self._get_selected_branch()
661
raise errors.NoColocatedBranchSupport(self)
652
662
path = self._path_for_remote_call(self._client)
677
687
b = self.open_branch(name=name)
690
def get_branches(self, possible_transports=None, ignore_fallbacks=False):
691
path = self._path_for_remote_call(self._client)
693
response, handler = self._call_expecting_body(
694
'BzrDir.get_branches', path)
695
except errors.UnknownSmartMethod:
697
return self._real_bzrdir.get_branches()
698
if response[0] != "success":
699
raise errors.UnexpectedSmartServerResponse(response)
700
body = bencode.bdecode(handler.read_body_bytes())
702
for (name, value) in body.iteritems():
703
ret[name] = self._open_branch(name, value[0], value[1],
704
possible_transports=possible_transports,
705
ignore_fallbacks=ignore_fallbacks)
708
def set_branch_reference(self, target_branch, name=None):
709
"""See BzrDir.set_branch_reference()."""
711
name = self._get_selected_branch()
713
raise errors.NoColocatedBranchSupport(self)
715
return self._real_bzrdir.set_branch_reference(target_branch, name=name)
680
717
def get_branch_reference(self, name=None):
681
718
"""See BzrDir.get_branch_reference()."""
683
# XXX JRV20100304: Support opening colocated branches
720
name = self._get_selected_branch()
684
722
raise errors.NoColocatedBranchSupport(self)
685
723
response = self._get_branch_reference()
686
724
if response[0] == 'ref':
722
760
"""See BzrDir._get_tree_branch()."""
723
761
return None, self.open_branch(name=name)
725
def open_branch(self, name=None, unsupported=False,
726
ignore_fallbacks=False, possible_transports=None):
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
734
response = self._get_branch_reference()
735
if response[0] == 'ref':
763
def _open_branch(self, name, kind, location_or_format,
764
ignore_fallbacks=False, possible_transports=None):
736
766
# a branch reference, use the existing BranchReference logic.
737
767
format = BranchReferenceFormat()
738
768
return format.open(self, name=name, _found=True,
739
location=response[1], ignore_fallbacks=ignore_fallbacks,
769
location=location_or_format, ignore_fallbacks=ignore_fallbacks,
740
770
possible_transports=possible_transports)
741
branch_format_name = response[1]
771
branch_format_name = location_or_format
742
772
if not branch_format_name:
743
773
branch_format_name = None
744
774
format = RemoteBranchFormat(network_name=branch_format_name)
746
776
setup_stacking=not ignore_fallbacks, name=name,
747
777
possible_transports=possible_transports)
779
def open_branch(self, name=None, unsupported=False,
780
ignore_fallbacks=False, possible_transports=None):
782
name = self._get_selected_branch()
784
raise errors.NoColocatedBranchSupport(self)
786
raise NotImplementedError('unsupported flag support not implemented yet.')
787
if self._next_open_branch_result is not None:
788
# See create_branch for details.
789
result = self._next_open_branch_result
790
self._next_open_branch_result = None
792
response = self._get_branch_reference()
793
return self._open_branch(name, response[0], response[1],
794
possible_transports=possible_transports,
795
ignore_fallbacks=ignore_fallbacks)
749
797
def _open_repo_v1(self, path):
750
798
verb = 'BzrDir.find_repository'
751
799
response = self._call(verb, path)
3089
3137
if isinstance(a_bzrdir, RemoteBzrDir):
3090
3138
a_bzrdir._ensure_real()
3091
3139
result = self._custom_format.initialize(a_bzrdir._real_bzrdir,
3092
name, append_revisions_only=append_revisions_only)
3140
name=name, append_revisions_only=append_revisions_only)
3094
3142
# We assume the bzrdir is parameterised; it may not be.
3095
result = self._custom_format.initialize(a_bzrdir, name,
3143
result = self._custom_format.initialize(a_bzrdir, name=name,
3096
3144
append_revisions_only=append_revisions_only)
3097
3145
if (isinstance(a_bzrdir, RemoteBzrDir) and
3098
3146
not isinstance(result, RemoteBranch)):
3103
3151
def initialize(self, a_bzrdir, name=None, repository=None,
3104
3152
append_revisions_only=None):
3154
name = a_bzrdir._get_selected_branch()
3105
3155
# 1) get the network name to use.
3106
3156
if self._custom_format:
3107
3157
network_name = self._custom_format.network_name()
3122
3172
# Creating on a remote bzr dir.
3123
3173
# 2) try direct creation via RPC
3124
3174
path = a_bzrdir._path_for_remote_call(a_bzrdir._client)
3125
if name is not None:
3126
3176
# XXX JRV20100304: Support creating colocated branches
3127
3177
raise errors.NoColocatedBranchSupport(self)
3128
3178
verb = 'BzrDir.create_branch'