1. Software Freedom Conservancy
  2. Kallithea
  3. kallithea
  4. Issues

Issues

Issue #27 resolved

Viewing a pull request for empty origin results in error

Stefan Walter
created an issue

Playing around with our 0.1 installation, I...

  1. ...created a new (HG) repository.
  2. ...created a fork of that (still empty) repository.
  3. ...pushed changes to the fork.
  4. ...created a pull request for the changes.
  5. ...tried to open/view the pull request.

The result was an error page being shown and the following stack trace mailed to me:

Module kallithea.controllers.pullrequests:2 in show
Module kallithea.lib.auth:776 in __wrapper
>>  return func(*fargs, **fkwargs)
Module kallithea.controllers.pullrequests:2 in show
Module kallithea.lib.auth:835 in __wrapper
>>  return func(*fargs, **fkwargs)
Module kallithea.controllers.pullrequests:583 in show
>>  other_branch_name = other_scm_instance.get_changeset(c.a_ref_name).branch # use ref_type ?
Module kallithea.lib.vcs.backends.hg.repository:511 in get_changeset
>>  revision = self._get_revision(revision)
Module kallithea.lib.vcs.backends.hg.repository:434 in _get_revision
>>  raise EmptyRepositoryError("There are no changesets yet")
EmptyRepositoryError: There are no changesets yet

Pull requests for empty repositories certainly don't happen too often. Nevertheless, a more graceful reaction would be nice.

Comments (6)

  1. Christophe Combelles

    I just got the same error but a few lines below.

    line 589 on

    targethead = other_scm_instance.get_changeset(c.a_branch_name).raw_id
    

    It occurs when : - I create an empty repository - I fork the repository and create a changeset - I create a PR on the empty original repository - I update the fork with at least one more changeset - I visit the PR →

    (...)
    Module kallithea.controllers.pullrequests:589 in show
    >>  targethead = other_scm_instance.get_changeset(c.a_branch_name).raw_id
    Module kallithea.lib.vcs.backends.hg.repository:499 in get_changeset
    >>  revision = self._get_revision(revision)
    Module kallithea.lib.vcs.backends.hg.repository:416 in _get_revision
    >>  raise EmptyRepositoryError("There are no changesets yet")
    EmptyRepositoryError: There are no changesets yet
    
  2. Christophe Combelles

    How do I reopen this issue?

    The fix is exactly the same as suggested above :

    Replace the line with:

                        try:
                            targethead = other_scm_instance.get_changeset(c.a_branch_name).raw_id
                        except EmptyRepositoryError:
                            targethead = 'null'
    
  3. Log in to comment