Show More
@@ -79,11 +79,11 b' class datapacktestsbase(object):' | |||||
79 | revisions = [(filename, node, nullid, content)] |
|
79 | revisions = [(filename, node, nullid, content)] | |
80 | pack = self.createPack(revisions) |
|
80 | pack = self.createPack(revisions) | |
81 | if self.paramsavailable: |
|
81 | if self.paramsavailable: | |
82 |
self.assertEqual |
|
82 | self.assertEqual(pack.params.fanoutprefix, | |
83 |
|
|
83 | basepack.SMALLFANOUTPREFIX) | |
84 |
|
84 | |||
85 | chain = pack.getdeltachain(filename, node) |
|
85 | chain = pack.getdeltachain(filename, node) | |
86 |
self.assertEqual |
|
86 | self.assertEqual(content, chain[0][4]) | |
87 |
|
87 | |||
88 | def testAddSingle(self): |
|
88 | def testAddSingle(self): | |
89 | self._testAddSingle('') |
|
89 | self._testAddSingle('') | |
@@ -106,10 +106,10 b' class datapacktestsbase(object):' | |||||
106 |
|
106 | |||
107 | for filename, node, base, content in revisions: |
|
107 | for filename, node, base, content in revisions: | |
108 | entry = pack.getdelta(filename, node) |
|
108 | entry = pack.getdelta(filename, node) | |
109 |
self.assertEqual |
|
109 | self.assertEqual((content, filename, base, {}), entry) | |
110 |
|
110 | |||
111 | chain = pack.getdeltachain(filename, node) |
|
111 | chain = pack.getdeltachain(filename, node) | |
112 |
self.assertEqual |
|
112 | self.assertEqual(content, chain[0][4]) | |
113 |
|
113 | |||
114 | def testAddDeltas(self): |
|
114 | def testAddDeltas(self): | |
115 | """Test putting multiple delta blobs into a pack and read the chain. |
|
115 | """Test putting multiple delta blobs into a pack and read the chain. | |
@@ -127,13 +127,13 b' class datapacktestsbase(object):' | |||||
127 |
|
127 | |||
128 | entry = pack.getdelta(filename, revisions[0][1]) |
|
128 | entry = pack.getdelta(filename, revisions[0][1]) | |
129 | realvalue = (revisions[0][3], filename, revisions[0][2], {}) |
|
129 | realvalue = (revisions[0][3], filename, revisions[0][2], {}) | |
130 |
self.assertEqual |
|
130 | self.assertEqual(entry, realvalue) | |
131 |
|
131 | |||
132 | # Test that the chain for the final entry has all the others |
|
132 | # Test that the chain for the final entry has all the others | |
133 | chain = pack.getdeltachain(filename, node) |
|
133 | chain = pack.getdeltachain(filename, node) | |
134 | for i in range(10): |
|
134 | for i in range(10): | |
135 | content = "abcdef%s" % i |
|
135 | content = "abcdef%s" % i | |
136 |
self.assertEqual |
|
136 | self.assertEqual(content, chain[-i - 1][4]) | |
137 |
|
137 | |||
138 | def testPackMany(self): |
|
138 | def testPackMany(self): | |
139 | """Pack many related and unrelated objects. |
|
139 | """Pack many related and unrelated objects. | |
@@ -162,7 +162,7 b' class datapacktestsbase(object):' | |||||
162 | chain = pack.getdeltachain(filename, node) |
|
162 | chain = pack.getdeltachain(filename, node) | |
163 | for entry in chain: |
|
163 | for entry in chain: | |
164 | expectedcontent = blobs[(entry[0], entry[1], entry[3])] |
|
164 | expectedcontent = blobs[(entry[0], entry[1], entry[3])] | |
165 |
self.assertEqual |
|
165 | self.assertEqual(entry[4], expectedcontent) | |
166 |
|
166 | |||
167 | def testPackMetadata(self): |
|
167 | def testPackMetadata(self): | |
168 | revisions = [] |
|
168 | revisions = [] | |
@@ -181,7 +181,7 b' class datapacktestsbase(object):' | |||||
181 | # flag == 0 should be optimized out |
|
181 | # flag == 0 should be optimized out | |
182 | if origmeta[constants.METAKEYFLAG] == 0: |
|
182 | if origmeta[constants.METAKEYFLAG] == 0: | |
183 | del origmeta[constants.METAKEYFLAG] |
|
183 | del origmeta[constants.METAKEYFLAG] | |
184 |
self.assertEqual |
|
184 | self.assertEqual(parsedmeta, origmeta) | |
185 |
|
185 | |||
186 | def testGetMissing(self): |
|
186 | def testGetMissing(self): | |
187 | """Test the getmissing() api. |
|
187 | """Test the getmissing() api. | |
@@ -206,7 +206,7 b' class datapacktestsbase(object):' | |||||
206 |
|
206 | |||
207 | fakenode = self.getFakeHash() |
|
207 | fakenode = self.getFakeHash() | |
208 | missing = pack.getmissing([("foo", revisions[0][1]), ("foo", fakenode)]) |
|
208 | missing = pack.getmissing([("foo", revisions[0][1]), ("foo", fakenode)]) | |
209 |
self.assertEqual |
|
209 | self.assertEqual(missing, [("foo", fakenode)]) | |
210 |
|
210 | |||
211 | def testAddThrows(self): |
|
211 | def testAddThrows(self): | |
212 | pack = self.createPack() |
|
212 | pack = self.createPack() | |
@@ -238,7 +238,7 b' class datapacktestsbase(object):' | |||||
238 | revisions = [("filename", fakenode, self.getFakeHash(), "content")] |
|
238 | revisions = [("filename", fakenode, self.getFakeHash(), "content")] | |
239 | pack = self.createPack(revisions) |
|
239 | pack = self.createPack(revisions) | |
240 | chain = pack.getdeltachain("filename", fakenode) |
|
240 | chain = pack.getdeltachain("filename", fakenode) | |
241 |
self.assertEqual |
|
241 | self.assertEqual(len(chain), 1) | |
242 |
|
242 | |||
243 | def testLargePack(self): |
|
243 | def testLargePack(self): | |
244 | """Test creating and reading from a large pack with over X entries. |
|
244 | """Test creating and reading from a large pack with over X entries. | |
@@ -255,12 +255,12 b' class datapacktestsbase(object):' | |||||
255 |
|
255 | |||
256 | pack = self.createPack(revisions) |
|
256 | pack = self.createPack(revisions) | |
257 | if self.paramsavailable: |
|
257 | if self.paramsavailable: | |
258 |
self.assertEqual |
|
258 | self.assertEqual(pack.params.fanoutprefix, | |
259 |
|
|
259 | basepack.LARGEFANOUTPREFIX) | |
260 |
|
260 | |||
261 | for (filename, node), content in blobs.iteritems(): |
|
261 | for (filename, node), content in blobs.iteritems(): | |
262 | actualcontent = pack.getdeltachain(filename, node)[0][4] |
|
262 | actualcontent = pack.getdeltachain(filename, node)[0][4] | |
263 |
self.assertEqual |
|
263 | self.assertEqual(actualcontent, content) | |
264 |
|
264 | |||
265 | def testPacksCache(self): |
|
265 | def testPacksCache(self): | |
266 | """Test that we remember the most recent packs while fetching the delta |
|
266 | """Test that we remember the most recent packs while fetching the delta | |
@@ -300,12 +300,12 b' class datapacktestsbase(object):' | |||||
300 | chain = store.getdeltachain(revision[0], revision[1]) |
|
300 | chain = store.getdeltachain(revision[0], revision[1]) | |
301 |
|
301 | |||
302 | mostrecentpack = next(iter(store.packs), None) |
|
302 | mostrecentpack = next(iter(store.packs), None) | |
303 |
self.assertEqual |
|
303 | self.assertEqual( | |
304 | mostrecentpack.getdeltachain(revision[0], revision[1]), |
|
304 | mostrecentpack.getdeltachain(revision[0], revision[1]), | |
305 | chain |
|
305 | chain | |
306 | ) |
|
306 | ) | |
307 |
|
307 | |||
308 |
self.assertEqual |
|
308 | self.assertEqual(randomchain.index(revision) + 1, len(chain)) | |
309 |
|
309 | |||
310 | # perf test off by default since it's slow |
|
310 | # perf test off by default since it's slow | |
311 | def _testIndexPerf(self): |
|
311 | def _testIndexPerf(self): |
@@ -78,9 +78,9 b' class histpacktests(unittest.TestCase):' | |||||
78 | pack = self.createPack(revisions) |
|
78 | pack = self.createPack(revisions) | |
79 |
|
79 | |||
80 | actual = pack.getancestors(filename, node)[node] |
|
80 | actual = pack.getancestors(filename, node)[node] | |
81 |
self.assertEqual |
|
81 | self.assertEqual(p1, actual[0]) | |
82 |
self.assertEqual |
|
82 | self.assertEqual(p2, actual[1]) | |
83 |
self.assertEqual |
|
83 | self.assertEqual(linknode, actual[2]) | |
84 |
|
84 | |||
85 | def testAddMultiple(self): |
|
85 | def testAddMultiple(self): | |
86 | """Test putting multiple unrelated revisions into a pack and reading |
|
86 | """Test putting multiple unrelated revisions into a pack and reading | |
@@ -99,10 +99,10 b' class histpacktests(unittest.TestCase):' | |||||
99 |
|
99 | |||
100 | for filename, node, p1, p2, linknode, copyfrom in revisions: |
|
100 | for filename, node, p1, p2, linknode, copyfrom in revisions: | |
101 | actual = pack.getancestors(filename, node)[node] |
|
101 | actual = pack.getancestors(filename, node)[node] | |
102 |
self.assertEqual |
|
102 | self.assertEqual(p1, actual[0]) | |
103 |
self.assertEqual |
|
103 | self.assertEqual(p2, actual[1]) | |
104 |
self.assertEqual |
|
104 | self.assertEqual(linknode, actual[2]) | |
105 |
self.assertEqual |
|
105 | self.assertEqual(copyfrom, actual[3]) | |
106 |
|
106 | |||
107 | def testAddAncestorChain(self): |
|
107 | def testAddAncestorChain(self): | |
108 | """Test putting multiple revisions in into a pack and read the ancestor |
|
108 | """Test putting multiple revisions in into a pack and read the ancestor | |
@@ -124,10 +124,10 b' class histpacktests(unittest.TestCase):' | |||||
124 | ancestors = pack.getancestors(revisions[0][0], revisions[0][1]) |
|
124 | ancestors = pack.getancestors(revisions[0][0], revisions[0][1]) | |
125 | for filename, node, p1, p2, linknode, copyfrom in revisions: |
|
125 | for filename, node, p1, p2, linknode, copyfrom in revisions: | |
126 | ap1, ap2, alinknode, acopyfrom = ancestors[node] |
|
126 | ap1, ap2, alinknode, acopyfrom = ancestors[node] | |
127 |
self.assertEqual |
|
127 | self.assertEqual(ap1, p1) | |
128 |
self.assertEqual |
|
128 | self.assertEqual(ap2, p2) | |
129 |
self.assertEqual |
|
129 | self.assertEqual(alinknode, linknode) | |
130 |
self.assertEqual |
|
130 | self.assertEqual(acopyfrom, copyfrom) | |
131 |
|
131 | |||
132 | def testPackMany(self): |
|
132 | def testPackMany(self): | |
133 | """Pack many related and unrelated ancestors. |
|
133 | """Pack many related and unrelated ancestors. | |
@@ -163,14 +163,14 b' class histpacktests(unittest.TestCase):' | |||||
163 | # Verify the pack contents |
|
163 | # Verify the pack contents | |
164 | for (filename, node), (p1, p2, lastnode) in allentries.items(): |
|
164 | for (filename, node), (p1, p2, lastnode) in allentries.items(): | |
165 | ancestors = pack.getancestors(filename, node) |
|
165 | ancestors = pack.getancestors(filename, node) | |
166 |
self.assertEqual |
|
166 | self.assertEqual(ancestorcounts[(filename, node)], | |
167 |
|
|
167 | len(ancestors)) | |
168 | for anode, (ap1, ap2, alinknode, copyfrom) in ancestors.items(): |
|
168 | for anode, (ap1, ap2, alinknode, copyfrom) in ancestors.items(): | |
169 | ep1, ep2, elinknode = allentries[(filename, anode)] |
|
169 | ep1, ep2, elinknode = allentries[(filename, anode)] | |
170 |
self.assertEqual |
|
170 | self.assertEqual(ap1, ep1) | |
171 |
self.assertEqual |
|
171 | self.assertEqual(ap2, ep2) | |
172 |
self.assertEqual |
|
172 | self.assertEqual(alinknode, elinknode) | |
173 |
self.assertEqual |
|
173 | self.assertEqual(copyfrom, None) | |
174 |
|
174 | |||
175 | def testGetNodeInfo(self): |
|
175 | def testGetNodeInfo(self): | |
176 | revisions = [] |
|
176 | revisions = [] | |
@@ -186,10 +186,10 b' class histpacktests(unittest.TestCase):' | |||||
186 | # Test that getnodeinfo returns the expected results |
|
186 | # Test that getnodeinfo returns the expected results | |
187 | for filename, node, p1, p2, linknode, copyfrom in revisions: |
|
187 | for filename, node, p1, p2, linknode, copyfrom in revisions: | |
188 | ap1, ap2, alinknode, acopyfrom = pack.getnodeinfo(filename, node) |
|
188 | ap1, ap2, alinknode, acopyfrom = pack.getnodeinfo(filename, node) | |
189 |
self.assertEqual |
|
189 | self.assertEqual(ap1, p1) | |
190 |
self.assertEqual |
|
190 | self.assertEqual(ap2, p2) | |
191 |
self.assertEqual |
|
191 | self.assertEqual(alinknode, linknode) | |
192 |
self.assertEqual |
|
192 | self.assertEqual(acopyfrom, copyfrom) | |
193 |
|
193 | |||
194 | def testGetMissing(self): |
|
194 | def testGetMissing(self): | |
195 | """Test the getmissing() api. |
|
195 | """Test the getmissing() api. | |
@@ -215,11 +215,11 b' class histpacktests(unittest.TestCase):' | |||||
215 | fakenode = self.getFakeHash() |
|
215 | fakenode = self.getFakeHash() | |
216 | missing = pack.getmissing([(filename, revisions[0][1]), |
|
216 | missing = pack.getmissing([(filename, revisions[0][1]), | |
217 | (filename, fakenode)]) |
|
217 | (filename, fakenode)]) | |
218 |
self.assertEqual |
|
218 | self.assertEqual(missing, [(filename, fakenode)]) | |
219 |
|
219 | |||
220 | # Test getmissing on a non-existant filename |
|
220 | # Test getmissing on a non-existant filename | |
221 | missing = pack.getmissing([("bar", fakenode)]) |
|
221 | missing = pack.getmissing([("bar", fakenode)]) | |
222 |
self.assertEqual |
|
222 | self.assertEqual(missing, [("bar", fakenode)]) | |
223 |
|
223 | |||
224 | def testAddThrows(self): |
|
224 | def testAddThrows(self): | |
225 | pack = self.createPack() |
|
225 | pack = self.createPack() | |
@@ -260,14 +260,14 b' class histpacktests(unittest.TestCase):' | |||||
260 | revisions.append((filename, node, p1, p2, linknode, None)) |
|
260 | revisions.append((filename, node, p1, p2, linknode, None)) | |
261 |
|
261 | |||
262 | pack = self.createPack(revisions) |
|
262 | pack = self.createPack(revisions) | |
263 |
self.assertEqual |
|
263 | self.assertEqual(pack.params.fanoutprefix, basepack.LARGEFANOUTPREFIX) | |
264 |
|
264 | |||
265 | for filename, node, p1, p2, linknode, copyfrom in revisions: |
|
265 | for filename, node, p1, p2, linknode, copyfrom in revisions: | |
266 | actual = pack.getancestors(filename, node)[node] |
|
266 | actual = pack.getancestors(filename, node)[node] | |
267 |
self.assertEqual |
|
267 | self.assertEqual(p1, actual[0]) | |
268 |
self.assertEqual |
|
268 | self.assertEqual(p2, actual[1]) | |
269 |
self.assertEqual |
|
269 | self.assertEqual(linknode, actual[2]) | |
270 |
self.assertEqual |
|
270 | self.assertEqual(copyfrom, actual[3]) | |
271 | # TODO: |
|
271 | # TODO: | |
272 | # histpack store: |
|
272 | # histpack store: | |
273 | # - repack two packs into one |
|
273 | # - repack two packs into one |
General Comments 0
You need to be logged in to leave comments.
Login now