Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/vcs/, pym/repoman/vcs/modules/hg/, pym/repoman/vcs/modules/, ...
Date: Wed, 30 Dec 2015 23:38:24
Message-Id: 1451517862.018e8a127455b18593d8c07a28df3eef665a7332.dolsen@gentoo
1 commit: 018e8a127455b18593d8c07a28df3eef665a7332
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Wed Dec 30 23:24:22 2015 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Wed Dec 30 23:24:22 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=018e8a12
7
8 initial repoman stage2 vcs plugin system started
9
10 Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>
11
12 pym/repoman/actions.py | 5 +-
13 pym/repoman/main.py | 9 +-
14 pym/repoman/modules/commit/repochecks.py | 5 +-
15 pym/repoman/scanner.py | 9 +-
16 pym/repoman/vcs/__init__.py | 14 +++
17 pym/repoman/vcs/modules/__init__.py | 1 +
18 pym/repoman/vcs/modules/bzr/__init__.py | 23 +++++
19 pym/repoman/vcs/modules/bzr/bzrstatus.py | 36 ++++++++
20 pym/repoman/vcs/modules/cvs/__init__.py | 23 +++++
21 pym/repoman/vcs/modules/cvs/cvsstatus.py | 102 +++++++++++++++++++++
22 pym/repoman/vcs/modules/git/__init__.py | 23 +++++
23 pym/repoman/vcs/modules/git/gitstatus.py | 46 ++++++++++
24 pym/repoman/vcs/modules/hg/__init__.py | 23 +++++
25 pym/repoman/vcs/modules/hg/hgstatus.py | 30 ++++++
26 pym/repoman/vcs/modules/svn/__init__.py | 23 +++++
27 pym/repoman/vcs/modules/svn/svnstatus.py | 121 ++++++++++++++++++++++++
28 pym/repoman/vcs/settings.py | 74 +++++++++++++++
29 pym/repoman/vcs/vcs.py | 152 -------------------------------
30 pym/repoman/vcs/vcsstatus.py | 106 +--------------------
31 19 files changed, 556 insertions(+), 269 deletions(-)
32
33 diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py
34 index f461703..a17c205 100644
35 --- a/pym/repoman/actions.py
36 +++ b/pym/repoman/actions.py
37 @@ -30,7 +30,7 @@ from repoman._subprocess import repoman_popen, repoman_getstatusoutput
38 from repoman.errors import err
39 from repoman.gpg import gpgsign, need_signature
40 from repoman import utilities
41 -from repoman.vcs.vcs import git_supports_gpg_sign, vcs_files_to_cps
42 +from repoman.vcs.vcs import vcs_files_to_cps
43
44 bad = create_color_func("BAD")
45
46 @@ -662,8 +662,7 @@ class Actions(object):
47 else:
48 retval = spawn(commit_cmd, env=self.repo_settings.commit_env)
49 if retval != os.EX_OK:
50 - if self.repo_settings.repo_config.sign_commit and self.vcs_settings.vcs == 'git' and \
51 - not git_supports_gpg_sign():
52 + if self.repo_settings.repo_config.sign_commit and not self.vcs_settings.status.supports_gpg_sign():
53 # Inform user that newer git is needed (bug #403323).
54 logging.error(
55 "Git >=1.7.9 is required for signed commits!")
56
57 diff --git a/pym/repoman/main.py b/pym/repoman/main.py
58 index 00d48e7..c41e943 100755
59 --- a/pym/repoman/main.py
60 +++ b/pym/repoman/main.py
61 @@ -33,7 +33,7 @@ from repoman.qa_data import (
62 from repoman.repos import RepoSettings
63 from repoman.scanner import Scanner
64 from repoman import utilities
65 -from repoman.vcs.vcs import VCSSettings
66 +from repoman.vcs.settings import VCSSettings
67
68 if sys.hexversion >= 0x3000000:
69 basestring = str
70 @@ -101,7 +101,7 @@ def repoman_main(argv):
71 # Perform the main checks
72 scanner = Scanner(repo_settings, myreporoot, config_root, options,
73 vcs_settings, mydir, env)
74 - qatracker, can_force = scanner.scan_pkgs(can_force)
75 + can_force = scanner.scan_pkgs(can_force)
76
77 commitmessage = None
78
79 @@ -122,7 +122,7 @@ def repoman_main(argv):
80 sys.exit(result['fail'])
81
82 for x in qacats:
83 - if x not in qatracker.fails:
84 + if x not in vcs_settings.qatracker.fails:
85 continue
86 result['warn'] = 1
87 if x not in qawarnings:
88 @@ -153,7 +153,8 @@ def repoman_main(argv):
89
90 format_output = format_outputs.get(
91 options.output_style, format_outputs['default'])
92 - format_output(f, qatracker.fails, result['full'], result['fail'], options, qawarnings)
93 + format_output(f, vcs_settings.qatracker.fails, result['full'],
94 + result['fail'], options, qawarnings)
95
96 style_file.flush()
97 del console_writer, f, style_file
98
99 diff --git a/pym/repoman/modules/commit/repochecks.py b/pym/repoman/modules/commit/repochecks.py
100 index 163466d..ff7f604 100644
101 --- a/pym/repoman/modules/commit/repochecks.py
102 +++ b/pym/repoman/modules/commit/repochecks.py
103 @@ -5,7 +5,6 @@ from __future__ import print_function, unicode_literals
104 from portage.output import red
105
106 from repoman.errors import err
107 -from repoman.vcs.vcs import detect_vcs_conflicts
108
109
110 def commit_check(repolevel, reposplit):
111 @@ -32,4 +31,6 @@ def commit_check(repolevel, reposplit):
112
113 def conflict_check(vcs_settings, options):
114 if vcs_settings.vcs:
115 - detect_vcs_conflicts(options, vcs_settings.vcs)
116 + status = vcssettings.get_status(None, None)
117 + conflicts = status.detect_conflicts(options)
118 +
119
120 diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
121 index d1c10d7..eb1896f 100644
122 --- a/pym/repoman/scanner.py
123 +++ b/pym/repoman/scanner.py
124 @@ -40,7 +40,6 @@ from repoman.ebuild import Ebuild
125 from repoman.modules.commit import repochecks
126 from repoman.profile import check_profiles, dev_profile_keywords, setup_profile
127 from repoman.qa_data import missingvars, suspect_virtual, suspect_rdepend
128 -from repoman.qa_tracker import QATracker
129 from repoman.repos import repo_metadata
130 from repoman.scan import Changes, scan
131 from repoman.vcs.vcsstatus import VCSStatus
132 @@ -141,7 +140,7 @@ class Scanner(object):
133
134 self.dev_keywords = dev_profile_keywords(self.profiles)
135
136 - self.qatracker = QATracker()
137 + self.qatracker = self.vcs_settings.qatracker
138
139 if self.options.echangelog is None and self.repo_settings.repo_config.update_changelog:
140 self.options.echangelog = 'y'
141 @@ -209,7 +208,7 @@ class Scanner(object):
142 self.is_ebuild = IsEbuild(self.repo_settings.repoman_settings, self.repo_settings, self.portdb, self.qatracker)
143 self.filescheck = FileChecks(
144 self.qatracker, self.repo_settings.repoman_settings, self.repo_settings, self.portdb, self.vcs_settings)
145 - self.status_check = VCSStatus(self.vcs_settings, self.qatracker)
146 + self.status_check = VCSStatus(self.vcs_settings)
147 self.fetchcheck = FetchChecks(
148 self.qatracker, self.repo_settings, self.portdb, self.vcs_settings)
149 self.pkgmeta = PkgMetadata(self.options, self.qatracker,
150 @@ -270,7 +269,7 @@ class Scanner(object):
151 checkdir, checkdirlist, checkdir_relative, self.changed.changed, self.changed.new)
152
153 self.status_check.check(self.check['ebuild_notadded'], checkdir, checkdir_relative, xpkg)
154 - self.eadded.extend(self.status_check.eadded)
155 + self.eadded.extend(self.status_check.vcs_settings.eadded)
156
157 self.fetchcheck.check(
158 xpkg, checkdir, checkdir_relative, self.changed.changed, self.changed.new)
159 @@ -285,7 +284,7 @@ class Scanner(object):
160 self.changelog_modified = changelog_path in self.changed.changelogs
161
162 self._scan_ebuilds(ebuildlist, xpkg, catdir, pkgdir)
163 - return self.qatracker, can_force
164 + return can_force
165
166
167 def _scan_ebuilds(self, ebuildlist, xpkg, catdir, pkgdir):
168
169 diff --git a/pym/repoman/vcs/__init__.py b/pym/repoman/vcs/__init__.py
170 index e69de29..d7f6af9 100644
171 --- a/pym/repoman/vcs/__init__.py
172 +++ b/pym/repoman/vcs/__init__.py
173 @@ -0,0 +1,14 @@
174 +
175 +import os
176 +from portage.module import Modules
177 +
178 +path = os.path.join(os.path.dirname(__file__), "modules")
179 +# initial development debug info
180 +#print("module path:", path)
181 +
182 +module_controller = Modules(path=path, namepath="repoman.vcs.modules")
183 +
184 +# initial development debug info
185 +#print(module_controller.module_names)
186 +module_names = module_controller.module_names[:]
187 +
188
189 diff --git a/pym/repoman/vcs/modules/__init__.py b/pym/repoman/vcs/modules/__init__.py
190 new file mode 100644
191 index 0000000..8b13789
192 --- /dev/null
193 +++ b/pym/repoman/vcs/modules/__init__.py
194 @@ -0,0 +1 @@
195 +
196
197 diff --git a/pym/repoman/vcs/modules/bzr/__init__.py b/pym/repoman/vcs/modules/bzr/__init__.py
198 new file mode 100644
199 index 0000000..6f3aaa2
200 --- /dev/null
201 +++ b/pym/repoman/vcs/modules/bzr/__init__.py
202 @@ -0,0 +1,23 @@
203 +# Copyright 2014-2015 Gentoo Foundation
204 +# Distributed under the terms of the GNU General Public License v2
205 +
206 +doc = """BZR plug-in module for portage.
207 +Performs variaous Bazaar actions and checks on repositories."""
208 +__doc__ = doc[:]
209 +
210 +
211 +module_spec = {
212 + 'name': 'bzr',
213 + 'description': doc,
214 + 'provides':{
215 + 'bzr-module': {
216 + 'name': "bzrstatus",
217 + 'class': "Status",
218 + 'description': doc,
219 + 'functions': ['check', 'supports_gpg_sign', 'detect_conflicts'],
220 + 'func_desc': {
221 + },
222 + 'vcs_preserves_mtime': True,
223 + }
224 + }
225 +}
226
227 diff --git a/pym/repoman/vcs/modules/bzr/bzrstatus.py b/pym/repoman/vcs/modules/bzr/bzrstatus.py
228 new file mode 100644
229 index 0000000..5839272
230 --- /dev/null
231 +++ b/pym/repoman/vcs/modules/bzr/bzrstatus.py
232 @@ -0,0 +1,36 @@
233 +
234 +from repoman._portage import portage
235 +from portage import os
236 +from repoman._subprocess import repoman_popen
237 +
238 +
239 +class Status(object):
240 +
241 + def __init__(self, qatracker, eadded):
242 + self.qatracker = qatracker
243 + self.eadded = eadded
244 +
245 + def check_bzr(self, checkdir, checkdir_relative, xpkg):
246 + try:
247 + myf = repoman_popen(
248 + "bzr ls -v --kind=file " +
249 + portage._shell_quote(checkdir))
250 + myl = myf.readlines()
251 + myf.close()
252 + except IOError:
253 + raise
254 + for l in myl:
255 + if l[1:2] == "?":
256 + continue
257 + l = l.split()[-1]
258 + if l[-7:] == ".ebuild":
259 + self.eadded.append(os.path.basename(l[:-7]))
260 + return True
261 +
262 + @staticmethod
263 + def detect_conflicts(options):
264 + return False
265 +
266 + @staticmethod
267 + def supports_gpg_sign():
268 + return False
269
270 diff --git a/pym/repoman/vcs/modules/cvs/__init__.py b/pym/repoman/vcs/modules/cvs/__init__.py
271 new file mode 100644
272 index 0000000..0cd4bc7
273 --- /dev/null
274 +++ b/pym/repoman/vcs/modules/cvs/__init__.py
275 @@ -0,0 +1,23 @@
276 +# Copyright 2014-2015 Gentoo Foundation
277 +# Distributed under the terms of the GNU General Public License v2
278 +
279 +doc = """CVS plug-in module for portage.
280 +Performs variaous CVS actions and checks on repositories."""
281 +__doc__ = doc[:]
282 +
283 +
284 +module_spec = {
285 + 'name': 'cvs',
286 + 'description': doc,
287 + 'provides':{
288 + 'git-module': {
289 + 'name': "cvsstatus",
290 + 'class': "Status",
291 + 'description': doc,
292 + 'functions': ['check', 'supports_gpg_sign', 'detect_conflicts'],
293 + 'func_desc': {
294 + },
295 + 'vcs_preserves_mtime': True,
296 + }
297 + }
298 +}
299
300 diff --git a/pym/repoman/vcs/modules/cvs/cvsstatus.py b/pym/repoman/vcs/modules/cvs/cvsstatus.py
301 new file mode 100644
302 index 0000000..726bd65
303 --- /dev/null
304 +++ b/pym/repoman/vcs/modules/cvs/cvsstatus.py
305 @@ -0,0 +1,102 @@
306 +
307 +import logging
308 +import subprocess
309 +import sys
310 +
311 +from repoman._portage import portage
312 +from portage import os
313 +from portage.const import BASH_BINARY
314 +from portage.output import red, green
315 +from portage import _unicode_encode, _unicode_decode
316 +
317 +
318 +class Status(object):
319 +
320 + def __init__(self, qatracker, eadded):
321 + self.qatracker = qatracker
322 + self.eadded = eadded
323 +
324 + def check_cvs(self, checkdir, checkdir_relative, xpkg):
325 + try:
326 + myf = open(checkdir + "/CVS/Entries", "r")
327 + myl = myf.readlines()
328 + myf.close()
329 + except IOError:
330 + self.qatracker.add_error(
331 + "CVS/Entries.IO_error", checkdir + "/CVS/Entries")
332 + return True
333 + for l in myl:
334 + if l[0] != "/":
335 + continue
336 + splitl = l[1:].split("/")
337 + if not len(splitl):
338 + continue
339 + if splitl[0][-7:] == ".ebuild":
340 + self.eadded.append(splitl[0][:-7])
341 + return True
342 +
343 + @staticmethod
344 + def detect_conflicts(options):
345 + """Determine if the checkout has cvs conflicts.
346 +
347 + TODO(antarus): Also this should probably not call sys.exit() as
348 + repoman is run on >1 packages and one failure should not cause
349 + subsequent packages to fail.
350 +
351 + Returns:
352 + None (calls sys.exit on fatal problems)
353 + """
354 +
355 + cmd = ("cvs -n up 2>/dev/null | "
356 + "egrep '^[^\?] .*' | "
357 + "egrep -v '^. .*/digest-[^/]+|^cvs server: .* -- ignored$'")
358 + msg = ("Performing a %s with a little magic grep to check for updates."
359 + % green("cvs -n up"))
360 +
361 + logging.info(msg)
362 + # Use Popen instead of getstatusoutput(), in order to avoid
363 + # unicode handling problems (see bug #310789).
364 + args = [BASH_BINARY, "-c", cmd]
365 + args = [_unicode_encode(x) for x in args]
366 + proc = subprocess.Popen(
367 + args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
368 + out = _unicode_decode(proc.communicate()[0])
369 + proc.wait()
370 + mylines = out.splitlines()
371 + myupdates = []
372 + for line in mylines:
373 + if not line:
374 + continue
375 +
376 + # [ ] Unmodified (SVN) [U] Updates [P] Patches
377 + # [M] Modified [A] Added [R] Removed / Replaced
378 + # [D] Deleted
379 + if line[0] not in " UPMARD":
380 + # Stray Manifest is fine, we will readd it anyway.
381 + if line[0] == '?' and line[1:].lstrip() == 'Manifest':
382 + continue
383 + logging.error(red(
384 + "!!! Please fix the following issues reported "
385 + "from cvs: %s" % green("(U,P,M,A,R,D are ok)")))
386 + logging.error(red(
387 + "!!! Note: This is a pretend/no-modify pass..."))
388 + logging.error(out)
389 + sys.exit(1)
390 + elif line[0] in "UP":
391 + myupdates.append(line[2:])
392 +
393 + if myupdates:
394 + logging.info(green("Fetching trivial updates..."))
395 + if options.pretend:
396 + logging.info("(cvs update " + " ".join(myupdates) + ")")
397 + retval = os.EX_OK
398 + else:
399 + retval = os.system("cvs update " + " ".join(myupdates))
400 + if retval != os.EX_OK:
401 + logging.fatal("!!! cvs exited with an error. Terminating.")
402 + sys.exit(retval)
403 + return False
404 +
405 + @staticmethod
406 + def supports_gpg_sign():
407 + return False
408
409 diff --git a/pym/repoman/vcs/modules/git/__init__.py b/pym/repoman/vcs/modules/git/__init__.py
410 new file mode 100644
411 index 0000000..d8a2eea
412 --- /dev/null
413 +++ b/pym/repoman/vcs/modules/git/__init__.py
414 @@ -0,0 +1,23 @@
415 +# Copyright 2014-2015 Gentoo Foundation
416 +# Distributed under the terms of the GNU General Public License v2
417 +
418 +doc = """Git plug-in module for portage.
419 +Performs variaous git actions and checks on repositories."""
420 +__doc__ = doc[:]
421 +
422 +
423 +module_spec = {
424 + 'name': 'git',
425 + 'description': doc,
426 + 'provides':{
427 + 'git-module': {
428 + 'name': "gitstatus",
429 + 'class': "Status",
430 + 'description': doc,
431 + 'functions': ['check', 'supports_gpg_sign', 'detect_conflicts'],
432 + 'func_desc': {
433 + },
434 + 'vcs_preserves_mtime': False,
435 + }
436 + }
437 +}
438
439 diff --git a/pym/repoman/vcs/modules/git/gitstatus.py b/pym/repoman/vcs/modules/git/gitstatus.py
440 new file mode 100644
441 index 0000000..affe21c
442 --- /dev/null
443 +++ b/pym/repoman/vcs/modules/git/gitstatus.py
444 @@ -0,0 +1,46 @@
445 +
446 +import re
447 +
448 +from repoman._portage import portage
449 +from portage import os
450 +from repoman._subprocess import repoman_popen, repoman_getstatusoutput
451 +
452 +
453 +class Status(object):
454 +
455 + def __init__(self, qatracker, eadded):
456 + self.qatracker = qatracker
457 + self.eadded = eadded
458 +
459 + def check(self, checkdir, checkdir_relative, xpkg):
460 + myf = repoman_popen(
461 + "git ls-files --others %s" %
462 + (portage._shell_quote(checkdir_relative),))
463 + for l in myf:
464 + if l[:-1][-7:] == ".ebuild":
465 + self.qatracker.add_error(
466 + "ebuild.notadded",
467 + os.path.join(xpkg, os.path.basename(l[:-1])))
468 + myf.close()
469 + return True
470 +
471 + @staticmethod
472 + def supports_gpg_sign():
473 + status, cmd_output = \
474 + repoman_getstatusoutput("git --version")
475 + cmd_output = cmd_output.split()
476 + if cmd_output:
477 + version = re.match(r'^(\d+)\.(\d+)\.(\d+)', cmd_output[-1])
478 + if version is not None:
479 + version = [int(x) for x in version.groups()]
480 + if version[0] > 1 or \
481 + (version[0] == 1 and version[1] > 7) or \
482 + (version[0] == 1 and version[1] == 7 and version[2] >= 9):
483 + return True
484 + return False
485 +
486 + @staticmethod
487 + def detect_conflicts(options):
488 + return False
489 +
490 +
491
492 diff --git a/pym/repoman/vcs/modules/hg/__init__.py b/pym/repoman/vcs/modules/hg/__init__.py
493 new file mode 100644
494 index 0000000..68cccf2
495 --- /dev/null
496 +++ b/pym/repoman/vcs/modules/hg/__init__.py
497 @@ -0,0 +1,23 @@
498 +# Copyright 2014-2015 Gentoo Foundation
499 +# Distributed under the terms of the GNU General Public License v2
500 +
501 +doc = """HG plug-in module for portage.
502 +Performs variaous mercurial actions and checks on repositories."""
503 +__doc__ = doc[:]
504 +
505 +
506 +module_spec = {
507 + 'name': 'hg',
508 + 'description': doc,
509 + 'provides':{
510 + 'hg-module': {
511 + 'name': "hgstatus",
512 + 'class': "Status",
513 + 'description': doc,
514 + 'functions': ['check', 'supports_gpg_sign', 'detect_conflicts'],
515 + 'func_desc': {
516 + },
517 + 'vcs_preserves_mtime': False,
518 + }
519 + }
520 +}
521
522 diff --git a/pym/repoman/vcs/modules/hg/hgstatus.py b/pym/repoman/vcs/modules/hg/hgstatus.py
523 new file mode 100644
524 index 0000000..a0a0d9e
525 --- /dev/null
526 +++ b/pym/repoman/vcs/modules/hg/hgstatus.py
527 @@ -0,0 +1,30 @@
528 +
529 +from repoman._portage import portage
530 +from portage import os
531 +from repoman._subprocess import repoman_popen
532 +
533 +class Status(object):
534 +
535 + def __init__(self, qatracker, eadded):
536 + self.qatracker = qatracker
537 + self.eadded = eadded
538 +
539 + def check_hg(self, checkdir, checkdir_relative, xpkg):
540 + myf = repoman_popen(
541 + "hg status --no-status --unknown %s" %
542 + (portage._shell_quote(checkdir_relative),))
543 + for l in myf:
544 + if l[:-1][-7:] == ".ebuild":
545 + self.qatracker.add_error(
546 + "ebuild.notadded",
547 + os.path.join(xpkg, os.path.basename(l[:-1])))
548 + myf.close()
549 + return True
550 +
551 + @staticmethod
552 + def detect_conflicts(options):
553 + return False
554 +
555 + @staticmethod
556 + def supports_gpg_sign():
557 + return False
558
559 diff --git a/pym/repoman/vcs/modules/svn/__init__.py b/pym/repoman/vcs/modules/svn/__init__.py
560 new file mode 100644
561 index 0000000..2e2811d
562 --- /dev/null
563 +++ b/pym/repoman/vcs/modules/svn/__init__.py
564 @@ -0,0 +1,23 @@
565 +# Copyright 2014-2015 Gentoo Foundation
566 +# Distributed under the terms of the GNU General Public License v2
567 +
568 +doc = """SVN plug-in module for portage.
569 +Performs variaous subversion actions and checks on repositories."""
570 +__doc__ = doc[:]
571 +
572 +
573 +module_spec = {
574 + 'name': 'svn',
575 + 'description': doc,
576 + 'provides':{
577 + 'svn-module': {
578 + 'name': "svnstatus",
579 + 'class': "Status",
580 + 'description': doc,
581 + 'functions': ['check', 'supports_gpg_sign', 'detect_conflicts'],
582 + 'func_desc': {
583 + },
584 + 'vcs_preserves_mtime': False,
585 + }
586 + }
587 +}
588
589 diff --git a/pym/repoman/vcs/modules/svn/svnstatus.py b/pym/repoman/vcs/modules/svn/svnstatus.py
590 new file mode 100644
591 index 0000000..4a70455
592 --- /dev/null
593 +++ b/pym/repoman/vcs/modules/svn/svnstatus.py
594 @@ -0,0 +1,121 @@
595 +
596 +import logging
597 +import subprocess
598 +import sys
599 +
600 +from repoman._portage import portage
601 +from portage import os
602 +from portage.const import BASH_BINARY
603 +from portage.output import red, green
604 +from portage import _unicode_encode, _unicode_decode
605 +
606 +from repoman._subprocess import repoman_popen
607 +
608 +
609 +class Status(object):
610 +
611 + def __init__(self, qatracker, eadded):
612 + self.qatracker = qatracker
613 + self.eadded = eadded
614 +
615 + def check_svn(self, checkdir, checkdir_relative, xpkg):
616 + try:
617 + myf = repoman_popen(
618 + "svn status --depth=files --verbose " +
619 + portage._shell_quote(checkdir))
620 + myl = myf.readlines()
621 + myf.close()
622 + except IOError:
623 + raise
624 + for l in myl:
625 + if l[:1] == "?":
626 + continue
627 + if l[:7] == ' >':
628 + # tree conflict, new in subversion 1.6
629 + continue
630 + l = l.split()[-1]
631 + if l[-7:] == ".ebuild":
632 + self.eadded.append(os.path.basename(l[:-7]))
633 + try:
634 + myf = repoman_popen(
635 + "svn status " +
636 + portage._shell_quote(checkdir))
637 + myl = myf.readlines()
638 + myf.close()
639 + except IOError:
640 + raise
641 + for l in myl:
642 + if l[0] == "A":
643 + l = l.rstrip().split(' ')[-1]
644 + if l[-7:] == ".ebuild":
645 + self.eadded.append(os.path.basename(l[:-7]))
646 + return True
647 +
648 + @staticmethod
649 + def detect_conflicts(options):
650 + """Determine if the checkout has problems like cvs conflicts.
651 +
652 + If you want more vcs support here just keep adding if blocks...
653 + This could be better.
654 +
655 + TODO(antarus): Also this should probably not call sys.exit() as
656 + repoman is run on >1 packages and one failure should not cause
657 + subsequent packages to fail.
658 +
659 + Args:
660 + vcs - A string identifying the version control system in use
661 + Returns:
662 + None (calls sys.exit on fatal problems)
663 + """
664 +
665 + cmd = "svn status -u 2>&1 | egrep -v '^. +.*/digest-[^/]+' | head -n-1"
666 + msg = ("Performing a %s with a little magic grep to check for updates."
667 + % green("svn status -u"))
668 +
669 + logging.info(msg)
670 + # Use Popen instead of getstatusoutput(), in order to avoid
671 + # unicode handling problems (see bug #310789).
672 + args = [BASH_BINARY, "-c", cmd]
673 + args = [_unicode_encode(x) for x in args]
674 + proc = subprocess.Popen(
675 + args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
676 + out = _unicode_decode(proc.communicate()[0])
677 + proc.wait()
678 + mylines = out.splitlines()
679 + myupdates = []
680 + for line in mylines:
681 + if not line:
682 + continue
683 +
684 + # [ ] Unmodified (SVN) [U] Updates [P] Patches
685 + # [M] Modified [A] Added [R] Removed / Replaced
686 + # [D] Deleted
687 + if line[0] not in " UPMARD":
688 + # Stray Manifest is fine, we will readd it anyway.
689 + if line[0] == '?' and line[1:].lstrip() == 'Manifest':
690 + continue
691 + logging.error(red(
692 + "!!! Please fix the following issues reported "
693 + "from cvs: %s" % green("(U,P,M,A,R,D are ok)")))
694 + logging.error(red(
695 + "!!! Note: This is a pretend/no-modify pass..."))
696 + logging.error(out)
697 + sys.exit(1)
698 + elif line[8] == '*':
699 + myupdates.append(line[9:].lstrip(" 1234567890"))
700 +
701 + if myupdates:
702 + logging.info(green("Fetching trivial updates..."))
703 + if options.pretend:
704 + logging.info("(svn update " + " ".join(myupdates) + ")")
705 + retval = os.EX_OK
706 + else:
707 + retval = os.system("svn update " + " ".join(myupdates))
708 + if retval != os.EX_OK:
709 + logging.fatal("!!! svn exited with an error. Terminating.")
710 + sys.exit(retval)
711 + return False
712 +
713 + @staticmethod
714 + def supports_gpg_sign():
715 + return False
716
717 diff --git a/pym/repoman/vcs/settings.py b/pym/repoman/vcs/settings.py
718 new file mode 100644
719 index 0000000..a62427c
720 --- /dev/null
721 +++ b/pym/repoman/vcs/settings.py
722 @@ -0,0 +1,74 @@
723 +
724 +import logging
725 +import sys
726 +
727 +from repoman._portage import portage
728 +from portage.output import red
729 +from repoman.vcs import module_controller, module_names
730 +from repoman.vcs.vcs import FindVCS
731 +from repoman.qa_tracker import QATracker
732 +
733 +
734 +class VCSSettings(object):
735 + '''Holds various VCS settings'''
736 +
737 + def __init__(self, options=None, repoman_settings=None):
738 + if options.vcs:
739 + if options.vcs in module_names:
740 + self.vcs = options.vcs
741 + else:
742 + self.vcs = None
743 + else:
744 + vcses = FindVCS()
745 + if len(vcses) > 1:
746 + print(red(
747 + '*** Ambiguous workdir -- more than one VCS found'
748 + ' at the same depth: %s.' % ', '.join(vcses)))
749 + print(red(
750 + '*** Please either clean up your workdir'
751 + ' or specify --vcs option.'))
752 + sys.exit(1)
753 + elif vcses:
754 + self.vcs = vcses[0]
755 + else:
756 + self.vcs = None
757 +
758 + if options.if_modified == "y" and self.vcs is None:
759 + logging.info(
760 + "Not in a version controlled repository; "
761 + "disabling --if-modified.")
762 + options.if_modified = "n"
763 +
764 + self._status = None
765 + self.module_controller = module_controller
766 + self.module_names = module_names
767 +
768 + # Disable copyright/mtime check if vcs does not preserve mtime (bug #324075).
769 + self.vcs_preserves_mtime = module_controller.modules["%sstatus" % self.vcs]['vcs_preserves_mtime']
770 +
771 + self.vcs_local_opts = repoman_settings.get(
772 + "REPOMAN_VCS_LOCAL_OPTS", "").split()
773 + self.vcs_global_opts = repoman_settings.get(
774 + "REPOMAN_VCS_GLOBAL_OPTS")
775 + if self.vcs_global_opts is None:
776 + if self.vcs in ('cvs', 'svn'):
777 + self.vcs_global_opts = "-q"
778 + else:
779 + self.vcs_global_opts = ""
780 + self.vcs_global_opts = self.vcs_global_opts.split()
781 +
782 + if options.mode == 'commit' and not options.pretend and not self.vcs:
783 + logging.info(
784 + "Not in a version controlled repository; "
785 + "enabling pretend mode.")
786 + options.pretend = True
787 + self.qatracker = QATracker()
788 + self.eadded = []
789 +
790 + @property
791 + def status(self):
792 + if not self._status:
793 + status = self.module_controller.get_class('%sstatus' % self.vcs)
794 + self._status = status(self.qatracker, self.eadded)
795 + return self._status
796 +
797
798 diff --git a/pym/repoman/vcs/vcs.py b/pym/repoman/vcs/vcs.py
799 index a463335..8ec7270 100644
800 --- a/pym/repoman/vcs/vcs.py
801 +++ b/pym/repoman/vcs/vcs.py
802 @@ -4,17 +4,9 @@ from __future__ import print_function, unicode_literals
803
804 import collections
805 import logging
806 -import re
807 -import subprocess
808 -import sys
809 from itertools import chain
810
811 from portage import os
812 -from portage.const import BASH_BINARY
813 -from portage.output import red, green
814 -from portage import _unicode_encode, _unicode_decode
815 -
816 -from repoman._subprocess import repoman_getstatusoutput
817
818
819 _vcs_type = collections.namedtuple('_vcs_type', 'name dir_name')
820 @@ -141,147 +133,3 @@ def vcs_new_changed(relative_path, mychanged, mynew):
821 return False
822
823
824 -def git_supports_gpg_sign():
825 - status, cmd_output = \
826 - repoman_getstatusoutput("git --version")
827 - cmd_output = cmd_output.split()
828 - if cmd_output:
829 - version = re.match(r'^(\d+)\.(\d+)\.(\d+)', cmd_output[-1])
830 - if version is not None:
831 - version = [int(x) for x in version.groups()]
832 - if version[0] > 1 or \
833 - (version[0] == 1 and version[1] > 7) or \
834 - (version[0] == 1 and version[1] == 7 and version[2] >= 9):
835 - return True
836 - return False
837 -
838 -
839 -def detect_vcs_conflicts(options, vcs):
840 - """Determine if the checkout has problems like cvs conflicts.
841 -
842 - If you want more vcs support here just keep adding if blocks...
843 - This could be better.
844 -
845 - TODO(antarus): Also this should probably not call sys.exit() as
846 - repoman is run on >1 packages and one failure should not cause
847 - subsequent packages to fail.
848 -
849 - Args:
850 - vcs - A string identifying the version control system in use
851 - Returns:
852 - None (calls sys.exit on fatal problems)
853 - """
854 -
855 - cmd = None
856 - if vcs == 'cvs':
857 - logging.info(
858 - "Performing a %s with a little magic grep to check for updates." %
859 - green("cvs -n up"))
860 - cmd = (
861 - "cvs -n up 2>/dev/null | "
862 - "egrep '^[^\?] .*' | "
863 - "egrep -v '^. .*/digest-[^/]+|^cvs server: .* -- ignored$'")
864 - if vcs == 'svn':
865 - logging.info(
866 - "Performing a %s with a little magic grep to check for updates." %
867 - green("svn status -u"))
868 - cmd = (
869 - "svn status -u 2>&1 | "
870 - "egrep -v '^. +.*/digest-[^/]+' | "
871 - "head -n-1")
872 -
873 - if cmd is not None:
874 - # Use Popen instead of getstatusoutput(), in order to avoid
875 - # unicode handling problems (see bug #310789).
876 - args = [BASH_BINARY, "-c", cmd]
877 - args = [_unicode_encode(x) for x in args]
878 - proc = subprocess.Popen(
879 - args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
880 - out = _unicode_decode(proc.communicate()[0])
881 - proc.wait()
882 - mylines = out.splitlines()
883 - myupdates = []
884 - for line in mylines:
885 - if not line:
886 - continue
887 -
888 - # [ ] Unmodified (SVN) [U] Updates [P] Patches
889 - # [M] Modified [A] Added [R] Removed / Replaced
890 - # [D] Deleted
891 - if line[0] not in " UPMARD":
892 - # Stray Manifest is fine, we will readd it anyway.
893 - if line[0] == '?' and line[1:].lstrip() == 'Manifest':
894 - continue
895 - logging.error(red(
896 - "!!! Please fix the following issues reported "
897 - "from cvs: %s" % green("(U,P,M,A,R,D are ok)")))
898 - logging.error(red(
899 - "!!! Note: This is a pretend/no-modify pass..."))
900 - logging.error(out)
901 - sys.exit(1)
902 - elif vcs == 'cvs' and line[0] in "UP":
903 - myupdates.append(line[2:])
904 - elif vcs == 'svn' and line[8] == '*':
905 - myupdates.append(line[9:].lstrip(" 1234567890"))
906 -
907 - if myupdates:
908 - logging.info(green("Fetching trivial updates..."))
909 - if options.pretend:
910 - logging.info("(" + vcs + " update " + " ".join(myupdates) + ")")
911 - retval = os.EX_OK
912 - else:
913 - retval = os.system(vcs + " update " + " ".join(myupdates))
914 - if retval != os.EX_OK:
915 - logging.fatal("!!! " + vcs + " exited with an error. Terminating.")
916 - sys.exit(retval)
917 -
918 -
919 -class VCSSettings(object):
920 - '''Holds various VCS settings'''
921 -
922 - def __init__(self, options=None, repoman_settings=None):
923 - if options.vcs:
924 - if options.vcs in ('cvs', 'svn', 'git', 'bzr', 'hg'):
925 - self.vcs = options.vcs
926 - else:
927 - self.vcs = None
928 - else:
929 - vcses = FindVCS()
930 - if len(vcses) > 1:
931 - print(red(
932 - '*** Ambiguous workdir -- more than one VCS found'
933 - ' at the same depth: %s.' % ', '.join(vcses)))
934 - print(red(
935 - '*** Please either clean up your workdir'
936 - ' or specify --vcs option.'))
937 - sys.exit(1)
938 - elif vcses:
939 - self.vcs = vcses[0]
940 - else:
941 - self.vcs = None
942 -
943 - if options.if_modified == "y" and self.vcs is None:
944 - logging.info(
945 - "Not in a version controlled repository; "
946 - "disabling --if-modified.")
947 - options.if_modified = "n"
948 -
949 - # Disable copyright/mtime check if vcs does not preserve mtime (bug #324075).
950 - self.vcs_preserves_mtime = self.vcs in ('cvs',)
951 -
952 - self.vcs_local_opts = repoman_settings.get(
953 - "REPOMAN_VCS_LOCAL_OPTS", "").split()
954 - self.vcs_global_opts = repoman_settings.get(
955 - "REPOMAN_VCS_GLOBAL_OPTS")
956 - if self.vcs_global_opts is None:
957 - if self.vcs in ('cvs', 'svn'):
958 - self.vcs_global_opts = "-q"
959 - else:
960 - self.vcs_global_opts = ""
961 - self.vcs_global_opts = self.vcs_global_opts.split()
962 -
963 - if options.mode == 'commit' and not options.pretend and not self.vcs:
964 - logging.info(
965 - "Not in a version controlled repository; "
966 - "enabling pretend mode.")
967 - options.pretend = True
968
969 diff --git a/pym/repoman/vcs/vcsstatus.py b/pym/repoman/vcs/vcsstatus.py
970 index 53b8ffe..f0ad52c 100644
971 --- a/pym/repoman/vcs/vcsstatus.py
972 +++ b/pym/repoman/vcs/vcsstatus.py
973 @@ -1,114 +1,14 @@
974 # -*- coding:utf-8 -*-
975
976
977 -# import our initialized portage instance
978 -from repoman._portage import portage
979 -
980 -from portage import os
981 -
982 -from repoman._subprocess import repoman_popen
983 -
984 -
985 class VCSStatus(object):
986 '''Determines the status of the vcs repositories
987 to determine if files are not added'''
988
989 - def __init__(self, vcs_settings, qatracker):
990 + def __init__(self, vcs_settings):
991 self.vcs_settings = vcs_settings
992 - self.vcs = vcs_settings.vcs
993 - self.eadded = []
994 - self.qatracker = qatracker
995
996 def check(self, check_not_added, checkdir, checkdir_relative, xpkg):
997 - if self.vcs and check_not_added:
998 - vcscheck = getattr(self, 'check_%s' % self.vcs)
999 - vcscheck(checkdir, checkdir_relative, xpkg)
1000 -
1001 - def post_git_hg(self, myf, xpkg):
1002 - for l in myf:
1003 - if l[:-1][-7:] == ".ebuild":
1004 - self.qatracker.add_error(
1005 - "ebuild.notadded",
1006 - os.path.join(xpkg, os.path.basename(l[:-1])))
1007 - myf.close()
1008 -
1009 - def check_git(self, checkdir, checkdir_relative, xpkg):
1010 - myf = repoman_popen(
1011 - "git ls-files --others %s" %
1012 - (portage._shell_quote(checkdir_relative),))
1013 - self.post_git_hg(myf, xpkg)
1014 -
1015 - def check_hg(self, checkdir, checkdir_relative, xpkg):
1016 - myf = repoman_popen(
1017 - "hg status --no-status --unknown %s" %
1018 - (portage._shell_quote(checkdir_relative),))
1019 - self.post_git_hg(myf, xpkg)
1020 -
1021 - def check_cvs(self, checkdir, checkdir_relative, xpkg):
1022 - try:
1023 - myf = open(checkdir + "/CVS/Entries", "r")
1024 - myl = myf.readlines()
1025 - myf.close()
1026 - except IOError:
1027 - self.qatracker.add_error(
1028 - "CVS/Entries.IO_error", checkdir + "/CVS/Entries")
1029 - return True
1030 - for l in myl:
1031 - if l[0] != "/":
1032 - continue
1033 - splitl = l[1:].split("/")
1034 - if not len(splitl):
1035 - continue
1036 - if splitl[0][-7:] == ".ebuild":
1037 - self.eadded.append(splitl[0][:-7])
1038 - return True
1039 -
1040 - def check_svn(self, checkdir, checkdir_relative, xpkg):
1041 - try:
1042 - myf = repoman_popen(
1043 - "svn status --depth=files --verbose " +
1044 - portage._shell_quote(checkdir))
1045 - myl = myf.readlines()
1046 - myf.close()
1047 - except IOError:
1048 - raise
1049 - for l in myl:
1050 - if l[:1] == "?":
1051 - continue
1052 - if l[:7] == ' >':
1053 - # tree conflict, new in subversion 1.6
1054 - continue
1055 - l = l.split()[-1]
1056 - if l[-7:] == ".ebuild":
1057 - self.eadded.append(os.path.basename(l[:-7]))
1058 - try:
1059 - myf = repoman_popen(
1060 - "svn status " +
1061 - portage._shell_quote(checkdir))
1062 - myl = myf.readlines()
1063 - myf.close()
1064 - except IOError:
1065 - raise
1066 - for l in myl:
1067 - if l[0] == "A":
1068 - l = l.rstrip().split(' ')[-1]
1069 - if l[-7:] == ".ebuild":
1070 - self.eadded.append(os.path.basename(l[:-7]))
1071 - return True
1072 + if self.vcs_settings.vcs and check_not_added:
1073 + self.vcs_settings.status.check(checkdir, checkdir_relative, xpkg)
1074
1075 - def check_bzr(self, checkdir, checkdir_relative, xpkg):
1076 - try:
1077 - myf = repoman_popen(
1078 - "bzr ls -v --kind=file " +
1079 - portage._shell_quote(checkdir))
1080 - myl = myf.readlines()
1081 - myf.close()
1082 - except IOError:
1083 - raise
1084 - for l in myl:
1085 - if l[1:2] == "?":
1086 - continue
1087 - l = l.split()[-1]
1088 - if l[-7:] == ".ebuild":
1089 - self.eadded.append(os.path.basename(l[:-7]))
1090 - return True