diff tests/simplestorerepo.py @ 39882:f8eb71f9e3bd

storageutil: new module for storage primitives (API) There will exist common code between storage backends. It would be nice to have a central place to put that code. This commit attempts to create that place by creating the "storageutil" module. The first thing we move is revlog.hash(), which is the function for computing the SHA-1 hash of revision fulltext and parents. Differential Revision: https://phab.mercurial-scm.org/D4753
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 24 Sep 2018 14:23:54 -0700
parents a269fa55467e
children 3e896b51aa5d
line wrap: on
line diff
--- a/tests/simplestorerepo.py	Mon Sep 24 13:35:50 2018 -0700
+++ b/tests/simplestorerepo.py	Mon Sep 24 14:23:54 2018 -0700
@@ -40,6 +40,7 @@
 )
 from mercurial.utils import (
     interfaceutil,
+    storageutil,
 )
 
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
@@ -285,7 +286,7 @@
     def checkhash(self, text, node, p1=None, p2=None, rev=None):
         if p1 is None and p2 is None:
             p1, p2 = self.parents(node)
-        if node != revlog.hash(text, p1, p2):
+        if node != storageutil.hashrevisionsha1(text, p1, p2):
             raise simplestoreerror(_("integrity check failed on %s") %
                 self._path)
 
@@ -342,7 +343,7 @@
 
         p1, p2 = self.parents(node)
 
-        if revlog.hash(t, p1, p2) == node:
+        if storageutil.hashrevisionsha1(t, p1, p2) == node:
             return False
 
         if self.iscensored(self.rev(node)):
@@ -420,11 +421,11 @@
         validatenode(p2)
 
         if flags:
-            node = node or revlog.hash(text, p1, p2)
+            node = node or storageutil.hashrevisionsha1(text, p1, p2)
 
         rawtext, validatehash = self._processflags(text, flags, 'write')
 
-        node = node or revlog.hash(text, p1, p2)
+        node = node or storageutil.hashrevisionsha1(text, p1, p2)
 
         if node in self._indexbynode:
             return node