~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Patch Queue Manager
  • Date: 2012-01-03 17:44:03 UTC
  • mfrom: (6362.6.3 hpss-add-revision)
  • Revision ID: pqm@pqm.ubuntu.com-20120103174403-a1g6m9e6m95515uk
(jelmer) Add RemoteRepository.add_revision. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    bencode,
24
24
    branch,
25
25
    bzrdir as _mod_bzrdir,
26
 
    config,
 
26
    config as _mod_config,
27
27
    controldir,
28
28
    debug,
29
29
    errors,
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
63
 
63
64
 
64
65
_DEFAULT_SEARCH_DEPTH = 100
348
349
        _mod_bzrdir.BzrDirMetaFormat1._set_repository_format) #.im_func)
349
350
 
350
351
 
351
 
class RemoteControlStore(config.IniFileStore):
 
352
class RemoteControlStore(_mod_config.IniFileStore):
352
353
    """Control store which attempts to use HPSS calls to retrieve control store.
353
354
 
354
355
    Note that this is specific to bzr-based formats.
378
379
    def _ensure_real(self):
379
380
        self.bzrdir._ensure_real()
380
381
        if self._real_store is None:
381
 
            self._real_store = config.ControlStore(self.bzrdir)
 
382
            self._real_store = _mod_config.ControlStore(self.bzrdir)
382
383
 
383
384
    def external_url(self):
384
385
        return self.bzrdir.user_url
1843
1844
            delta, new_revision_id, parents, basis_inv=basis_inv,
1844
1845
            propagate_caches=propagate_caches)
1845
1846
 
1846
 
    def add_revision(self, rev_id, rev, inv=None, config=None):
1847
 
        self._ensure_real()
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):
 
1851
            if inv is None:
 
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]):
 
1861
            if inv is None:
 
1862
                raise errors.WeaveRevisionNotPresent(revision_id,
 
1863
                                                     self.inventories)
 
1864
            else:
 
1865
                # yes, this is not suitable for adding with ghosts.
 
1866
                rev.inventory_sha1 = self.add_inventory(revision_id, inv,
 
1867
                                                        rev.parent_ids)
 
1868
        else:
 
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)
1850
1878
 
1851
1879
    @needs_read_lock
1852
1880
    def get_inventory(self, revision_id):
3178
3206
        return False
3179
3207
 
3180
3208
 
3181
 
class RemoteBranchStore(config.IniFileStore):
 
3209
class RemoteBranchStore(_mod_config.IniFileStore):
3182
3210
    """Branch store which attempts to use HPSS calls to retrieve branch store.
3183
3211
 
3184
3212
    Note that this is specific to bzr-based formats.
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)
3240
3268
 
3241
3269
 
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)
3946
3974
        return value
3947
3975
 
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']:
3954
3982
            hook(self)
3955
3983
        return conf
3956
3984