[PATCH 2 of 4] basestore: separates veryfing logic from printing summary result

liscju piotr.listkiewicz at gmail.com
Mon May 2 16:19:10 EDT 2016


# HG changeset patch
# User liscju <piotr.listkiewicz at gmail.com>
# Date 1462206865 -7200
#      Mon May 02 18:34:25 2016 +0200
# Branch stable
# Node ID db90d22f291f40554f857a7b0b2d43a0d674cf75
# Parent  a06124951cf43126a92ab77290f8c182e9ebbb1e
basestore: separates veryfing logic from printing summary result

This makes easier to change behaviour of verify in localstore and
remotestore.

diff -r a06124951cf4 -r db90d22f291f hgext/largefiles/basestore.py
--- a/hgext/largefiles/basestore.py	Mon May 02 18:14:28 2016 +0200
+++ b/hgext/largefiles/basestore.py	Mon May 02 18:34:25 2016 +0200
@@ -122,13 +122,7 @@ class basestore(object):
                        len(revs))
         verified = set()                # set of (filename, filenode) tuples
 
-        for rev in revs:
-            cctx = self.repo[rev]
-            cset = "%d:%s" % (cctx.rev(), node.short(cctx.node()))
-
-            for standin in cctx:
-                if self._verifyfile(cctx, cset, contents, standin, verified):
-                    failed = True
+        failed = self._verify(revs, contents, verified)
 
         numrevs = len(verified)
         numlfiles = len(set([fname for (fname, fnode) in verified]))
@@ -142,6 +136,17 @@ class basestore(object):
                 % (numrevs, numlfiles))
         return int(failed)
 
+    def _verify(self, revs, contents, verified):
+        failed = False
+        for rev in revs:
+            cctx = self.repo[rev]
+            cset = "%d:%s" % (cctx.rev(), node.short(cctx.node()))
+
+            for standin in cctx:
+                if self._verifyfile(cctx, cset, contents, standin, verified):
+                    failed = True
+        return failed
+
     def _getfile(self, tmpfile, filename, hash):
         '''Fetch one revision of one file from the store and write it
         to tmpfile.  Compute the hash of the file on-the-fly as it


More information about the Mercurial-devel mailing list