changeset 6337:58115cf37211 stable

evolve: make sqlstablerange slightly more tolerant to fs issues (issue6246) It will fall back to memory db when there are problems opening the persistent cache file.
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 01 Dec 2022 16:29:56 +0400
parents 29fb13dcb56c
children a55b9b917a08
files hgext3rd/evolve/stablerangecache.py tests/test-check-sdist.t tests/test-discovery-obshashrange.t tests/test-evolve-issue6246.t tests/test-pullbundle.t
diffstat 5 files changed, 38 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/stablerangecache.py	Sat Nov 19 17:28:10 2022 +0100
+++ b/hgext3rd/evolve/stablerangecache.py	Thu Dec 01 16:29:56 2022 +0400
@@ -246,8 +246,11 @@
             return None
         if self._createmode is not None:
             pre_existed = os.access(self._path, os.R_OK)
-        con = sqlite3.connect(encoding.strfromlocal(self._path), timeout=30,
-                              isolation_level=r"IMMEDIATE")
+        try:
+            con = sqlite3.connect(encoding.strfromlocal(self._path),
+                                  timeout=30, isolation_level=r"IMMEDIATE")
+        except sqlite3.OperationalError:
+            return None
         con.text_factory = bytes
         if self._createmode is not None and not pre_existed:
             try:
@@ -398,6 +401,8 @@
 
         if self._con is not None:
             self._cachekey = (self._ondisktiprev, self._ondisktipnode)
+        else:
+            repo.ui.debug(b'stable-range cache: unable to load, regenerating\n')
         self._ondiskkey = self._cachekey
 
     def save(self, repo):
--- a/tests/test-check-sdist.t	Sat Nov 19 17:28:10 2022 +0100
+++ b/tests/test-check-sdist.t	Thu Dec 01 16:29:56 2022 +0400
@@ -35,7 +35,7 @@
 
   $ tar -tzf hg-evolve-*.tar.gz | sed 's|^hg-evolve-[^/]*/||' | sort > files
   $ wc -l files
-  358 files
+  359 files
   $ fgrep debian files
   tests/test-check-debian.t
   $ fgrep __init__.py files
--- a/tests/test-discovery-obshashrange.t	Sat Nov 19 17:28:10 2022 +0100
+++ b/tests/test-discovery-obshashrange.t	Thu Dec 01 16:29:56 2022 +0400
@@ -198,6 +198,7 @@
   received listkey for "namespaces": 40 bytes
   OBSEXC: computing relevant nodes
   OBSEXC: looking for common markers in 6 nodes
+  stable-range cache: unable to load, regenerating
   query 0; add more sample (target 100, current 1)
   query 0; sample size is 9, largest range 5
   sending evoext_obshashrange_v1 command
@@ -322,6 +323,7 @@
   * @45f8b879de922f6a6e620ba04205730335b6fc7e (*)> preparing listkeys for "namespaces" (glob)
   * @45f8b879de922f6a6e620ba04205730335b6fc7e (*)> sending listkeys command (glob)
   * @45f8b879de922f6a6e620ba04205730335b6fc7e (*)> received listkey for "namespaces": 40 bytes (glob)
+  * @45f8b879de922f6a6e620ba04205730335b6fc7e (*)> stable-range cache: unable to load, regenerating (glob)
   * @45f8b879de922f6a6e620ba04205730335b6fc7e (*)> updated evo-ext-depthcache in *.???? seconds (6r) (glob)
   * @45f8b879de922f6a6e620ba04205730335b6fc7e (*)> updated evo-ext-stablerange-mergepoint in *.???? seconds (6r) (glob)
   * @45f8b879de922f6a6e620ba04205730335b6fc7e (*)> updated evo-ext-obshashrange in *.???? seconds (6r, 4o) (glob)
@@ -1113,6 +1115,7 @@
   $ ls -1 .hg/cache/ | grep evoext
   [1]
   $ hg debugupdatecache --debug
+  stable-range cache: unable to load, regenerating
   updating the branch cache
   $ f -s .hg/cache/evoext*
   .hg/cache/evoext-depthcache-00: size=96
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-evolve-issue6246.t	Thu Dec 01 16:29:56 2022 +0400
@@ -0,0 +1,26 @@
+Failure to open evoext_stablerange_v2.sqlite shouldn't affect operations (issue6246)
+https://bz.mercurial-scm.org/show_bug.cgi?id=6246
+
+  $ . $TESTDIR/testlib/common.sh
+
+  $ cat << EOF >> $HGRCPATH
+  > [extensions]
+  > evolve =
+  > EOF
+
+  $ hg init issue6246
+  $ cd issue6246
+  $ hg debugbuilddag '.+6'
+
+making a cache file that sqlite cannot open shouldn't break stablerange cache
+
+  $ touch .hg/cache/evoext_stablerange_v2.sqlite
+  $ chmod 0000 .hg/cache/evoext_stablerange_v2.sqlite
+
+  $ hg debugstablerange --method default --verify --subranges --rev 1 --debug
+  stable-range cache: unable to load, regenerating
+  66f7d451a68b-0 (1, 2, 2) [complete] - 1ea73414a91b-0 (0, 1, 1), 66f7d451a68b-1 (1, 2, 1)
+  1ea73414a91b-0 (0, 1, 1) [leaf] - 
+  66f7d451a68b-1 (1, 2, 1) [leaf] - 
+
+  $ cd ..
--- a/tests/test-pullbundle.t	Sat Nov 19 17:28:10 2022 +0100
+++ b/tests/test-pullbundle.t	Thu Dec 01 16:29:56 2022 +0400
@@ -186,6 +186,7 @@
   bundle2-input: end of bundle2 stream
   bundle2-input-bundle: 7 parts total
   checking for updated bookmarks
+  stable-range cache: unable to load, regenerating
   updating the branch cache
   added 1235 changesets with 0 changes to 0 files
   new changesets 1ea73414a91b:f864bc82f6a2