changeset 8294:38a833e742ea

cli: fix indexing of repos where last indexed revision has been stripped
author Mads Kiilerich <mads@kiilerich.com>
date Thu, 12 Mar 2020 17:07:28 +0100
parents 75e2d061385a
children 8d663d23ab85
files kallithea/lib/indexers/daemon.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/indexers/daemon.py	Thu Mar 12 17:06:56 2020 +0100
+++ b/kallithea/lib/indexers/daemon.py	Thu Mar 12 17:07:28 2020 +0100
@@ -40,7 +40,7 @@
 from kallithea.config.conf import INDEX_EXTENSIONS, INDEX_FILENAMES
 from kallithea.lib.indexers import CHGSET_IDX_NAME, CHGSETS_SCHEMA, IDX_NAME, SCHEMA
 from kallithea.lib.utils2 import safe_str
-from kallithea.lib.vcs.exceptions import ChangesetError, NodeDoesNotExistError, RepositoryError
+from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, ChangesetError, NodeDoesNotExistError, RepositoryError
 from kallithea.model.db import Repository
 from kallithea.model.scm import ScmModel
 
@@ -299,7 +299,11 @@
                         # assuming that there is only one result, if not this
                         # may require a full re-index.
                         start_id = results[0]['raw_id']
-                        last_rev = repo.get_changeset(revision=start_id).revision
+                        try:
+                            last_rev = repo.get_changeset(revision=start_id).revision
+                        except ChangesetDoesNotExistError:
+                            log.error('previous last revision %s not found - indexing from scratch', start_id)
+                            start_id = None
 
                     # there are new changesets to index or a new repo to index
                     if last_rev == 0 or num_of_revs > last_rev + 1: