[PATCH] pullrequests: introduce limit to stop displaying additional changes

Mathias De Mare mathias.de_mare at nokia.com
Wed Jan 18 06:45:20 UTC 2023


# HG changeset patch
# User Mathias De Mare <mathias.de_mare at nokia.com>
# Date 1672834977 -3600
#      Wed Jan 04 13:22:57 2023 +0100
# Branch stable
# Node ID ac278c9c011136b72de43d8dbd742f9cf3dbf020
# Parent  b7efb8fdc45fb95ce8ece04e1aed7d965c300bae
pullrequests: introduce limit to stop displaying additional changes

The previous pull request threw away some of the changesets
to keep the total amount more manageable, but this results
in an (for the user) unpredictable subset of changesets being shown.

To resolve this issue, we instead do not display any additional changes
if the amount of additional changes is larger than a user-defined limit.

This could be extended further with "too long to be shown - click here
to show", but that was quite a bit of additional work
and did not cover our use case of not allowing the display at all
in case of too many additional changes.

diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py
--- a/kallithea/controllers/pullrequests.py
+++ b/kallithea/controllers/pullrequests.py
@@ -35,6 +35,8 @@ from tg import tmpl_context as c
 from tg.i18n import ugettext as _
 from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPFound, HTTPNotFound
 
+import kallithea
+
 import kallithea.lib.helpers as h
 from kallithea.controllers import base
 from kallithea.controllers.changeset import create_cs_pr_comment, delete_cs_pr_comment
@@ -494,6 +496,8 @@ class PullrequestsController(base.BaseRe
         except IndexError: # probably because c.cs_ranges is empty, probably because revisions are missing
             pass
 
+        rev_limit = safe_int(kallithea.CONFIG.get('next_iteration_rev_limit'), 0)
+
         avail_revs = set()
         avail_show = []
         c.cs_branch_name = c.cs_ref_name
@@ -563,9 +567,16 @@ class PullrequestsController(base.BaseRe
         except ChangesetDoesNotExistError:
             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]
-        c.avail_jsdata = graph_data(org_scm_instance, avail_show)
+        if rev_limit and len(avail_revs) > rev_limit:
+            c.update_msg = _('Additional changesets (%d) are not shown because they exceed the limit (%d).') % (len(avail_revs), rev_limit)
+            c.avail_revs = []
+            c.avail_cs = []
+            c.avail_jsdata = None
+        else:
+            c.rev_limit_reached = False
+            c.avail_revs = avail_revs
+            c.avail_cs = [org_scm_instance.get_changeset(r) for r in avail_show]
+            c.avail_jsdata = graph_data(org_scm_instance, avail_show)
 
         raw_ids = [x.raw_id for x in c.cs_ranges]
         c.cs_comments = c.cs_repo.get_comments(raw_ids)



More information about the kallithea-general mailing list