equal
deleted
inserted
replaced
11 """ |
11 """ |
12 |
12 |
13 import zlib, struct, sha, binascii, heapq |
13 import zlib, struct, sha, binascii, heapq |
14 from mercurial import mdiff |
14 from mercurial import mdiff |
15 from node import * |
15 from node import * |
|
16 |
|
17 def hash(text, p1, p2): |
|
18 """generate a hash from the given text and its parent hashes |
|
19 |
|
20 This hash combines both the current file contents and its history |
|
21 in a manner that makes it easy to distinguish nodes with the same |
|
22 content in the revision graph. |
|
23 """ |
|
24 l = [p1, p2] |
|
25 l.sort() |
|
26 s = sha.new(l[0]) |
|
27 s.update(l[1]) |
|
28 s.update(text) |
|
29 return s.digest() |
16 |
30 |
17 def compress(text): |
31 def compress(text): |
18 """ generate a possibly-compressed representation of text """ |
32 """ generate a possibly-compressed representation of text """ |
19 if not text: return text |
33 if not text: return text |
20 if len(text) < 44: |
34 if len(text) < 44: |