/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Andrew Bennetts
  • Date: 2008-05-27 04:12:56 UTC
  • mto: (3801.1.1 autopack-rpc)
  • mto: This revision was merged to the branch mainline in revision 3814.
  • Revision ID: andrew.bennetts@canonical.com-20080527041256-uuyg3kjmab9zc3gl
Experimental PackRepository.{check_references,autopack} RPCs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
# across to run on the server.
19
19
 
20
20
import bz2
21
 
from cStringIO import StringIO
22
21
 
23
22
from bzrlib import (
24
23
    branch,
32
31
)
33
32
from bzrlib.branch import BranchReferenceFormat
34
33
from bzrlib.bzrdir import BzrDir, RemoteBzrDirFormat
35
 
from bzrlib.config import BranchConfig, TreeConfig
36
34
from bzrlib.decorators import needs_read_lock, needs_write_lock
37
35
from bzrlib.errors import (
38
36
    NoSuchRevision,
41
39
from bzrlib.lockable_files import LockableFiles
42
40
from bzrlib.pack import ContainerPushParser
43
41
from bzrlib.smart import client, vfs
 
42
from bzrlib.repofmt.pack_repo import Packer
44
43
from bzrlib.repository import InterRepository
45
44
from bzrlib.revision import ensure_null, NULL_REVISION
46
45
from bzrlib.trace import mutter, note, warning
310
309
 
311
310
    __repr__ = __str__
312
311
 
 
312
    @property
 
313
    def _pack_collection(self):
 
314
        # XXX: this seems a bit evil...
 
315
        self._ensure_real()
 
316
        return self._real_repository._pack_collection
 
317
 
313
318
    def abort_write_group(self):
314
319
        """Complete a write group on the decorated repository.
315
320
        
830
835
                        len(parent_map))
831
836
            ancestry.update(parent_map)
832
837
        present_keys = [k for k in keys if k in ancestry]
833
 
        if 'hpss' in debug.debug_flags:
 
838
        if 'hpss' in debug.debug_flags and False:
834
839
            if self._requested_parents is not None and len(ancestry) != 0:
835
840
                self._requested_parents.update(present_keys)
836
841
                mutter('Current RemoteRepository graph hit rate: %d%%',
1166
1171
        count = str(recipe[2])
1167
1172
        return '\n'.join((start_keys, stop_keys, count))
1168
1173
 
 
1174
    def autopack(self):
 
1175
        path = self.bzrdir._path_for_remote_call(self._client)
 
1176
        self._client.call('PackRepository.autopack', path)
 
1177
 
 
1178
 
 
1179
class RemotePacker(Packer):
 
1180
 
 
1181
    def __init__(self, path, client, pack_collection, packs, suffix, revision_ids=None):
 
1182
        self.path = path
 
1183
        self.client = client
 
1184
        #self._real_packer = real_packer
 
1185
        Packer.__init__(self, pack_collection, packs, suffix, revision_ids)
 
1186
 
 
1187
    def _check_references(self):
 
1188
        external_refs = self.new_pack._external_compression_parents_of_texts()
 
1189
        if external_refs:
 
1190
            try:
 
1191
                self.client.call(
 
1192
                    'PackRepository.check_references', self.path, 
 
1193
                    *external_refs)
 
1194
            except errors.ErrorFromSmartServer, err:
 
1195
                #import pdb; pdb.set_trace()
 
1196
                if err.error_verb == 'RevisionNotPresent':
 
1197
                    missing_revision_id, missing_file_id = err.error_args
 
1198
                    raise errors.RevisionNotPresent(
 
1199
                        missing_revision_id, missing_file_id)
 
1200
                raise
 
1201
 
 
1202
#    def __getattr__(self, name):
 
1203
#        return getattr(self._real_packer, name)
 
1204
 
 
1205
#    def _save_pack_names(self):
 
1206
#        XXX
 
1207
 
1169
1208
 
1170
1209
class RemoteBranchLockableFiles(LockableFiles):
1171
1210
    """A 'LockableFiles' implementation that talks to a smart server.
1460
1499
        response_tuple, response_handler = self._client.call_expecting_body(
1461
1500
            'Branch.revision_history', path)
1462
1501
        if response_tuple[0] != 'ok':
1463
 
            raise UnexpectedSmartServerResponse(response_tuple)
 
1502
            raise errors.UnexpectedSmartServerResponse(response_tuple)
1464
1503
        result = response_handler.read_body_bytes().split('\x00')
1465
1504
        if result == ['']:
1466
1505
            return []