sqlite: fast path when nothing to save stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 27 Aug 2018 11:33:09 +0200
branchstable
changeset 4023 f59b262400fb
parent 4022 082b59126099
child 4024 210f8abdfcd7
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.
hgext3rd/evolve/obsdiscovery.py
hgext3rd/evolve/stablerangecache.py
tests/test-discovery-obshashrange.t
--- 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
@@ -568,6 +568,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
@@ -224,6 +224,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