changeset 4010:4c2fcd53c601

sqlite: fast path when nothing to save If we have no new data to save, we should try to do anything. Doing something concurrently is hard enough. If we can avoid doing it at all that would be great.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 27 Aug 2018 11:33:09 +0200
parents c58362473bd4
children 3cb41bf56f16
files hgext3rd/evolve/obsdiscovery.py hgext3rd/evolve/stablerangecache.py tests/test-discovery-obshashrange.t
diffstat 3 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/obsdiscovery.py	Mon Aug 27 11:27:04 2018 +0200
+++ b/hgext3rd/evolve/obsdiscovery.py	Mon Aug 27 11:33:09 2018 +0200
@@ -573,6 +573,8 @@
             repo.ui.warn(msg)
 
     def _save(self, repo):
+        if not self._new:
+            return
         try:
             return self._trysave(repo)
         except (sqlite3.OperationalError, sqlite3.IntegrityError) as exc:
--- a/hgext3rd/evolve/stablerangecache.py	Mon Aug 27 11:27:04 2018 +0200
+++ b/hgext3rd/evolve/stablerangecache.py	Mon Aug 27 11:33:09 2018 +0200
@@ -223,6 +223,8 @@
         return con
 
     def _save(self, repo):
+        if not self._unsavedsubranges:
+            return
         try:
             return self._trysave(repo)
         except (sqlite3.OperationalError, sqlite3.IntegrityError) as exc:
--- a/tests/test-discovery-obshashrange.t	Mon Aug 27 11:27:04 2018 +0200
+++ b/tests/test-discovery-obshashrange.t	Mon Aug 27 11:33:09 2018 +0200
@@ -445,8 +445,8 @@
   * @0000000000000000000000000000000000000000 (*)> updated evo-ext-obscache in *.???? seconds (0r, 1o) (glob)
   * @0000000000000000000000000000000000000000 (*)> -R ../server debugobsolete bbbbbbb2222222222bbbbbbbbbbbbb2222222222 bebd167eb94d257ace0e814aeb98e6972ed2970d exited 0 after *.?? seconds (glob)
   * @0000000000000000000000000000000000000000 (*)> -R server serve --stdio (glob)
-  1970/01/01 00:00:00 * @0000000000000000000000000000000000000000 (*)> obshashcache clean - new markers affect 2 changeset and cached ranges (glob)
-  * @0000000000000000000000000000000000000000 (*)> updated evo-ext-obshashrange in *.???? seconds (0r, 2o) (glob)
+  1970/01/01 00:00:00 * @0000000000000000000000000000000000000000 (*)> obshashcache clean - new markers affect 3 changeset and cached ranges (glob)
+  * @0000000000000000000000000000000000000000 (*)> updated evo-ext-obshashrange in *.???? seconds (0r, 4o) (glob)
   * @0000000000000000000000000000000000000000 (*)> -R server serve --stdio exited 0 after *.?? seconds (glob)
   * @0000000000000000000000000000000000000000 (*)> -R ../server blackbox (glob)
   $ rm ../server/.hg/blackbox.log