~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Robert Collins
  • Date: 2008-02-03 22:55:08 UTC
  • mto: This revision was merged to the branch mainline in revision 3216.
  • Revision ID: robertc@robertcollins.net-20080203225508-0rogbg0ggonuqfhp
Change the smart server get_parents method to take a graph search to exclude already recieved parents from. This prevents history shortcuts causing huge numbers of duplicates.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
from bzrlib.smart.client import _SmartClient
47
47
from bzrlib.transport.memory import MemoryTransport
48
48
from bzrlib.transport.remote import RemoteTransport
 
49
from bzrlib.tuned_gzip import bytes_to_gzip
49
50
 
50
51
 
51
52
class BasicRemoteObjectTests(tests.TestCaseWithTransport):
608
609
        r1 = u'\u0e33'.encode('utf8')
609
610
        r2 = u'\u0dab'.encode('utf8')
610
611
        lines = [' '.join([r2, r1]), r1]
611
 
        encoded_body = '\n'.join(lines)
 
612
        encoded_body = bytes_to_gzip('\n'.join(lines))
612
613
        responses = [(('ok', ), encoded_body), (('ok', ), encoded_body)]
613
614
 
614
615
        transport_path = 'quack'
624
625
        parents = graph.get_parent_map([r1])
625
626
        self.assertEqual({r1: (NULL_REVISION,)}, parents)
626
627
        self.assertEqual(
627
 
            [('call_expecting_body', 'Repository.get_parent_map',
628
 
             ('quack/', r2))],
 
628
            [('call_with_body_bytes_expecting_body',
 
629
              'Repository.get_parent_map', ('quack/', r2), '\n\n0')],
629
630
            client._calls)
630
631
        repo.unlock()
631
632
        # now we call again, and it should use the second response.
634
635
        parents = graph.get_parent_map([r1])
635
636
        self.assertEqual({r1: (NULL_REVISION,)}, parents)
636
637
        self.assertEqual(
637
 
            [('call_expecting_body', 'Repository.get_parent_map',
638
 
              ('quack/', r2)),
639
 
             ('call_expecting_body', 'Repository.get_parent_map',
640
 
              ('quack/', r1))
 
638
            [('call_with_body_bytes_expecting_body',
 
639
              'Repository.get_parent_map', ('quack/', r2), '\n\n0'),
 
640
             ('call_with_body_bytes_expecting_body',
 
641
              'Repository.get_parent_map', ('quack/', r1), '\n\n0'),
641
642
            ],
642
643
            client._calls)
643
644
        repo.unlock()