~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-16 06:51:36 UTC
  • mfrom: (4144.3.5 simplify-interrepo-stack)
  • Revision ID: pqm@pqm.ubuntu.com-20090316065136-1g3udxbvvlgtsbup
(andrew) Add RPC that can insert a stream into older (i.e. lockable)
        repository formats.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1522
1522
        return result
1523
1523
 
1524
1524
    def insert_stream(self, stream, src_format, resume_tokens):
1525
 
        repo = self.target_repo
1526
 
        client = repo._client
 
1525
        target = self.target_repo
 
1526
        if target._lock_token:
 
1527
            verb = 'Repository.insert_stream_locked'
 
1528
            extra_args = (target._lock_token or '',)
 
1529
            required_version = (1, 14)
 
1530
        else:
 
1531
            verb = 'Repository.insert_stream'
 
1532
            extra_args = ()
 
1533
            required_version = (1, 13)
 
1534
        client = target._client
1527
1535
        medium = client._medium
1528
 
        if medium._is_remote_before((1, 13)):
 
1536
        if medium._is_remote_before(required_version):
1529
1537
            # No possible way this can work.
1530
1538
            return self._insert_real(stream, src_format, resume_tokens)
1531
 
        path = repo.bzrdir._path_for_remote_call(client)
 
1539
        path = target.bzrdir._path_for_remote_call(client)
1532
1540
        if not resume_tokens:
1533
1541
            # XXX: Ugly but important for correctness, *will* be fixed during
1534
1542
            # 1.13 cycle. Pushing a stream that is interrupted results in a
1541
1549
            byte_stream = smart_repo._stream_to_byte_stream([], src_format)
1542
1550
            try:
1543
1551
                response = client.call_with_body_stream(
1544
 
                    ('Repository.insert_stream', path, ''), byte_stream)
 
1552
                    (verb, path, '') + extra_args, byte_stream)
1545
1553
            except errors.UnknownSmartMethod:
1546
 
                medium._remember_remote_is_before((1,13))
 
1554
                medium._remember_remote_is_before(required_version)
1547
1555
                return self._insert_real(stream, src_format, resume_tokens)
1548
1556
        byte_stream = smart_repo._stream_to_byte_stream(
1549
1557
            stream, src_format)
1550
1558
        resume_tokens = ' '.join(resume_tokens)
1551
1559
        response = client.call_with_body_stream(
1552
 
            ('Repository.insert_stream', path, resume_tokens), byte_stream)
 
1560
            (verb, path, resume_tokens) + extra_args, byte_stream)
1553
1561
        if response[0][0] not in ('ok', 'missing-basis'):
1554
1562
            raise errors.UnexpectedSmartServerResponse(response)
1555
1563
        if response[0][0] == 'missing-basis':