~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_versionedfile.py

  • Committer: John Arbash Meinel
  • Date: 2010-08-10 20:03:44 UTC
  • mto: This revision was merged to the branch mainline in revision 5376.
  • Revision ID: john@arbash-meinel.com-20100810200344-6muerwvkafqu7w47
Rework things a bit so the logic can be shared.

It turns out that some of the peak memory is actually during the inventory
to string to bundle translations. So re-use the refcount logic there.
This actually does show a decrease in peak memory.
Specifically 'cd bzr.dev; bzr send ../2.2' drops from 221MB peak to 156MB.

We don't speed anything up (16.5s both ways), but peak memory is quite
a bit better.

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
        # It is returned, but we don't really care as we won't extract it
60
60
        self.assertEqual({('one',): 1}, refcount)
61
61
        self.assertEqual([('one',)], sorted(gen.ghost_parents))
 
62
        self.assertEqual([], sorted(gen.present_parents))
62
63
 
63
64
    def test_raises_on_ghost_keys(self):
64
65
        # If the requested key is a ghost, then we have a problem
74
75
        self.assertEqual(sorted([('one',), ('two',), ('three',)]),
75
76
                         sorted(needed_keys))
76
77
        self.assertEqual({('one',): 2, ('two',): 1}, refcount)
 
78
        self.assertEqual([('one',)], sorted(gen.present_parents))
77
79
 
78
80
    def test_process_contents(self):
79
81
        vf = self.make_three_vf()
90
92
        self.assertEqual(('one',), record.key)
91
93
        # one is not needed in the output, but it is needed by children. As
92
94
        # such, it should end up in the various caches
93
 
        gen._process_one_record(record)
 
95
        gen._process_one_record(record.key, record.get_bytes_as('chunked'))
94
96
        # The chunks should be cached, the refcount untouched
95
97
        self.assertEqual([('one',)], gen.chunks.keys())
96
98
        self.assertEqual({('one',): 2, ('two',): 1}, gen.refcounts)
99
101
        # three
100
102
        record = stream.next()
101
103
        self.assertEqual(('two',), record.key)
102
 
        gen._process_one_record(record)
 
104
        gen._process_one_record(record.key, record.get_bytes_as('chunked'))
103
105
        # Both are now cached, and the diff for two has been extracted, and
104
106
        # one's refcount has been updated. two has been removed from the
105
107
        # parent_map
113
115
        # caches
114
116
        record = stream.next()
115
117
        self.assertEqual(('three',), record.key)
116
 
        gen._process_one_record(record)
 
118
        gen._process_one_record(record.key, record.get_bytes_as('chunked'))
117
119
        # Both are now cached, and the diff for two has been extracted, and
118
120
        # one's refcount has been updated
119
121
        self.assertEqual([], gen.chunks.keys())