Show More
@@ -42,6 +42,8 b' def gettype(q):' | |||
|
42 | 42 | def offset_type(offset, type): |
|
43 | 43 | return long(long(offset) << 16 | type) |
|
44 | 44 | |
|
45 | nullhash = _sha(nullid) | |
|
46 | ||
|
45 | 47 | def hash(text, p1, p2): |
|
46 | 48 | """generate a hash from the given text and its parent hashes |
|
47 | 49 | |
@@ -49,10 +51,17 b' def hash(text, p1, p2):' | |||
|
49 | 51 | in a manner that makes it easy to distinguish nodes with the same |
|
50 | 52 | content in the revision graph. |
|
51 | 53 | """ |
|
52 | l = [p1, p2] | |
|
53 | l.sort() | |
|
54 | s = _sha(l[0]) | |
|
55 | s.update(l[1]) | |
|
54 | # As of now, if one of the parent node is null, p2 is null | |
|
55 | if p2 == nullid: | |
|
56 | # deep copy of a hash is faster than creating one | |
|
57 | s = nullhash.copy() | |
|
58 | s.update(p1) | |
|
59 | else: | |
|
60 | # none of the parent nodes are nullid | |
|
61 | l = [p1, p2] | |
|
62 | l.sort() | |
|
63 | s = _sha(l[0]) | |
|
64 | s.update(l[1]) | |
|
56 | 65 | s.update(text) |
|
57 | 66 | return s.digest() |
|
58 | 67 |
General Comments 0
You need to be logged in to leave comments.
Login now