Mercurial > hg
comparison mercurial/filelog.py @ 2887:05257fd28591
filelog: add hash-based comparisons
For status, rather than reconstruct full file versions from revlog for
comparison, compare hashes.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 14 Aug 2006 15:07:00 -0500 |
parents | 345bac2bc4ec |
children | 5df3e5cf16bc |
comparison
equal
deleted
inserted
replaced
2886:bee4b7abcb01 | 2887:05257fd28591 |
---|---|
63 m = self.readmeta(node) | 63 m = self.readmeta(node) |
64 if m and m.has_key("copy"): | 64 if m and m.has_key("copy"): |
65 return (m["copy"], bin(m["copyrev"])) | 65 return (m["copy"], bin(m["copyrev"])) |
66 return False | 66 return False |
67 | 67 |
68 def cmp(self, node, text): | |
69 """compare text with a given file revision""" | |
70 | |
71 # for renames, we have to go the slow way | |
72 if self.renamed(node): | |
73 t2 = self.read(node) | |
74 return t2 == text | |
75 | |
76 p1, p2 = self.parents(node) | |
77 h = hash(text, p1, p2) | |
78 | |
79 return h != node | |
80 | |
81 def makenode(self, node, text): | |
82 """calculate a file nodeid for text, descended or possibly | |
83 unchanged from node""" | |
84 | |
85 if self.cmp(node, text): | |
86 return hash(text, node, nullid) | |
87 return node | |
88 | |
68 def annotate(self, node): | 89 def annotate(self, node): |
69 | 90 |
70 def decorate(text, rev): | 91 def decorate(text, rev): |
71 return ([rev] * len(text.splitlines()), text) | 92 return ([rev] * len(text.splitlines()), text) |
72 | 93 |