/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/smart/repository.py

  • Committer: Andrew Bennetts
  • Date: 2009-03-16 04:48:09 UTC
  • mto: This revision was merged to the branch mainline in revision 4148.
  • Revision ID: andrew.bennetts@canonical.com-20090316044809-0bsw43pof8fq7byl
Add Repository.insert_stream_locked server-side implementation, plus tests for server-side _translate_error.

Show diffs side-by-side

added added

removed removed

Lines of Context:
524
524
            tarball.close()
525
525
 
526
526
 
527
 
class SmartServerRepositoryInsertStream(SmartServerRepositoryRequest):
 
527
class SmartServerRepositoryInsertStreamLocked(SmartServerRepositoryRequest):
528
528
    """Insert a record stream from a RemoteSink into a repository.
529
529
 
530
530
    This gets bytes pushed to it by the network infrastructure and turns that
531
531
    into a bytes iterator using a thread. That is then processed by
532
532
    _byte_stream_to_stream.
 
533
 
 
534
    New in 1.14.
533
535
    """
534
536
 
535
 
    def do_repository_request(self, repository, resume_tokens):
 
537
    def do_repository_request(self, repository, resume_tokens, lock_token):
536
538
        """StreamSink.insert_stream for a remote repository."""
537
 
        repository.lock_write()
 
539
        repository.lock_write(token=lock_token)
 
540
        self.do_insert_stream_request(repository, resume_tokens)
 
541
 
 
542
    def do_insert_stream_request(self, repository, resume_tokens):
538
543
        tokens = [token for token in resume_tokens.split(' ') if token]
539
544
        self.tokens = tokens
540
545
        self.repository = repository
582
587
        else:
583
588
            self.repository.unlock()
584
589
            return SuccessfulSmartServerResponse(('ok', ))
 
590
 
 
591
 
 
592
class SmartServerRepositoryInsertStream(SmartServerRepositoryInsertStreamLocked):
 
593
    """Insert a record stream from a RemoteSink into an unlocked repository.
 
594
 
 
595
    This gets bytes pushed to it by the network infrastructure and turns that
 
596
    into a bytes iterator using a thread. That is then processed by
 
597
    _byte_stream_to_stream.
 
598
 
 
599
    This is the same as SmartServerRepositoryInsertStreamLocked, except it
 
600
    takes no lock_tokens; i.e. it works with an unlocked (or lock-free, e.g.
 
601
    like pack format) repository.
 
602
 
 
603
    New in 1.13.
 
604
    """
 
605
 
 
606
    def do_repository_request(self, repository, resume_tokens):
 
607
        """StreamSink.insert_stream for a remote repository."""
 
608
        repository.lock_write()
 
609
        self.do_insert_stream_request(repository, resume_tokens)
 
610
 
 
611