##// END OF EJS Templates
revlog: clear revision cache on hash verification failure...
Gregory Szorc -
r40090:801ccd8e default
parent child Browse files
Show More
@@ -1659,6 +1659,15 b' class revlog(object):'
1659 1659 if p1 is None and p2 is None:
1660 1660 p1, p2 = self.parents(node)
1661 1661 if node != self.hash(text, p1, p2):
1662 # Clear the revision cache on hash failure. The revision cache
1663 # only stores the raw revision and clearing the cache does have
1664 # the side-effect that we won't have a cache hit when the raw
1665 # revision data is accessed. But this case should be rare and
1666 # it is extra work to teach the cache about the hash
1667 # verification state.
1668 if self._revisioncache and self._revisioncache[0] == node:
1669 self._revisioncache = None
1670
1662 1671 revornode = rev
1663 1672 if revornode is None:
1664 1673 revornode = templatefilters.short(hex(node))
@@ -881,13 +881,14 b' class ifiledatatests(basetestcase):'
881 881 with self.assertRaises(error.StorageError):
882 882 f.revision(node1)
883 883
884 # revision(raw=True) still verifies hashes.
885 # TODO this is buggy because of cache interaction.
886 self.assertEqual(f.revision(node1, raw=True), fulltext1)
884 # raw=True still verifies because there are no special storage
885 # settings.
886 with self.assertRaises(error.StorageError):
887 f.revision(node1, raw=True)
887 888
888 889 # read() behaves like revision().
889 # TODO this is buggy because of cache interaction.
890 f.read(node1)
890 with self.assertRaises(error.StorageError):
891 f.read(node1)
891 892
892 893 # We can't test renamed() here because some backends may not require
893 894 # reading/validating the fulltext to return rename metadata.
@@ -931,8 +932,8 b' class ifiledatatests(basetestcase):'
931 932 with self.assertRaises(error.StorageError):
932 933 f.read(node1)
933 934
934 # TODO this should raise error.StorageError.
935 f.read(node1)
935 with self.assertRaises(error.StorageError):
936 f.read(node1)
936 937
937 938 def testbadnodedelta(self):
938 939 f = self._makefilefn()
@@ -986,7 +987,8 b' class ifiledatatests(basetestcase):'
986 987 with self.assertRaises(error.CensoredNodeError):
987 988 f.revision(1)
988 989
989 self.assertEqual(f.revision(1, raw=True), stored1)
990 with self.assertRaises(error.CensoredNodeError):
991 f.revision(1, raw=True)
990 992
991 993 with self.assertRaises(error.CensoredNodeError):
992 994 f.read(1)
General Comments 0
You need to be logged in to leave comments. Login now