##// END OF EJS Templates
storageutil: invert logic of file data comparison...
Gregory Szorc -
r40043:14701830 default
parent child Browse files
Show More
@@ -135,7 +135,7 b' class filelog(object):'
135
135
136 returns True if text is different than what is stored.
136 returns True if text is different than what is stored.
137 """
137 """
138 return storageutil.filerevisiondifferent(self, node, text)
138 return not storageutil.filedataequivalent(self, node, text)
139
139
140 def verifyintegrity(self, state):
140 def verifyintegrity(self, state):
141 return self._revlog.verifyintegrity(state)
141 return self._revlog.verifyintegrity(state)
@@ -108,8 +108,18 b' def filerevisioncopied(store, node):'
108
108
109 return False
109 return False
110
110
111 def filerevisiondifferent(store, node, filedata):
111 def filedataequivalent(store, node, filedata):
112 """Determines whether file data is equivalent to a stored node."""
112 """Determines whether file data is equivalent to a stored node.
113
114 Returns True if the passed file data would hash to the same value
115 as a stored revision and False otherwise.
116
117 When a stored revision is censored, filedata must be empty to have
118 equivalence.
119
120 When a stored revision has copy metadata, it is ignored as part
121 of the compare.
122 """
113
123
114 if filedata.startswith(b'\x01\n'):
124 if filedata.startswith(b'\x01\n'):
115 revisiontext = b'\x01\n\x01\n' + filedata
125 revisiontext = b'\x01\n\x01\n' + filedata
@@ -121,18 +131,18 b' def filerevisiondifferent(store, node, f'
121 computednode = hashrevisionsha1(revisiontext, p1, p2)
131 computednode = hashrevisionsha1(revisiontext, p1, p2)
122
132
123 if computednode == node:
133 if computednode == node:
124 return False
134 return True
125
135
126 # Censored files compare against the empty file.
136 # Censored files compare against the empty file.
127 if store.iscensored(store.rev(node)):
137 if store.iscensored(store.rev(node)):
128 return filedata != b''
138 return filedata == b''
129
139
130 # Renaming a file produces a different hash, even if the data
140 # Renaming a file produces a different hash, even if the data
131 # remains unchanged. Check if that's the case.
141 # remains unchanged. Check if that's the case.
132 if store.renamed(node):
142 if store.renamed(node):
133 return store.read(node) != filedata
143 return store.read(node) == filedata
134
144
135 return True
145 return False
136
146
137 def iterrevs(storelen, start=0, stop=None):
147 def iterrevs(storelen, start=0, stop=None):
138 """Iterate over revision numbers in a store."""
148 """Iterate over revision numbers in a store."""
General Comments 0
You need to be logged in to leave comments. Login now