Mercurial > kallithea
changeset 6048:19e619f3cde1
pullrequests: better handling of Mercurial pullrequests with missing revisions - don't crash
Trying to display a Mercurial PR with missing changesets could give a crash
when trying to compute available updates after 3f646f7bac39 did that
c.cs_ranges could be empty. That would normally not happen on Mercurial, but
could happen when restoring an old filesystem backup ... or when using strip on
the server.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Thu, 28 Jul 2016 16:28:34 +0200 |
parents | f6376261296d |
children | 97a4b5c47cc1 |
files | kallithea/controllers/pullrequests.py kallithea/templates/pullrequests/pullrequest_show.html |
diffstat | 2 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/controllers/pullrequests.py Wed Jun 15 18:33:27 2016 +0200 +++ b/kallithea/controllers/pullrequests.py Thu Jul 28 16:28:34 2016 +0200 @@ -576,6 +576,8 @@ for x in c.pull_request.revisions] except ChangesetDoesNotExistError: c.cs_ranges = [] + h.flash(_('Revision %s not found in %s') % (x, c.cs_repo.repo_name), + 'error') c.cs_ranges_org = None # not stored and not important and moving target - could be calculated ... revs = [ctx.revision for ctx in reversed(c.cs_ranges)] c.jsdata = json.dumps(graph_data(org_scm_instance, revs)) @@ -600,7 +602,9 @@ c.update_msg = "" c.update_msg_other = "" try: - if org_scm_instance.alias == 'hg' and c.a_ref_name != 'ancestor': + if not c.cs_ranges: + c.update_msg = _('Error: changesets not found when displaying pull request from %s.') % c.cs_rev + elif org_scm_instance.alias == 'hg' and c.a_ref_name != 'ancestor': if c.cs_ref_type != 'branch': c.cs_branch_name = org_scm_instance.get_changeset(c.cs_ref_name).branch # use ref_type ? c.a_branch_name = c.a_ref_name @@ -654,7 +658,7 @@ c.cs_repo.scm_instance.get_changeset(c.cs_rev) # check it exists - raise ChangesetDoesNotExistError if not c.update_msg = _("Git pull requests don't support iterating yet.") except ChangesetDoesNotExistError: - c.update_msg = _('Error: revision %s was not found. Please create a new pull request!') % c.cs_rev + c.update_msg = _('Error: some changesets not found when displaying pull request from %s.') % c.cs_rev c.avail_revs = avail_revs c.avail_cs = [org_scm_instance.get_changeset(r) for r in avail_show]
--- a/kallithea/templates/pullrequests/pullrequest_show.html Wed Jun 15 18:33:27 2016 +0200 +++ b/kallithea/templates/pullrequests/pullrequest_show.html Thu Jul 28 16:28:34 2016 +0200 @@ -133,6 +133,7 @@ <label>${_('Pull changes')}:</label> </div> <div class="input"> + %if c.cs_ranges: <div> ## TODO: use cs_ranges[-1] or org_ref_parts[1] in both cases? %if h.is_hg(c.pull_request.org_repo): @@ -141,6 +142,7 @@ <span style="font-family: monospace">git pull ${c.pull_request.org_repo.clone_url()} ${c.pull_request.org_ref_parts[1]}</span> %endif </div> + %endif </div> </div> <div class="field"> @@ -180,7 +182,7 @@ <table id="updaterevs-table" class="noborder" style="padding-left:50px"> %for cnt, cs in enumerate(c.avail_cs): <tr id="chg_available_${cnt+1}"> - %if cs.revision == c.cs_ranges[-1].revision: + %if c.cs_ranges and cs.revision == c.cs_ranges[-1].revision: <td> %if editable: ${h.radio(name='updaterev', value='', checked=True)}