Merge ~rbalint/britney/+git/britney2-ubuntu:master into ~ubuntu-release/britney/+git/britney2-ubuntu:master

Proposed by Balint Reczey
Status: Merged
Merged at revision: da5770559c0f8634ea18084e1060de2eda9b3fbc
Proposed branch: ~rbalint/britney/+git/britney2-ubuntu:master
Merge into: ~ubuntu-release/britney/+git/britney2-ubuntu:master
Diff against target: 84 lines (+50/-1)
2 files modified
britney.py (+5/-1)
britney2/policies/policy.py (+45/-0)
Reviewer Review Type Date Requested Status
Adam Conrad (community) Approve
Review via email: mp+372862@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Adam Conrad (adconrad) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/britney.py b/britney.py
2index 52932bc..37d6256 100755
3--- a/britney.py
4+++ b/britney.py
5@@ -65,6 +65,9 @@ Other than source and binary packages, Britney loads the following data:
6 * Blocks, which contains user-supplied blocks read from Launchpad bugs
7 (see LPBlockBugPolicy).
8
9+ * ExcuseBugs, which contains user-supplied update-excuse read from
10+ Launchpad bugs (see LPExcuseBugsPolicy).
11+
12 For a more detailed explanation about the format of these files, please read
13 the documentation of the related methods. The exact meaning of them will be
14 instead explained in the chapter "Excuses Generation".
15@@ -202,7 +205,7 @@ from britney2.hints import HintParser
16 from britney2.installability.builder import build_installability_tester, ma_parse_depends
17 from britney2.migrationitem import MigrationItem
18 from britney2.policies.policy import AgePolicy, RCBugPolicy, PiupartsPolicy, PolicyVerdict
19-from britney2.policies.policy import LPBlockBugPolicy
20+from britney2.policies.policy import LPBlockBugPolicy, LPExcuseBugsPolicy
21 from britney2.policies.autopkgtest import AutopkgtestPolicy
22 from britney2.policies.sourceppa import SourcePPAPolicy
23 from britney2.policies.sruadtregression import SRUADTRegressionPolicy
24@@ -536,6 +539,7 @@ class Britney(object):
25 # Piuparts is noisy & not used by Ubuntu (LP: #1651537)
26 # self.policies.append(PiupartsPolicy(self.options, self.suite_info))
27 self.policies.append(LPBlockBugPolicy(self.options, self.suite_info))
28+ self.policies.append(LPExcuseBugsPolicy(self.options, self.suite_info))
29 if getattr(self.options, 'adt_enable') == 'yes':
30 self.policies.append(AutopkgtestPolicy(self.options, self.suite_info))
31 self.policies.append(SourcePPAPolicy(self.options, self.suite_info))
32diff --git a/britney2/policies/policy.py b/britney2/policies/policy.py
33index 4a231ce..a81db75 100644
34--- a/britney2/policies/policy.py
35+++ b/britney2/policies/policy.py
36@@ -698,3 +698,48 @@ class LPBlockBugPolicy(BasePolicy):
37 excuse.addreason('block')
38
39 return PolicyVerdict.REJECTED_PERMANENTLY
40+
41+class LPExcuseBugsPolicy(BasePolicy):
42+ """update-excuse Launchpad bug policy to link to a bug report, does not prevent migration
43+
44+ This policy will read an user-supplied "ExcuseBugs" file from the unstable
45+ directory (provided by an external script) with rows of the following
46+ format:
47+
48+ <source-name> <bug> <date>
49+
50+ The dates are expressed as the number of seconds from the Unix epoch
51+ (1970-01-01 00:00:00 UTC).
52+ """
53+ def __init__(self, options, suite_info):
54+ super().__init__('update-excuse', options, suite_info, {'unstable'})
55+
56+ def initialise(self, britney):
57+ super().initialise(britney)
58+ self.excuse_bugs = {} # srcpkg -> [(bug, date), ...]
59+
60+ filename = os.path.join(self.options.unstable, "ExcuseBugs")
61+ self.log("Loading user-supplied excuse bug data from %s" % filename)
62+ for line in open(filename):
63+ l = line.split()
64+ if len(l) != 3:
65+ self.log("ExcuseBugs, ignoring malformed line %s" % line, type='W')
66+ continue
67+ try:
68+ self.excuse_bugs.setdefault(l[0], [])
69+ self.excuse_bugs[l[0]].append((l[1], int(l[2])))
70+ except ValueError:
71+ self.log("ExcuseBugs, unable to parse \"%s\"" % line, type='E')
72+
73+ def apply_policy_impl(self, excuse_bugs_info, suite, source_name, source_data_tdist, source_data_srcdist, excuse):
74+ try:
75+ excuse_bug = self.excuse_bugs[source_name]
76+ except KeyError:
77+ return PolicyVerdict.PASS
78+
79+ for bug, date in excuse_bug:
80+ excuse_bugs_info[bug] = date
81+ excuse.addhtml("Also see <a href=\"https://launchpad.net/bugs/%s\">bug %s</a> last updated on %s" %
82+ (bug, bug, time.asctime(time.gmtime(date))))
83+
84+ return PolicyVerdict.PASS

Subscribers

People subscribed via source and target branches