Mercurial > evolve
changeset 4012:dbeac677e99a
obshashrange: rework saving branching to be clearer and safer
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 27 Aug 2018 12:12:49 +0200 |
parents | 3cb41bf56f16 |
children | 434398b37e16 |
files | hgext3rd/evolve/obsdiscovery.py |
diffstat | 1 files changed, 17 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/obsdiscovery.py Mon Aug 27 11:40:32 2018 +0200 +++ b/hgext3rd/evolve/obsdiscovery.py Mon Aug 27 12:12:49 2018 +0200 @@ -614,9 +614,12 @@ for req in _sqliteschema: con.execute(req) - con.execute(_newmeta, self._fullcachekey) + meta = [self._schemaversion] + list(self.emptykey) + con.execute(_newmeta, meta) + self._ondiskcachekey = self.emptykey else: con = self._con + with con: meta = con.execute(_querymeta).fetchone() if meta[1:] != self._ondiskcachekey: # drifting is currently an issue because this means another @@ -625,17 +628,20 @@ msg = _('obshashrange cache: skipping write, ' 'database drifted under my feet\n') repo.ui.warn(msg) + self._new.clear() + self._valid = False + if '_con' in vars(self): + del self._con + self._valid = False return - 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() - self._ondiskcachekey = self._cachekey - self._valid = True - + 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) + self._new.clear() + self._valid = True + self._ondiskcachekey = self._cachekey @eh.wrapfunction(obsolete.obsstore, '_addmarkers') def _addmarkers(orig, obsstore, *args, **kwargs): obsstore.rangeobshashcache.clear()