Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/vcs/
Date: Fri, 30 May 2014 13:03:38
Message-Id: 1401402981.3418e0f2e3fd983c61a1731eee6bb737325f9cba.dol-sen@gentoo
1 commit: 3418e0f2e3fd983c61a1731eee6bb737325f9cba
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Thu May 29 22:29:13 2014 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Thu May 29 22:36:21 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3418e0f2
7
8 repoman/main.py: Split out vcsstatus.py with VCSStatus class
9
10 This class scans the vcs to determine ebuilds not added.
11
12 ---
13 pym/repoman/main.py | 81 +++----------------------
14 pym/repoman/vcs/vcsstatus.py | 137 +++++++++++++++++++++++++++++++++++++++++++
15 2 files changed, 146 insertions(+), 72 deletions(-)
16
17 diff --git a/pym/repoman/main.py b/pym/repoman/main.py
18 index ee70735..f48c8ba 100755
19 --- a/pym/repoman/main.py
20 +++ b/pym/repoman/main.py
21 @@ -83,6 +83,7 @@ from repoman._subprocess import repoman_popen, repoman_getstatusoutput
22 from repoman import utilities
23 from repoman.vcs.vcs import (git_supports_gpg_sign, vcs_files_to_cps,
24 vcs_new_changed, VCSSettings)
25 +from repoman.vcs.vcsstatus import VCSStatus
26 from repoman._xml import _XMLParser, _MetadataTreeBuilder, XmlLint
27
28
29 @@ -449,78 +450,14 @@ for xpkg in effective_scanlist:
30 if f is not None:
31 f.close()
32
33 - if vcs_settings.vcs in ("git", "hg") and check_ebuild_notadded:
34 - if vcs_settings.vcs == "git":
35 - myf = repoman_popen(
36 - "git ls-files --others %s" %
37 - (portage._shell_quote(checkdir_relative),))
38 - if vcs_settings.vcs == "hg":
39 - myf = repoman_popen(
40 - "hg status --no-status --unknown %s" %
41 - (portage._shell_quote(checkdir_relative),))
42 - for l in myf:
43 - if l[:-1][-7:] == ".ebuild":
44 - stats["ebuild.notadded"] += 1
45 - fails["ebuild.notadded"].append(
46 - os.path.join(xpkg, os.path.basename(l[:-1])))
47 - myf.close()
48 -
49 - if vcs_settings.vcs in ("cvs", "svn", "bzr") and check_ebuild_notadded:
50 - try:
51 - if vcs_settings.vcs == "cvs":
52 - myf = open(checkdir + "/CVS/Entries", "r")
53 - if vcs_settings.vcs == "svn":
54 - myf = repoman_popen(
55 - "svn status --depth=files --verbose " +
56 - portage._shell_quote(checkdir))
57 - if vcs_settings.vcs == "bzr":
58 - myf = repoman_popen(
59 - "bzr ls -v --kind=file " +
60 - portage._shell_quote(checkdir))
61 - myl = myf.readlines()
62 - myf.close()
63 - for l in myl:
64 - if vcs_settings.vcs == "cvs":
65 - if l[0] != "/":
66 - continue
67 - splitl = l[1:].split("/")
68 - if not len(splitl):
69 - continue
70 - if splitl[0][-7:] == ".ebuild":
71 - eadded.append(splitl[0][:-7])
72 - if vcs_settings.vcs == "svn":
73 - if l[:1] == "?":
74 - continue
75 - if l[:7] == ' >':
76 - # tree conflict, new in subversion 1.6
77 - continue
78 - l = l.split()[-1]
79 - if l[-7:] == ".ebuild":
80 - eadded.append(os.path.basename(l[:-7]))
81 - if vcs_settings.vcs == "bzr":
82 - if l[1:2] == "?":
83 - continue
84 - l = l.split()[-1]
85 - if l[-7:] == ".ebuild":
86 - eadded.append(os.path.basename(l[:-7]))
87 - if vcs_settings.vcs == "svn":
88 - myf = repoman_popen(
89 - "svn status " +
90 - portage._shell_quote(checkdir))
91 - myl = myf.readlines()
92 - myf.close()
93 - for l in myl:
94 - if l[0] == "A":
95 - l = l.rstrip().split(' ')[-1]
96 - if l[-7:] == ".ebuild":
97 - eadded.append(os.path.basename(l[:-7]))
98 - except IOError:
99 - if vcs_settings.vcs == "cvs":
100 - stats["CVS/Entries.IO_error"] += 1
101 - fails["CVS/Entries.IO_error"].append(checkdir + "/CVS/Entries")
102 - else:
103 - raise
104 - continue
105 +###############
106 + status_check = VCSStatus(vcs_settings, checkdir, checkdir_relative, xpkg)
107 + status_check.check(check_ebuild_notadded)
108 + eadded.extend(status_check.eadded)
109 + for key in list(status_check.stats):
110 + stats[key] += status_check.stats[key]
111 + fails[key].extend(status_check.fails[key])
112 +###############
113
114 mf = repoman_settings.repositories.get_repo_for_location(
115 os.path.dirname(os.path.dirname(checkdir)))
116
117 diff --git a/pym/repoman/vcs/vcsstatus.py b/pym/repoman/vcs/vcsstatus.py
118 new file mode 100644
119 index 0000000..4f57c42
120 --- /dev/null
121 +++ b/pym/repoman/vcs/vcsstatus.py
122 @@ -0,0 +1,137 @@
123 +
124 +
125 +import portage
126 +from portage import os
127 +
128 +from repoman._subprocess import repoman_popen
129 +
130 +
131 +
132 +class VCSStatus(object):
133 + '''Determines the status of the vcs repositories
134 + to determine if files are not added'''
135 +
136 + def __init__(self, vcs_settings, checkdir, checkdir_relative, xpkg):
137 + self.vcs_settings = vcs_settings
138 + self.vcs = vcs_settings.vcs
139 + self.eadded = []
140 + self.checkdir = checkdir
141 + self.checkdir_relative = checkdir_relative
142 + self.xpkg = xpkg
143 + self.stats = {}
144 + self.fails = {}
145 +
146 +
147 + def check(self, check_not_added):
148 + if check_not_added:
149 + vcscheck = getattr(self, 'check_%s' % self.vcs)
150 + vcscheck()
151 +
152 +
153 + def post_git_hg(self, myf):
154 + for l in myf:
155 + if l[:-1][-7:] == ".ebuild":
156 + if "ebuild.notadded" in list(self.fails):
157 + self.stats["ebuild.notadded"] += 1
158 + self.fails["ebuild.notadded"].append(
159 + os.path.join(self.xpkg, os.path.basename(l[:-1])))
160 + else:
161 + self.stats["ebuild.notadded"] = 1
162 + self.fails["ebuild.notadded"] = [os.path.join(
163 + self.xpkg, os.path.basename(l[:-1]))]
164 + myf.close()
165 +
166 +
167 + def check_git(self):
168 + myf = repoman_popen(
169 + "git ls-files --others %s" %
170 + (portage._shell_quote(self.checkdir_relative),))
171 + self.post_git_hg(myf)
172 +
173 +
174 + def check_hg(self):
175 + myf = repoman_popen(
176 + "hg status --no-status --unknown %s" %
177 + (portage._shell_quote(self.checkdir_relative),))
178 + self.post_git_hg(myf)
179 +
180 +
181 + def check_cvs(self):
182 + try:
183 + myf = open(self.checkdir + "/CVS/Entries", "r")
184 + myl = myf.readlines()
185 + myf.close()
186 + for l in myl:
187 + if l[0] != "/":
188 + continue
189 + splitl = l[1:].split("/")
190 + if not len(splitl):
191 + continue
192 + if splitl[0][-7:] == ".ebuild":
193 + self.eadded.append(splitl[0][:-7])
194 + except IOError:
195 + if "CVS/Entries.IO_error" in list(self.fails):
196 + self.stats["CVS/Entries.IO_error"] += 1
197 + self.fails["CVS/Entries.IO_error"].append(
198 + self.checkdir + "/CVS/Entries")
199 + else:
200 + self.stats["CVS/Entries.IO_error"] = 1
201 + self.fails["CVS/Entries.IO_error"] = [
202 + self.checkdir + "/CVS/Entries"]
203 + return True
204 +
205 +
206 + def check_svn(self):
207 + try:
208 + myf = repoman_popen(
209 + "svn status --depth=files --verbose " +
210 + portage._shell_quote(self.checkdir))
211 + myl = myf.readlines()
212 + myf.close()
213 + for l in myl:
214 + if l[:1] == "?":
215 + continue
216 + if l[:7] == ' >':
217 + # tree conflict, new in subversion 1.6
218 + continue
219 + l = l.split()[-1]
220 + if l[-7:] == ".ebuild":
221 + self.eadded.append(os.path.basename(l[:-7]))
222 + except IOError:
223 + raise
224 + return True
225 +
226 +
227 + def check_bzr(self):
228 + try:
229 + myf = repoman_popen(
230 + "bzr ls -v --kind=file " +
231 + portage._shell_quote(self.checkdir))
232 + myl = myf.readlines()
233 + myf.close()
234 + for l in myl:
235 + if l[1:2] == "?":
236 + continue
237 + l = l.split()[-1]
238 + if l[-7:] == ".ebuild":
239 + self.eadded.append(os.path.basename(l[:-7]))
240 + except IOError:
241 + raise
242 + return True
243 +
244 +
245 + def post_cvs_svn_bzr(self, myf):
246 + if self.vcs == "svn":
247 + myf = repoman_popen(
248 + "svn status " +
249 + portage._shell_quote(self.checkdir))
250 + myl = myf.readlines()
251 + myf.close()
252 + for l in myl:
253 + if l[0] == "A":
254 + l = l.rstrip().split(' ')[-1]
255 + if l[-7:] == ".ebuild":
256 + self.eadded.append(os.path.basename(l[:-7]))
257 + else:
258 + raise
259 + #continue