Mercurial > kallithea
changeset 4506:ac752047284f
pull requests: handle pull requests to empty repos (Issue #27)
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Mon, 08 Sep 2014 13:38:56 +0200 |
parents | 99c914f5fd89 |
children | cd9bb3e07e68 |
files | kallithea/controllers/compare.py kallithea/controllers/pullrequests.py kallithea/lib/base.py |
diffstat | 3 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/controllers/compare.py Mon Sep 08 13:38:56 2014 +0200 +++ b/kallithea/controllers/compare.py Mon Sep 08 13:38:56 2014 +0200 @@ -210,7 +210,8 @@ h.flash(msg, category='error') return redirect(url('compare_home', repo_name=c.repo_name)) - c.a_rev = self._get_ref_rev(org_repo, org_ref_type, org_ref_name) + c.a_rev = self._get_ref_rev(org_repo, org_ref_type, org_ref_name, + returnempty=True) c.cs_rev = self._get_ref_rev(other_repo, other_ref_type, other_ref_name) c.compare_home = False
--- a/kallithea/controllers/pullrequests.py Mon Sep 08 13:38:56 2014 +0200 +++ b/kallithea/controllers/pullrequests.py Mon Sep 08 13:38:56 2014 +0200 @@ -580,7 +580,10 @@ c.cs_branch_name = org_scm_instance.get_changeset(c.cs_ref_name).branch # use ref_type ? other_branch_name = c.a_ref_name if c.a_ref_type != 'branch': - other_branch_name = other_scm_instance.get_changeset(c.a_ref_name).branch # use ref_type ? + try: + other_branch_name = other_scm_instance.get_changeset(c.a_ref_name).branch # use ref_type ? + except EmptyRepositoryError: + other_branch_name = 'null' # not a branch name ... but close enough # candidates: descendants of old head that are on the right branch # and not are the old head itself ... # and nothing at all if old head is a descendent of target ref name
--- a/kallithea/lib/base.py Mon Sep 08 13:38:56 2014 +0200 +++ b/kallithea/lib/base.py Mon Sep 08 13:38:56 2014 +0200 @@ -436,7 +436,7 @@ c.repo_name, self.authuser.user_id) @staticmethod - def _get_ref_rev(repo, ref_type, ref_name): + def _get_ref_rev(repo, ref_type, ref_name, returnempty=False): """ Safe way to get changeset. If error occurs show error. """ @@ -444,6 +444,8 @@ try: return repo.scm_instance.get_ref_revision(ref_type, ref_name) except EmptyRepositoryError as e: + if returnempty: + return repo.scm_instance.EMPTY_CHANGESET h.flash(h.literal(_('There are no changesets yet')), category='error') raise webob.exc.HTTPNotFound()