obshashcache: purge the meta line before writing a new one
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 17 May 2017 13:16:18 +0200
changeset 2391 80d6a2ad7b11
parent 2390 caddf846ca1e
child 2392 6be71b8f3408
obshashcache: purge the meta line before writing a new one Otherwise we get multiple lines and this gets messy.
hgext3rd/evolve/obsdiscovery.py
--- a/hgext3rd/evolve/obsdiscovery.py	Wed May 17 13:14:50 2017 +0200
+++ b/hgext3rd/evolve/obsdiscovery.py	Wed May 17 13:16:18 2017 +0200
@@ -408,6 +408,7 @@
     "CREATE INDEX range_index ON obshashrange(rev, idx);",
 ]
 _queryexist = "SELECT name FROM sqlite_master WHERE type='table' AND name='meta';"
+_clearmeta = """DELETE FROM meta;"""
 _newmeta = """INSERT INTO meta (schemaversion, tiprev, tipnode, nbobsmarker, obssize, obskey)
             VALUES (?,?,?,?,?,?);"""
 _updateobshash = "INSERT INTO obshashrange(rev, idx, obshash) VALUES (?,?,?);"
@@ -585,6 +586,7 @@
         data = ((rangeid[0], rangeid[1], self.get(rangeid)) for rangeid in self._new)
         con.executemany(_updateobshash, data)
         cachekey = self._fullcachekey
+        con.execute(_clearmeta) # remove the older entry
         con.execute(_newmeta, cachekey)
         con.commit()
         self._new.clear()