##// 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 if p1 is None and p2 is None:
1659 if p1 is None and p2 is None:
1660 p1, p2 = self.parents(node)
1660 p1, p2 = self.parents(node)
1661 if node != self.hash(text, p1, p2):
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 revornode = rev
1671 revornode = rev
1663 if revornode is None:
1672 if revornode is None:
1664 revornode = templatefilters.short(hex(node))
1673 revornode = templatefilters.short(hex(node))
@@ -881,13 +881,14 b' class ifiledatatests(basetestcase):'
881 with self.assertRaises(error.StorageError):
881 with self.assertRaises(error.StorageError):
882 f.revision(node1)
882 f.revision(node1)
883
883
884 # revision(raw=True) still verifies hashes.
884 # raw=True still verifies because there are no special storage
885 # TODO this is buggy because of cache interaction.
885 # settings.
886 self.assertEqual(f.revision(node1, raw=True), fulltext1)
886 with self.assertRaises(error.StorageError):
887 f.revision(node1, raw=True)
887
888
888 # read() behaves like revision().
889 # read() behaves like revision().
889 # TODO this is buggy because of cache interaction.
890 with self.assertRaises(error.StorageError):
890 f.read(node1)
891 f.read(node1)
891
892
892 # We can't test renamed() here because some backends may not require
893 # We can't test renamed() here because some backends may not require
893 # reading/validating the fulltext to return rename metadata.
894 # reading/validating the fulltext to return rename metadata.
@@ -931,8 +932,8 b' class ifiledatatests(basetestcase):'
931 with self.assertRaises(error.StorageError):
932 with self.assertRaises(error.StorageError):
932 f.read(node1)
933 f.read(node1)
933
934
934 # TODO this should raise error.StorageError.
935 with self.assertRaises(error.StorageError):
935 f.read(node1)
936 f.read(node1)
936
937
937 def testbadnodedelta(self):
938 def testbadnodedelta(self):
938 f = self._makefilefn()
939 f = self._makefilefn()
@@ -986,7 +987,8 b' class ifiledatatests(basetestcase):'
986 with self.assertRaises(error.CensoredNodeError):
987 with self.assertRaises(error.CensoredNodeError):
987 f.revision(1)
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 with self.assertRaises(error.CensoredNodeError):
993 with self.assertRaises(error.CensoredNodeError):
992 f.read(1)
994 f.read(1)
General Comments 0
You need to be logged in to leave comments. Login now