200
203
if (result_repo.user_url == result.user_url
201
204
and not require_stacking and
202
205
revision_id is not None):
203
fetch_spec = graph.PendingAncestryResult(
206
fetch_spec = vf_search.PendingAncestryResult(
204
207
[revision_id], local_repo)
205
208
result_repo.fetch(local_repo, fetch_spec=fetch_spec)
850
853
This might be a synthetic object for e.g. RemoteBranch and SVN.
852
from bzrlib.branch import BranchFormat
853
return BranchFormat.find_format(self, name=name)
855
from bzrlib.branch import BranchFormatMetadir
856
return BranchFormatMetadir.find_format(self, name=name)
855
858
def _get_mkdir_mode(self):
856
859
"""Figure out the mode to use when creating a bzrdir subdir."""
861
864
def get_branch_reference(self, name=None):
862
865
"""See BzrDir.get_branch_reference()."""
863
from bzrlib.branch import BranchFormat
864
format = BranchFormat.find_format(self, name=name)
866
from bzrlib.branch import BranchFormatMetadir
867
format = BranchFormatMetadir.find_format(self, name=name)
865
868
return format.get_reference(self, name=name)
867
870
def get_branch_transport(self, branch_format, name=None):
916
919
Note: if you're going to open the working tree, you should just go
917
920
ahead and try, and not ask permission first.
919
from bzrlib.workingtree import WorkingTreeFormat
922
from bzrlib.workingtree import WorkingTreeFormatMetaDir
921
WorkingTreeFormat.find_format_string(self)
924
WorkingTreeFormatMetaDir.find_format_string(self)
922
925
except errors.NoWorkingTree:
966
969
def open_repository(self, unsupported=False):
967
970
"""See BzrDir.open_repository."""
968
from bzrlib.repository import RepositoryFormat
969
format = RepositoryFormat.find_format(self)
971
from bzrlib.repository import RepositoryFormatMetaDir
972
format = RepositoryFormatMetaDir.find_format(self)
970
973
format.check_support_status(unsupported)
971
974
return format.open(self, _found=True)
973
976
def open_workingtree(self, unsupported=False,
974
977
recommend_upgrade=True):
975
978
"""See BzrDir.open_workingtree."""
976
from bzrlib.workingtree import WorkingTreeFormat
977
format = WorkingTreeFormat.find_format(self)
979
from bzrlib.workingtree import WorkingTreeFormatMetaDir
980
format = WorkingTreeFormatMetaDir.find_format(self)
978
981
format.check_support_status(unsupported, recommend_upgrade,
979
982
basedir=self.root_transport.base)
980
983
return format.open(self, _found=True)
1053
1056
self.control_files.unlock()
1054
1057
self.transport.delete_tree(path)
1056
def list_branches(self):
1057
"""See ControlDir.list_branches."""
1059
def get_branches(self):
1060
"""See ControlDir.get_branches."""
1061
ret.append(self.open_branch())
1063
ret[None] = self.open_branch()
1062
1064
except (errors.NotBranchError, errors.NoRepositoryPresent):
1065
# colocated branches
1066
ret.extend([self.open_branch(name.decode("utf-8")) for name in
1067
self._read_branch_list()])
1067
for name in self._read_branch_list():
1068
ret[name] = self.open_branch(name.decode('utf-8'))
1101
1102
return self.transport.clone(path)
1105
class BzrDirMetaComponentFormat(controldir.ControlComponentFormat):
1106
"""Base class for all formats of things living in metadirs.
1108
This class manages the format string that is stored in the 'format'
1109
or 'branch-format' file.
1111
All classes for (branch-, repository-, workingtree-) formats that
1112
live in meta directories and have their own 'format' file
1113
(i.e. different from .bzr/branch-format) derive from this class,
1114
as well as the relevant base class for their kind
1115
(BranchFormat, WorkingTreeFormat, RepositoryFormat).
1119
def get_format_string(cls):
1120
"""Return the ASCII format string that identifies this format."""
1121
raise NotImplementedError(cls.get_format_string)
1124
def from_string(cls, format_string):
1125
if format_string != cls.get_format_string():
1126
raise ValueError("Invalid format header %r" % format_string)
1130
def _find_format(klass, registry, kind, format_string):
1132
cls = registry.get(format_string)
1134
raise errors.UnknownFormatError(format=format_string, kind=kind)
1137
def network_name(self):
1138
"""A simple byte string uniquely identifying this format for RPC calls.
1140
Metadir branch formats use their format string.
1142
return self.get_format_string()
1144
def __eq__(self, other):
1145
return (self.__class__ is other.__class__)
1104
1148
class BzrProber(controldir.Prober):
1105
1149
"""Prober for formats that use a .bzr/ control directory."""
1125
1169
except errors.NoSuchFile:
1126
1170
raise errors.NotBranchError(path=transport.base)
1128
return klass.formats.get(format_string)
1172
cls = klass.formats.get(format_string)
1129
1173
except KeyError:
1130
1174
raise errors.UnknownFormatError(format=format_string, kind='bzrdir')
1175
return cls.from_string(format_string)
1133
1178
def known_formats(cls):
1556
1601
"""See BzrDirFormat.get_format_description()."""
1557
1602
return "Meta directory format 1"
1605
def from_string(cls, format_string):
1606
if format_string != cls.get_format_string():
1607
raise ValueError("Invalid format string %r" % format_string)
1559
1610
def network_name(self):
1560
1611
return self.get_format_string()
1611
1662
def __set_workingtree_format(self, wt_format):
1612
1663
self._workingtree_format = wt_format
1666
return "<%r>" % (self.__class__.__name__,)
1614
1668
workingtree_format = property(__get_workingtree_format,
1615
1669
__set_workingtree_format)