# HG changeset patch # User Pierre-Yves David # Date 1535366441 -7200 # Node ID 434398b37e16546cbdd88ba535b021527dcb4bd3 # Parent dbeac677e99a6f1e8578e95814232ab90d55c554 stablerange: rework saving logic to be clearer and safer diff -r dbeac677e99a -r 434398b37e16 hgext3rd/evolve/stablerangecache.py --- a/hgext3rd/evolve/stablerangecache.py Mon Aug 27 12:12:49 2018 +0200 +++ b/hgext3rd/evolve/stablerangecache.py Mon Aug 27 12:40:41 2018 +0200 @@ -261,19 +261,20 @@ con = self._db() if con is None: return - con.execute('BEGIN IMMEDIATE;') with con: for req in _sqliteschema: con.execute(req) meta = [self._schemaversion, - self._tiprev, - self._tipnode, + nodemod.nullrev, + nodemod.nullid, ] con.execute(_newmeta, meta) + self._ondisktiprev = nodemod.nullrev + self._ondisktipnode = nodemod.nullid else: con = self._con - con.execute('BEGIN IMMEDIATE;') + with con: meta = con.execute(_querymeta).fetchone() if meta[2] != self._ondisktipnode or meta[1] != self._ondisktiprev: # drifting is currently an issue because this means another @@ -286,15 +287,14 @@ nodemod.hex(self._ondisktipnode), self._ondisktiprev) repo.ui.warn(msg) repo.ui.warn(hint % data) - con.execute('ROLLBACK;') + self._unsavedsubranges.clear() return - meta = [self._tiprev, - self._tipnode, - ] - con.execute(_updatemeta, meta) - - self._saverange(con, repo) - con.commit() + else: + self._saverange(con, repo) + meta = [self._tiprev, + self._tipnode, + ] + con.execute(_updatemeta, meta) self._ondisktiprev = self._tiprev self._ondisktipnode = self._tipnode self._unsavedsubranges.clear()