comparison tests/test-manifest.py @ 24228:542c891274b2

lazymanifest: use a binary search to do an insertion This makes insertions log(n) plus some memmove() overhead, rather than doing an append followed by an n*log(n) sort. There's probably a lot of performance to be gained by adding a batch-add method, which could be smarter about the memmove()s performed. Includes a couple of extra tests that should help prevent bugs. Thanks to Martin for some significant pre-mail cleanup of this change.
author Augie Fackler <augie@google.com>
date Fri, 30 Jan 2015 21:30:40 -0800
parents 3e5c4af69808
children 49cd847fd69a
comparison
equal deleted inserted replaced
24227:8ec2df32bd39 24228:542c891274b2
131 m = manifestmod._lazymanifest(A_SHORT_MANIFEST) 131 m = manifestmod._lazymanifest(A_SHORT_MANIFEST)
132 del m['foo'] 132 del m['foo']
133 self.assertRaises(KeyError, lambda : m['foo']) 133 self.assertRaises(KeyError, lambda : m['foo'])
134 self.assertEqual(1, len(m)) 134 self.assertEqual(1, len(m))
135 self.assertEqual(1, len(list(m))) 135 self.assertEqual(1, len(list(m)))
136 # now restore and make sure everything works right
137 m['foo'] = 'a' * 20, ''
138 self.assertEqual(2, len(m))
139 self.assertEqual(2, len(list(m)))
136 140
137 def testManifestDiff(self): 141 def testManifestDiff(self):
138 MISSING = (None, '') 142 MISSING = (None, '')
139 addl = 'z-only-in-left\0' + HASH_1 + '\n' 143 addl = 'z-only-in-left\0' + HASH_1 + '\n'
140 addr = 'z-only-in-right\0' + HASH_2 + 'x\n' 144 addr = 'z-only-in-right\0' + HASH_2 + 'x\n'