Show More
@@ -31,15 +31,15 b' def hash(text, p1, p2):' | |||
|
31 | 31 | |
|
32 | 32 | def compress(text): |
|
33 | 33 | """ generate a possibly-compressed representation of text """ |
|
34 | if not text: return text | |
|
34 | if not text: return ("", text) | |
|
35 | 35 | if len(text) < 44: |
|
36 | if text[0] == '\0': return text | |
|
37 |
return 'u' |
|
|
36 | if text[0] == '\0': return ("", text) | |
|
37 | return ('u', text) | |
|
38 | 38 | bin = zlib.compress(text) |
|
39 | 39 | if len(bin) > len(text): |
|
40 | if text[0] == '\0': return text | |
|
41 |
return 'u' |
|
|
42 | return bin | |
|
40 | if text[0] == '\0': return ("", text) | |
|
41 | return ('u', text) | |
|
42 | return ("", bin) | |
|
43 | 43 | |
|
44 | 44 | def decompress(bin): |
|
45 | 45 | """ decompress the given input """ |
@@ -543,14 +543,16 b' class revlog:' | |||
|
543 | 543 | end = self.end(t) |
|
544 | 544 | if not d: |
|
545 | 545 | prev = self.revision(self.tip()) |
|
546 | d = self.diff(prev, text) | |
|
546 | d = self.diff(prev, str(text)) | |
|
547 | 547 | data = compress(d) |
|
548 |
|
|
|
548 | l = len(data[1]) + len(data[0]) | |
|
549 | dist = end - start + l | |
|
549 | 550 | |
|
550 | 551 | # full versions are inserted when the needed deltas |
|
551 | 552 | # become comparable to the uncompressed text |
|
552 | 553 | if not n or dist > len(text) * 2: |
|
553 | 554 | data = compress(text) |
|
555 | l = len(data[1]) + len(data[0]) | |
|
554 | 556 | base = n |
|
555 | 557 | else: |
|
556 | 558 | base = self.base(t) |
@@ -559,14 +561,17 b' class revlog:' | |||
|
559 | 561 | if t >= 0: |
|
560 | 562 | offset = self.end(t) |
|
561 | 563 | |
|
562 |
e = (offset, l |
|
|
564 | e = (offset, l, base, link, p1, p2, node) | |
|
563 | 565 | |
|
564 | 566 | self.index.append(e) |
|
565 | 567 | self.nodemap[node] = n |
|
566 | 568 | entry = struct.pack(indexformat, *e) |
|
567 | 569 | |
|
568 | 570 | transaction.add(self.datafile, e[0]) |
|
569 |
self.opener(self.datafile, "a") |
|
|
571 | f = self.opener(self.datafile, "a") | |
|
572 | if data[0]: | |
|
573 | f.write(data[0]) | |
|
574 | f.write(data[1]) | |
|
570 | 575 | transaction.add(self.indexfile, n * len(entry)) |
|
571 | 576 | self.opener(self.indexfile, "a").write(entry) |
|
572 | 577 | |
@@ -801,7 +806,8 b' class revlog:' | |||
|
801 | 806 | # current size. |
|
802 | 807 | |
|
803 | 808 | if chain == prev: |
|
804 |
|
|
|
809 | tempd = compress(delta) | |
|
810 | cdelta = tempd[0] + tempd[1] | |
|
805 | 811 | |
|
806 | 812 | if chain != prev or (end - start + len(cdelta)) > measure * 2: |
|
807 | 813 | # flush our writes here so we can read it in revision |
General Comments 0
You need to be logged in to leave comments.
Login now