1 |
commit: da2a8745c7870c57c2b4025238c0b48acab09c5d |
2 |
Author: Brian Dolbec <bdolbec <AT> gaikai <DOT> com> |
3 |
AuthorDate: Tue Jun 27 17:49:01 2017 +0000 |
4 |
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Jun 27 19:51:21 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=da2a8745 |
7 |
|
8 |
repoman: Move qa_data initialization and loading |
9 |
|
10 |
Move the new QAData class instance init to repoman_main(). |
11 |
parse_args() remove unused qahelp parameter. |
12 |
qa_tracker.py: Add default qacats and qawarnings parameters as None. |
13 |
These will be assigned later due to circular init references. |
14 |
repos.py: Perform the QAData class loading and complete intialization |
15 |
assignments. |
16 |
|
17 |
repoman/pym/repoman/argparser.py | 3 +-- |
18 |
repoman/pym/repoman/main.py | 26 ++++++++++++++------------ |
19 |
repoman/pym/repoman/qa_tracker.py | 10 +++++----- |
20 |
repoman/pym/repoman/repos.py | 12 ++++++++++-- |
21 |
4 files changed, 30 insertions(+), 21 deletions(-) |
22 |
|
23 |
diff --git a/repoman/pym/repoman/argparser.py b/repoman/pym/repoman/argparser.py |
24 |
index 2d56a87e6..68701378f 100644 |
25 |
--- a/repoman/pym/repoman/argparser.py |
26 |
+++ b/repoman/pym/repoman/argparser.py |
27 |
@@ -15,11 +15,10 @@ from portage import _unicode_decode |
28 |
from portage import util |
29 |
|
30 |
|
31 |
-def parse_args(argv, qahelp, repoman_default_opts): |
32 |
+def parse_args(argv, repoman_default_opts): |
33 |
"""Use a customized optionParser to parse command line arguments for repoman |
34 |
Args: |
35 |
argv - a sequence of command line arguments |
36 |
- qahelp - a dict of qa warning to help message |
37 |
Returns: |
38 |
(opts, args), just like a call to parser.parse_args() |
39 |
""" |
40 |
|
41 |
diff --git a/repoman/pym/repoman/main.py b/repoman/pym/repoman/main.py |
42 |
old mode 100755 |
43 |
new mode 100644 |
44 |
index ccc735c7d..3b628de00 |
45 |
--- a/repoman/pym/repoman/main.py |
46 |
+++ b/repoman/pym/repoman/main.py |
47 |
@@ -29,9 +29,8 @@ from portage.util.futures.extendedfutures import ( |
48 |
|
49 |
from repoman.actions import Actions |
50 |
from repoman.argparser import parse_args |
51 |
-from repoman.qa_data import ( |
52 |
- format_qa_output, format_qa_output_column, qahelp, |
53 |
- qawarnings, qacats) |
54 |
+from repoman.qa_data import QAData |
55 |
+from repoman.qa_data import format_qa_output, format_qa_output_column |
56 |
from repoman.repos import RepoSettings |
57 |
from repoman.scanner import Scanner |
58 |
from repoman import utilities |
59 |
@@ -60,7 +59,7 @@ def repoman_main(argv): |
60 |
nocolor() |
61 |
|
62 |
options, arguments = parse_args( |
63 |
- sys.argv, qahelp, repoman_settings.get("REPOMAN_DEFAULT_OPTS", "")) |
64 |
+ sys.argv, repoman_settings.get("REPOMAN_DEFAULT_OPTS", "")) |
65 |
|
66 |
if options.version: |
67 |
print("Repoman", VERSION, "(portage-%s)" % portage.VERSION) |
68 |
@@ -73,10 +72,6 @@ def repoman_main(argv): |
69 |
else: |
70 |
logger.setLevel(LOGLEVEL) |
71 |
|
72 |
- if options.experimental_inherit == 'y': |
73 |
- # This is experimental, so it's non-fatal. |
74 |
- qawarnings.add("inherit.missing") |
75 |
- |
76 |
# Set this to False when an extraordinary issue (generally |
77 |
# something other than a QA issue) makes it impossible to |
78 |
# commit (like if Manifest generation fails). |
79 |
@@ -91,14 +86,21 @@ def repoman_main(argv): |
80 |
|
81 |
# avoid a circular parameter repo_settings |
82 |
vcs_settings = VCSSettings(options, repoman_settings) |
83 |
+ qadata = QAData() |
84 |
|
85 |
+ logging.debug("repoman_main: RepoSettings init") |
86 |
repo_settings = RepoSettings( |
87 |
config_root, portdir, portdir_overlay, |
88 |
- repoman_settings, vcs_settings, options, qawarnings) |
89 |
+ repoman_settings, vcs_settings, options, qadata) |
90 |
repoman_settings = repo_settings.repoman_settings |
91 |
|
92 |
# Now set repo_settings |
93 |
vcs_settings.repo_settings = repo_settings |
94 |
+ # set QATracker qacats, qawarnings |
95 |
+ vcs_settings.qatracker.qacats = repo_settings.qadata.qacats |
96 |
+ vcs_settings.qatracker.qawarnings = repo_settings.qadata.qawarnings |
97 |
+ logging.debug("repoman_main: vcs_settings done") |
98 |
+ logging.debug("repoman_main: qadata: %s", repo_settings.qadata) |
99 |
|
100 |
if 'digest' in repoman_settings.features and options.digest != 'n': |
101 |
options.digest = 'y' |
102 |
@@ -133,11 +135,11 @@ def repoman_main(argv): |
103 |
if options.mode == "manifest": |
104 |
sys.exit(result['fail']) |
105 |
|
106 |
- for x in qacats: |
107 |
+ for x in qadata.qacats: |
108 |
if x not in vcs_settings.qatracker.fails: |
109 |
continue |
110 |
result['warn'] = 1 |
111 |
- if x not in qawarnings: |
112 |
+ if x not in qadata.qawarnings: |
113 |
result['fail'] = 1 |
114 |
|
115 |
if result['fail'] or \ |
116 |
@@ -174,7 +176,7 @@ def repoman_main(argv): |
117 |
format_output = format_outputs.get( |
118 |
options.output_style, format_outputs['default']) |
119 |
format_output(f, vcs_settings.qatracker.fails, result['full'], |
120 |
- result['fail'], options, qawarnings) |
121 |
+ result['fail'], options, qadata.qawarnings) |
122 |
|
123 |
style_file.flush() |
124 |
del console_writer, f, style_file |
125 |
|
126 |
diff --git a/repoman/pym/repoman/qa_tracker.py b/repoman/pym/repoman/qa_tracker.py |
127 |
index 9bfe0e241..faaf8e398 100644 |
128 |
--- a/repoman/pym/repoman/qa_tracker.py |
129 |
+++ b/repoman/pym/repoman/qa_tracker.py |
130 |
@@ -2,15 +2,15 @@ |
131 |
import logging |
132 |
import sys |
133 |
|
134 |
-from repoman.qa_data import qacats, qawarnings |
135 |
- |
136 |
|
137 |
class QATracker(object): |
138 |
'''Track all occurrances of Q/A problems detected''' |
139 |
|
140 |
- def __init__(self): |
141 |
+ def __init__(self, qacats=None, qawarnings=None): |
142 |
self.fails = {} |
143 |
self.warns = {} |
144 |
+ self.qacats = qacats |
145 |
+ self.qawarnings = qawarnings |
146 |
|
147 |
def add_error(self, detected_qa, info): |
148 |
'''Add the Q/A error to the database of detected problems |
149 |
@@ -18,7 +18,7 @@ class QATracker(object): |
150 |
@param detected_qa: string, member of qa_data.qacats list |
151 |
@param info: string, details of the detected problem |
152 |
''' |
153 |
- if detected_qa not in qacats: |
154 |
+ if detected_qa not in self.qacats: |
155 |
logging.error( |
156 |
'QATracker: Exiting on error. Unknown detected_qa type passed ' |
157 |
'in to add_error(): %s, %s' % (detected_qa, info)) |
158 |
@@ -34,7 +34,7 @@ class QATracker(object): |
159 |
@param detected_qa: string, member of qa_data.qawarnings list |
160 |
@param info: string, details of the detected problem |
161 |
''' |
162 |
- if detected_qa not in qawarnings: |
163 |
+ if detected_qa not in self.qawarnings: |
164 |
logging.error( |
165 |
'QATracker: Exiting on error. Unknown detected_qa type passed ' |
166 |
'in to add_warning(): %s, %s' % (detected_qa, info)) |
167 |
|
168 |
diff --git a/repoman/pym/repoman/repos.py b/repoman/pym/repoman/repos.py |
169 |
index 39f53c180..cd917828d 100644 |
170 |
--- a/repoman/pym/repoman/repos.py |
171 |
+++ b/repoman/pym/repoman/repos.py |
172 |
@@ -27,7 +27,7 @@ class RepoSettings(object): |
173 |
def __init__( |
174 |
self, config_root, portdir, portdir_overlay, |
175 |
repoman_settings=None, vcs_settings=None, options=None, |
176 |
- qawarnings=None): |
177 |
+ qadata=None): |
178 |
self.config_root = config_root |
179 |
self.repoman_settings = repoman_settings |
180 |
self.vcs_settings = vcs_settings |
181 |
@@ -41,6 +41,14 @@ class RepoSettings(object): |
182 |
except KeyError: |
183 |
self._add_repo(config_root, portdir_overlay) |
184 |
|
185 |
+ logging.debug("RepoSettings: init(); load qadata") |
186 |
+ # load the repo specific configuration |
187 |
+ self.qadata = qadata |
188 |
+ if not self.qadata.load_repo_config(self.repodir, options): |
189 |
+ logging.error("Aborting...") |
190 |
+ sys.exit(1) |
191 |
+ logging.debug("RepoSettings: qadata loaded", qadata.no_exec) |
192 |
+ |
193 |
self.root = self.repoman_settings['EROOT'] |
194 |
self.trees = { |
195 |
self.root: {'porttree': portage.portagetree(settings=self.repoman_settings)} |
196 |
@@ -60,7 +68,7 @@ class RepoSettings(object): |
197 |
del self.repositories[repo.name] |
198 |
|
199 |
if self.repo_config.allow_provide_virtual: |
200 |
- qawarnings.add("virtual.oldstyle") |
201 |
+ qadata.qawarnings.add("virtual.oldstyle") |
202 |
|
203 |
if self.repo_config.sign_commit and options.mode in ("commit", "fix", "manifest"): |
204 |
if vcs_settings.vcs: |