Changeset - a8b407f29405
[Not reviewed]
stable
0 1 0
Manuel Jacob - 4 years ago 2022-02-25 22:00:46
me@manueljacob.de
controllers: don’t pass start=0 to BaseRepository.get_changesets()

MercurialRepository.get_changesets() can fail if passing start=0 if the
revision 0 is not in self.revisions. That can happen if revision 0 is not in
the visible subset of the revisions in the repository. Before Kallithea
changeset 7c43e15fb8bc7a73f17f577e59a4698589b6809d, it was working by chance
because start=0 was treated like start=None in the relevant places
(GitRepository.get_changesets still does that).

The intention of passing start=0 was seemingly to not limit the start.
Therefore passing start=None (or nothing, as it’s the default value) should be
correct.

I got the following traceback before this change:

Traceback (most recent call last):
File "~/vcs/kallithea/kallithea/controllers/changelog.py", line 117, in index
collection = c.db_repo_scm_instance.get_changesets(start=0, end=revision,
File "~/vcs/kallithea/kallithea/lib/vcs/backends/hg/repository.py", line 529, in get_changesets
start_pos = None if start is None else self.revisions.index(start_raw_id)
ValueError: '4257f758b3eaacaebb6956d1aefc019afab956b8' is not in list
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/changelog.py
Show inline comments
 
@@ -114,7 +114,7 @@ class ChangelogController(base.BaseRepoC
 
                        webutils.flash(e, category='warning')
 
                        raise HTTPFound(location=webutils.url('changelog_home', repo_name=repo_name))
 
            else:
 
                collection = c.db_repo_scm_instance.get_changesets(start=0, end=revision,
 
                collection = c.db_repo_scm_instance.get_changesets(end=revision,
 
                                                        branch_name=branch_name, reverse=True)
 
            c.total_cs = len(collection)
 

	
0 comments (0 inline, 0 general)