comparison mercurial/revlog.py @ 1091:d62130f99a73

Move hash function back to revlog from node
author mpm@selenic.com
date Sat, 27 Aug 2005 14:43:20 -0700
parents 142b5d5ec9cc
children 0cb9c72b6c03
comparison
equal deleted inserted replaced
1090:1bca39b85615 1091:d62130f99a73
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: