117 """Test putting multiple revisions in into a pack and read the ancestor |
117 """Test putting multiple revisions in into a pack and read the ancestor |
118 chain. |
118 chain. |
119 """ |
119 """ |
120 revisions = [] |
120 revisions = [] |
121 filename = b"foo" |
121 filename = b"foo" |
122 lastnode = nullid |
122 lastnode = sha1nodeconstants.nullid |
123 for i in range(10): |
123 for i in range(10): |
124 node = self.getFakeHash() |
124 node = self.getFakeHash() |
125 revisions.append((filename, node, lastnode, nullid, nullid, None)) |
125 revisions.append( |
|
126 ( |
|
127 filename, |
|
128 node, |
|
129 lastnode, |
|
130 sha1nodeconstants.nullid, |
|
131 sha1nodeconstants.nullid, |
|
132 None, |
|
133 ) |
|
134 ) |
126 lastnode = node |
135 lastnode = node |
127 |
136 |
128 # revisions must be added in topological order, newest first |
137 # revisions must be added in topological order, newest first |
129 revisions = list(reversed(revisions)) |
138 revisions = list(reversed(revisions)) |
130 pack = self.createPack(revisions) |
139 pack = self.createPack(revisions) |
146 revisions = [] |
155 revisions = [] |
147 random.seed(0) |
156 random.seed(0) |
148 for i in range(100): |
157 for i in range(100): |
149 filename = b"filename-%d" % i |
158 filename = b"filename-%d" % i |
150 entries = [] |
159 entries = [] |
151 p2 = nullid |
160 p2 = sha1nodeconstants.nullid |
152 linknode = nullid |
161 linknode = sha1nodeconstants.nullid |
153 for j in range(random.randint(1, 100)): |
162 for j in range(random.randint(1, 100)): |
154 node = self.getFakeHash() |
163 node = self.getFakeHash() |
155 p1 = nullid |
164 p1 = sha1nodeconstants.nullid |
156 if len(entries) > 0: |
165 if len(entries) > 0: |
157 p1 = entries[random.randint(0, len(entries) - 1)] |
166 p1 = entries[random.randint(0, len(entries) - 1)] |
158 entries.append(node) |
167 entries.append(node) |
159 revisions.append((filename, node, p1, p2, linknode, None)) |
168 revisions.append((filename, node, p1, p2, linknode, None)) |
160 allentries[(filename, node)] = (p1, p2, linknode) |
169 allentries[(filename, node)] = (p1, p2, linknode) |
161 if p1 == nullid: |
170 if p1 == sha1nodeconstants.nullid: |
162 ancestorcounts[(filename, node)] = 1 |
171 ancestorcounts[(filename, node)] = 1 |
163 else: |
172 else: |
164 newcount = ancestorcounts[(filename, p1)] + 1 |
173 newcount = ancestorcounts[(filename, p1)] + 1 |
165 ancestorcounts[(filename, node)] = newcount |
174 ancestorcounts[(filename, node)] = newcount |
166 |
175 |
180 self.assertEqual(copyfrom, None) |
189 self.assertEqual(copyfrom, None) |
181 |
190 |
182 def testGetNodeInfo(self): |
191 def testGetNodeInfo(self): |
183 revisions = [] |
192 revisions = [] |
184 filename = b"foo" |
193 filename = b"foo" |
185 lastnode = nullid |
194 lastnode = sha1nodeconstants.nullid |
186 for i in range(10): |
195 for i in range(10): |
187 node = self.getFakeHash() |
196 node = self.getFakeHash() |
188 revisions.append((filename, node, lastnode, nullid, nullid, None)) |
197 revisions.append( |
|
198 ( |
|
199 filename, |
|
200 node, |
|
201 lastnode, |
|
202 sha1nodeconstants.nullid, |
|
203 sha1nodeconstants.nullid, |
|
204 None, |
|
205 ) |
|
206 ) |
189 lastnode = node |
207 lastnode = node |
190 |
208 |
191 pack = self.createPack(revisions) |
209 pack = self.createPack(revisions) |
192 |
210 |
193 # Test that getnodeinfo returns the expected results |
211 # Test that getnodeinfo returns the expected results |
231 |
249 |
232 def testAddThrows(self): |
250 def testAddThrows(self): |
233 pack = self.createPack() |
251 pack = self.createPack() |
234 |
252 |
235 try: |
253 try: |
236 pack.add(b'filename', nullid, nullid, nullid, nullid, None) |
254 pack.add( |
|
255 b'filename', |
|
256 sha1nodeconstants.nullid, |
|
257 sha1nodeconstants.nullid, |
|
258 sha1nodeconstants.nullid, |
|
259 sha1nodeconstants.nullid, |
|
260 None, |
|
261 ) |
237 self.assertTrue(False, "historypack.add should throw") |
262 self.assertTrue(False, "historypack.add should throw") |
238 except RuntimeError: |
263 except RuntimeError: |
239 pass |
264 pass |
240 |
265 |
241 def testBadVersionThrows(self): |
266 def testBadVersionThrows(self): |