obshashrange: do not search for affected ranges above the highest we have stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 16 Aug 2018 21:18:18 +0200
branchstable
changeset 3955 0174737af4fc
parent 3954 b53bf9942e0a
child 3956 98295547c40f
obshashrange: do not search for affected ranges above the highest we have It is a fast way to know we don't have an affected range for an affected revision.
hgext3rd/evolve/obsdiscovery.py
tests/test-discovery-obshashrange.t
--- a/hgext3rd/evolve/obsdiscovery.py	Thu Aug 16 20:49:55 2018 +0200
+++ b/hgext3rd/evolve/obsdiscovery.py	Thu Aug 16 21:18:18 2018 +0200
@@ -348,6 +348,7 @@
 _updateobshash = "INSERT INTO obshashrange(rev, idx, obshash) VALUES (?,?,?);"
 _querymeta = "SELECT schemaversion, tiprev, tipnode, nbobsmarker, obssize, obskey FROM meta;"
 _queryobshash = "SELECT obshash FROM obshashrange WHERE (rev = ? AND idx = ?);"
+_query_max_stored = "SELECT MAX(rev) FROM obshashrange"
 
 _reset = "DELETE FROM obshashrange;"
 _delete = "DELETE FROM obshashrange WHERE (rev = ? AND idx = ?);"
@@ -433,6 +434,14 @@
                         affected.add(r)
 
         if affected:
+            con = self._con
+            if con is None: # no data accessible
+                affected = set()
+            else:
+                max_stored = con.execute(_query_max_stored).fetchall()[0][0]
+                affected = set(r for r in affected if r <= max_stored)
+
+        if affected:
             repo.ui.log('evoext-cache', 'obshashcache clean - '
                         'new markers affect %d changeset and cached ranges\n'
                         % len(affected))
--- a/tests/test-discovery-obshashrange.t	Thu Aug 16 20:49:55 2018 +0200
+++ b/tests/test-discovery-obshashrange.t	Thu Aug 16 21:18:18 2018 +0200
@@ -447,7 +447,6 @@
   * @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)
-  * @0000000000000000000000000000000000000000 (*)> obshashcache clean - new markers affect 2 changeset and cached ranges (glob)
   * @0000000000000000000000000000000000000000 (*)> updated evo-ext-obshashrange in *.???? seconds (0r, 2o) (glob)
   * @0000000000000000000000000000000000000000 (*)> -R server serve --stdio exited 0 after *.?? seconds (glob)
   * @0000000000000000000000000000000000000000 (*)> -R ../server blackbox (glob)