14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
from __future__ import absolute_import
57
59
from bzrlib.repository import RepositoryWriteLockResult, _LazyListJoin
58
60
from bzrlib.serializer import format_registry as serializer_format_registry
59
61
from bzrlib.trace import mutter, note, warning, log_exception_quietly
62
from bzrlib.versionedfile import ChunkedContentFactory, FulltextContentFactory
62
65
_DEFAULT_SEARCH_DEPTH = 100
478
481
warning('VFS BzrDir access triggered\n%s',
479
482
''.join(traceback.format_stack()))
480
483
self._real_bzrdir = _mod_bzrdir.BzrDir.open_from_transport(
481
self.root_transport, _server_formats=False)
484
self.root_transport, probers=[_mod_bzrdir.BzrProber])
482
485
self._format._network_name = \
483
486
self._real_bzrdir._format.network_name()
1763
1768
def get_commit_builder(self, branch, parents, config, timestamp=None,
1764
1769
timezone=None, committer=None, revprops=None,
1765
1770
revision_id=None, lossy=False):
1766
# FIXME: It ought to be possible to call this without immediately
1767
# triggering _ensure_real. For now it's the easiest thing to do.
1769
real_repo = self._real_repository
1770
builder = real_repo.get_commit_builder(branch, parents,
1771
config, timestamp=timestamp, timezone=timezone,
1772
committer=committer, revprops=revprops,
1773
revision_id=revision_id, lossy=lossy)
1771
"""Obtain a CommitBuilder for this repository.
1773
:param branch: Branch to commit to.
1774
:param parents: Revision ids of the parents of the new revision.
1775
:param config: Configuration to use.
1776
:param timestamp: Optional timestamp recorded for commit.
1777
:param timezone: Optional timezone for timestamp.
1778
:param committer: Optional committer to set for commit.
1779
:param revprops: Optional dictionary of revision properties.
1780
:param revision_id: Optional revision id.
1781
:param lossy: Whether to discard data that can not be natively
1782
represented, when pushing to a foreign VCS
1784
if self._fallback_repositories and not self._format.supports_chks:
1785
raise errors.BzrError("Cannot commit directly to a stacked branch"
1786
" in pre-2a formats. See "
1787
"https://bugs.launchpad.net/bzr/+bug/375013 for details.")
1788
if self._format.rich_root_data:
1789
commit_builder_kls = vf_repository.VersionedFileRootCommitBuilder
1791
commit_builder_kls = vf_repository.VersionedFileCommitBuilder
1792
result = commit_builder_kls(self, parents, config,
1793
timestamp, timezone, committer, revprops, revision_id,
1795
self.start_write_group()
1776
1798
def add_fallback_repository(self, repository):
1777
1799
"""Add a repository to use for looking up data not held locally.
1822
1844
delta, new_revision_id, parents, basis_inv=basis_inv,
1823
1845
propagate_caches=propagate_caches)
1825
def add_revision(self, rev_id, rev, inv=None, config=None):
1827
return self._real_repository.add_revision(
1828
rev_id, rev, inv=inv, config=config)
1847
def add_revision(self, revision_id, rev, inv=None):
1848
_mod_revision.check_not_reserved_id(revision_id)
1849
key = (revision_id,)
1850
# check inventory present
1851
if not self.inventories.get_parent_map([key]):
1853
raise errors.WeaveRevisionNotPresent(revision_id,
1856
# yes, this is not suitable for adding with ghosts.
1857
rev.inventory_sha1 = self.add_inventory(revision_id, inv,
1860
rev.inventory_sha1 = self.inventories.get_sha1s([key])[key]
1861
self._add_revision(rev)
1863
def _add_revision(self, rev):
1864
if self._real_repository is not None:
1865
return self._real_repository._add_revision(rev)
1866
text = self._serializer.write_revision_to_string(rev)
1867
key = (rev.revision_id,)
1868
parents = tuple((parent,) for parent in rev.parent_ids)
1869
self._write_group_tokens, missing_keys = self._get_sink().insert_stream(
1870
[('revisions', [FulltextContentFactory(key, parents, None, text)])],
1871
self._format, self._write_group_tokens)
1830
1873
@needs_read_lock
1831
1874
def get_inventory(self, revision_id):
1992
2035
if self._real_repository is not None:
1993
2036
self._real_repository.refresh_data()
2037
# Refresh the parents cache for this object
2038
self._unstacked_provider.disable_cache()
2039
self._unstacked_provider.enable_cache()
1995
2041
def revision_ids_to_search_result(self, result_set):
1996
2042
"""Convert a set of revision ids to a graph SearchResult."""
3212
3258
def _ensure_real(self):
3213
3259
self.branch._ensure_real()
3214
3260
if self._real_store is None:
3215
self._real_store = config.BranchStore(self.branch)
3261
self._real_store = _mod_config.BranchStore(self.branch)
3218
3264
class RemoteBranch(branch.Branch, _RpcHelper, lock._RelockDebugMixin):
3917
3963
value = section_obj.get(name, default)
3918
3964
except errors.UnknownSmartMethod:
3919
3965
value = self._vfs_get_option(name, section, default)
3920
for hook in config.OldConfigHooks['get']:
3966
for hook in _mod_config.OldConfigHooks['get']:
3921
3967
hook(self, name, value)
3925
3971
if len(response[0]) and response[0][0] != 'ok':
3926
3972
raise errors.UnexpectedSmartServerResponse(response)
3927
3973
lines = response[1].read_body_bytes().splitlines()
3928
conf = config.ConfigObj(lines, encoding='utf-8')
3929
for hook in config.OldConfigHooks['load']:
3974
conf = _mod_config.ConfigObj(lines, encoding='utf-8')
3975
for hook in _mod_config.OldConfigHooks['load']: