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 <niels@thykier.net>
email-direct-upload-sponsor
Martin Pitt 8 years ago committed by Niels Thykier
parent dc52f019bc
commit e934ba1bb7

@ -1620,47 +1620,12 @@ 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 <a href=\"https://bugs.debian.org/cgi-bin/pkgreport.cgi?" \
"src=%s&sev-inc=critical&sev-inc=grave&sev-inc=serious\" " \
"target=\"_blank\">has new bugs</a>!" % (src, quote(src)))
excuse.addhtml("Updating %s introduces new bugs: %s" % (src, ", ".join(
["<a href=\"https://bugs.debian.org/%s\">#%s</a>" % (quote(a), a) for a in new_bugs])))
if excuse.newbugs:
update_candidate = False
if old_bugs:
excuse.addhtml("Updating %s fixes old bugs: %s" % (src, ", ".join(
["<a href=\"https://bugs.debian.org/%s\">#%s</a>" % (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 suite in ('pu', 'tpu') and source_t:
# o-o-d(ish) checks for (t-)p-u
# This only makes sense if the package is actually in testing.

@ -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 <a href=\"https://bugs.debian.org/cgi-bin/pkgreport.cgi?" \
"src=%s&sev-inc=critical&sev-inc=grave&sev-inc=serious\" " \
"target=\"_blank\">has new bugs</a>!" % (source_name, quote(source_name)))
excuse.addhtml("Updating %s introduces new bugs: %s" % (source_name, ", ".join(
["<a href=\"https://bugs.debian.org/%s\">#%s</a>" % (quote(a), a) for a in new_bugs])))
if old_bugs:
excuse.addhtml("Updating %s fixes old bugs: %s" % (source_name, ", ".join(
["<a href=\"https://bugs.debian.org/%s\">#%s</a>" % (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

Loading…
Cancel
Save