Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/revlog.py @ 65:d40cc5aacc31 0.4f
Fix up a bunch of bugs in the new merge code
Move getchangegroup/addchangegroup to generators
author | mpm@selenic.com |
---|---|
date | Fri, 13 May 2005 11:47:16 -0800 |
parents | b3e2ddff0159 |
children | a182f2561c8e |
comparison
equal
deleted
inserted
replaced
64:b3e2ddff0159 | 65:d40cc5aacc31 |
---|---|
343 def addgroup(self, data, linkmapper, transaction): | 343 def addgroup(self, data, linkmapper, transaction): |
344 # given a set of deltas, add them to the revision log. the | 344 # given a set of deltas, add them to the revision log. the |
345 # first delta is against its parent, which should be in our | 345 # first delta is against its parent, which should be in our |
346 # log, the rest are against the previous delta. | 346 # log, the rest are against the previous delta. |
347 | 347 |
348 if len(data) <= 4: return | 348 if not data: return self.tip() |
349 | 349 |
350 # retrieve the parent revision of the delta chain | 350 # retrieve the parent revision of the delta chain |
351 chain = data[28:48] | 351 chain = data[24:44] |
352 text = self.revision(chain) | |
353 | 352 |
354 # track the base of the current delta log | 353 # track the base of the current delta log |
355 r = self.count() | 354 r = self.count() |
356 t = r - 1 | 355 t = r - 1 |
357 | 356 |
368 transaction.add(self.indexfile, r * struct.calcsize(indexformat)) | 367 transaction.add(self.indexfile, r * struct.calcsize(indexformat)) |
369 dfh = self.opener(self.datafile, "a") | 368 dfh = self.opener(self.datafile, "a") |
370 ifh = self.opener(self.indexfile, "a") | 369 ifh = self.opener(self.indexfile, "a") |
371 | 370 |
372 # loop through our set of deltas | 371 # loop through our set of deltas |
373 pos = 4 | 372 pos = 0 |
374 while pos < len(data): | 373 while pos < len(data): |
375 l, node, p1, p2, cs = struct.unpack(">l20s20s20s20s", | 374 l, node, p1, p2, cs = struct.unpack(">l20s20s20s20s", |
376 data[pos:pos+84]) | 375 data[pos:pos+84]) |
377 link = linkmapper(cs) | 376 link = linkmapper(cs) |
378 delta = data[pos + 84:pos + l] | 377 delta = data[pos + 84:pos + l] |
389 | 388 |
390 if chain != prev or (end - start + len(cdelta)) > measure * 2: | 389 if chain != prev or (end - start + len(cdelta)) > measure * 2: |
391 # flush our writes here so we can read it in revision | 390 # flush our writes here so we can read it in revision |
392 dfh.flush() | 391 dfh.flush() |
393 ifh.flush() | 392 ifh.flush() |
394 text = self.revision(self.node(t)) | 393 text = self.revision(chain) |
395 text = self.patch(text, delta) | 394 text = self.patch(text, delta) |
396 chk = self.addrevision(text, transaction, link, p1, p2) | 395 chk = self.addrevision(text, transaction, link, p1, p2) |
397 if chk != node: | 396 if chk != node: |
398 raise "consistency error adding group" | 397 raise "consistency error adding group" |
399 measure = len(text) | 398 measure = len(text) |
402 self.index.append(e) | 401 self.index.append(e) |
403 self.nodemap[node] = r | 402 self.nodemap[node] = r |
404 dfh.write(cdelta) | 403 dfh.write(cdelta) |
405 ifh.write(struct.pack(indexformat, *e)) | 404 ifh.write(struct.pack(indexformat, *e)) |
406 | 405 |
407 t, r = r, r + 1 | 406 t, r, chain, prev = r, r + 1, node, node |
408 chain = prev | |
409 start = self.start(self.base(t)) | 407 start = self.start(self.base(t)) |
410 end = self.end(t) | 408 end = self.end(t) |
411 | 409 |
412 dfh.close() | 410 dfh.close() |
413 ifh.close() | 411 ifh.close() |