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
64
65
_DEFAULT_SEARCH_DEPTH = 100
1843
1844
delta, new_revision_id, parents, basis_inv=basis_inv,
1844
1845
propagate_caches=propagate_caches)
1846
def add_revision(self, rev_id, rev, inv=None, config=None):
1848
return self._real_repository.add_revision(
1849
rev_id, rev, inv=inv, config=config)
1847
def add_revision(self, revision_id, rev, inv=None, config=None):
1848
_mod_revision.check_not_reserved_id(revision_id)
1849
if (config is not None and
1850
config.get('create_signatures') == _mod_config.SIGN_ALWAYS):
1852
inv = self.get_inventory(revision_id)
1853
tree = InventoryRevisionTree(self, inv, revision_id)
1854
testament = _mod_testament.Testament(rev, tree)
1855
plaintext = testament.as_short_text()
1856
self.store_revision_signature(
1857
gpg.GPGStrategy(config), plaintext, revision_id)
1858
key = (revision_id,)
1859
# check inventory present
1860
if not self.inventories.get_parent_map([key]):
1862
raise errors.WeaveRevisionNotPresent(revision_id,
1865
# yes, this is not suitable for adding with ghosts.
1866
rev.inventory_sha1 = self.add_inventory(revision_id, inv,
1869
rev.inventory_sha1 = self.inventories.get_sha1s([key])[key]
1870
if self._real_repository is not None:
1871
return self._real_repository.add_revision(
1872
revision_id, rev, inv, config)
1873
text = self._serializer.write_revision_to_string(rev)
1874
parents = tuple((parent,) for parent in rev.parent_ids)
1875
self._write_group_tokens, missing_keys = self._get_sink().insert_stream(
1876
[('revisions', [FulltextContentFactory(key, parents, None, text)])],
1877
self._format, self._write_group_tokens)
1851
1879
@needs_read_lock
1852
1880
def get_inventory(self, revision_id):
3236
3264
def _ensure_real(self):
3237
3265
self.branch._ensure_real()
3238
3266
if self._real_store is None:
3239
self._real_store = config.BranchStore(self.branch)
3267
self._real_store = _mod_config.BranchStore(self.branch)
3242
3270
class RemoteBranch(branch.Branch, _RpcHelper, lock._RelockDebugMixin):
3941
3969
value = section_obj.get(name, default)
3942
3970
except errors.UnknownSmartMethod:
3943
3971
value = self._vfs_get_option(name, section, default)
3944
for hook in config.OldConfigHooks['get']:
3972
for hook in _mod_config.OldConfigHooks['get']:
3945
3973
hook(self, name, value)
3949
3977
if len(response[0]) and response[0][0] != 'ok':
3950
3978
raise errors.UnexpectedSmartServerResponse(response)
3951
3979
lines = response[1].read_body_bytes().splitlines()
3952
conf = config.ConfigObj(lines, encoding='utf-8')
3953
for hook in config.OldConfigHooks['load']:
3980
conf = _mod_config.ConfigObj(lines, encoding='utf-8')
3981
for hook in _mod_config.OldConfigHooks['load']: