# HG changeset patch # User Pierre-Yves David # Date 1535322499 -7200 # Node ID b3517f834f83831d7897e7ca205c7dbdb46d7aac # Parent c307ce1d9009b0623d05441f70f9cc932276c930 sqlcache: cache OperationError when saving This is a cache, so we should not crash when trying to operate on it. OperationError can happens when the database is seen as readonly or locked. diff -r c307ce1d9009 -r b3517f834f83 hgext3rd/evolve/obsdiscovery.py --- a/hgext3rd/evolve/obsdiscovery.py Mon Aug 27 00:18:06 2018 +0200 +++ b/hgext3rd/evolve/obsdiscovery.py Mon Aug 27 00:28:19 2018 +0200 @@ -568,6 +568,12 @@ repo.ui.warn(msg) def _save(self, repo): + try: + return self._trysave(repo) + except sqlite3.OperationalError as exc: + repo.ui.log('evoext-cache', 'error while saving new data: %s' % exc) + + def _trysave(self, repo): if self._con is None: util.unlinkpath(self._path, ignoremissing=True) if '_con' in vars(self): diff -r c307ce1d9009 -r b3517f834f83 hgext3rd/evolve/stablerangecache.py --- a/hgext3rd/evolve/stablerangecache.py Mon Aug 27 00:18:06 2018 +0200 +++ b/hgext3rd/evolve/stablerangecache.py Mon Aug 27 00:28:19 2018 +0200 @@ -223,6 +223,12 @@ return con def _save(self, repo): + try: + return self._trysave(repo) + except sqlite3.OperationalError as exc: + repo.ui.log('evoext-cache', 'error while saving new data: %s' % exc) + + def _trysave(self, repo): repo = repo.unfiltered() repo.depthcache.save(repo) repo.stablesort.save(repo)