From e934ba1bb78e65636c4fb556a6bd40cb40e4df08 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Thu, 20 Oct 2016 09:41:29 +0200 Subject: [PATCH] Move updating of excuses into policies It is unwieldy to have one half of output data generation in the policy but not the other half of updating the excuse. Now that apply_policy() gets the excuse object as argument we can move everything there. Signed-off-by: Niels Thykier --- britney.py | 39 ++------------------------------------- policies/policy.py | 40 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/britney.py b/britney.py index c715e3e..cb67648 100755 --- a/britney.py +++ b/britney.py @@ -1620,46 +1620,11 @@ class Britney(object): if policy_verdict.is_rejected: update_candidate = False - # Joggle some things into excuses - # - remove once the YAML is the canonical source for this information - if 'age' in policy_info: - age_info = policy_info['age'] - age_hint = age_info.get('age-requirement-reduced', None) - age_min_req = age_info['age-requirement'] - if age_hint: - new_req = age_hint['new-requirement'] - who = age_hint['changed-by'] - if new_req: - excuse.addhtml("Overriding age needed from %d days to %d by %s" % ( - age_min_req, new_req, who)) - else: - excuse.addhtml("Too young, but urgency pushed by %s" % who) - excuse.setdaysold(age_info['current-age'], age_min_req) - # if the suite is unstable, then we have to check the release-critical bug lists before # updating testing; if the unstable package has RC bugs that do not apply to the testing # one, the check fails and we set update_candidate to False to block the update - if 'rc-bugs' in policy_info: - rcbugs_info = policy_info['rc-bugs'] - new_bugs = rcbugs_info['unique-source-bugs'] - old_bugs = rcbugs_info['unique-target-bugs'] - - excuse.setbugs(old_bugs, new_bugs) - - if new_bugs: - excuse.addhtml("%s has new bugs!" % (src, quote(src))) - excuse.addhtml("Updating %s introduces new bugs: %s" % (src, ", ".join( - ["#%s" % (quote(a), a) for a in new_bugs]))) - update_candidate = False - - if old_bugs: - excuse.addhtml("Updating %s fixes old bugs: %s" % (src, ", ".join( - ["#%s" % (quote(a), a) for a in old_bugs]))) - if new_bugs and len(old_bugs) > len(new_bugs): - excuse.addhtml("%s introduces new bugs, so still ignored (even " - "though it fixes more than it introduces, whine at debian-release)" % src) + if excuse.newbugs: + update_candidate = False if suite in ('pu', 'tpu') and source_t: # o-o-d(ish) checks for (t-)p-u diff --git a/policies/policy.py b/policies/policy.py index 31f74e8..50bbe5f 100644 --- a/policies/policy.py +++ b/policies/policy.py @@ -3,6 +3,7 @@ from enum import Enum, unique import apt_pkg import os import time +from urllib.parse import quote from hints import Hint, split_into_one_hint_per_package @@ -262,6 +263,8 @@ class AgePolicy(BasePolicy): } min_days = new_req + res = PolicyVerdict.PASS + if days_old < min_days: urgent_hints = self.hints.search('urgent', package=source_name, version=source_data_srcdist.version) @@ -270,11 +273,24 @@ class AgePolicy(BasePolicy): 'new-requirement': 0, 'changed-by': urgent_hints[0].user } - return PolicyVerdict.PASS_HINTED + res = PolicyVerdict.PASS_HINTED + else: + res = PolicyVerdict.REJECTED_TEMPORARILY + + # update excuse + age_hint = age_info.get('age-requirement-reduced', None) + age_min_req = age_info['age-requirement'] + if age_hint: + new_req = age_hint['new-requirement'] + who = age_hint['changed-by'] + if new_req: + excuse.addhtml("Overriding age needed from %d days to %d by %s" % ( + age_min_req, new_req, who)) else: - return PolicyVerdict.REJECTED_TEMPORARILY + excuse.addhtml("Too young, but urgency pushed by %s" % who) + excuse.setdaysold(age_info['current-age'], age_min_req) - return PolicyVerdict.PASS + return res def _read_dates_file(self): """Parse the dates file""" @@ -475,6 +491,24 @@ class RCBugPolicy(BasePolicy): rcbugs_info['unique-source-bugs'] = sorted(bugs_u - bugs_t) rcbugs_info['unique-target-bugs'] = sorted(bugs_t - bugs_u) + # update excuse + new_bugs = rcbugs_info['unique-source-bugs'] + old_bugs = rcbugs_info['unique-target-bugs'] + excuse.setbugs(old_bugs, new_bugs) + if new_bugs: + excuse.addhtml("%s has new bugs!" % (source_name, quote(source_name))) + excuse.addhtml("Updating %s introduces new bugs: %s" % (source_name, ", ".join( + ["#%s" % (quote(a), a) for a in new_bugs]))) + + if old_bugs: + excuse.addhtml("Updating %s fixes old bugs: %s" % (source_name, ", ".join( + ["#%s" % (quote(a), a) for a in old_bugs]))) + if new_bugs and len(old_bugs) > len(new_bugs): + excuse.addhtml("%s introduces new bugs, so still ignored (even " + "though it fixes more than it introduces, whine at debian-release)" % source_name) + if not bugs_u or bugs_u <= bugs_t: return success_verdict return PolicyVerdict.REJECTED_PERMANENTLY