commit: 93411d21c0355ed38fd9708d865834f9a3fbce20 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> AuthorDate: Thu May 29 22:29:13 2014 +0000 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> CommitDate: Fri May 30 19:22:38 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=93411d21
repoman/main.py: Split out vcsstatus.py with VCSStatus class This class scans the vcs to determine ebuilds not added. --- pym/repoman/main.py | 81 +++----------------------- pym/repoman/vcs/vcsstatus.py | 134 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+), 72 deletions(-) diff --git a/pym/repoman/main.py b/pym/repoman/main.py index ee70735..f48c8ba 100755 --- a/pym/repoman/main.py +++ b/pym/repoman/main.py @@ -83,6 +83,7 @@ from repoman._subprocess import repoman_popen, repoman_getstatusoutput from repoman import utilities from repoman.vcs.vcs import (git_supports_gpg_sign, vcs_files_to_cps, vcs_new_changed, VCSSettings) +from repoman.vcs.vcsstatus import VCSStatus from repoman._xml import _XMLParser, _MetadataTreeBuilder, XmlLint @@ -449,78 +450,14 @@ for xpkg in effective_scanlist: if f is not None: f.close() - if vcs_settings.vcs in ("git", "hg") and check_ebuild_notadded: - if vcs_settings.vcs == "git": - myf = repoman_popen( - "git ls-files --others %s" % - (portage._shell_quote(checkdir_relative),)) - if vcs_settings.vcs == "hg": - myf = repoman_popen( - "hg status --no-status --unknown %s" % - (portage._shell_quote(checkdir_relative),)) - for l in myf: - if l[:-1][-7:] == ".ebuild": - stats["ebuild.notadded"] += 1 - fails["ebuild.notadded"].append( - os.path.join(xpkg, os.path.basename(l[:-1]))) - myf.close() - - if vcs_settings.vcs in ("cvs", "svn", "bzr") and check_ebuild_notadded: - try: - if vcs_settings.vcs == "cvs": - myf = open(checkdir + "/CVS/Entries", "r") - if vcs_settings.vcs == "svn": - myf = repoman_popen( - "svn status --depth=files --verbose " + - portage._shell_quote(checkdir)) - if vcs_settings.vcs == "bzr": - myf = repoman_popen( - "bzr ls -v --kind=file " + - portage._shell_quote(checkdir)) - myl = myf.readlines() - myf.close() - for l in myl: - if vcs_settings.vcs == "cvs": - if l[0] != "/": - continue - splitl = l[1:].split("/") - if not len(splitl): - continue - if splitl[0][-7:] == ".ebuild": - eadded.append(splitl[0][:-7]) - if vcs_settings.vcs == "svn": - if l[:1] == "?": - continue - if l[:7] == ' >': - # tree conflict, new in subversion 1.6 - continue - l = l.split()[-1] - if l[-7:] == ".ebuild": - eadded.append(os.path.basename(l[:-7])) - if vcs_settings.vcs == "bzr": - if l[1:2] == "?": - continue - l = l.split()[-1] - if l[-7:] == ".ebuild": - eadded.append(os.path.basename(l[:-7])) - if vcs_settings.vcs == "svn": - myf = repoman_popen( - "svn status " + - portage._shell_quote(checkdir)) - myl = myf.readlines() - myf.close() - for l in myl: - if l[0] == "A": - l = l.rstrip().split(' ')[-1] - if l[-7:] == ".ebuild": - eadded.append(os.path.basename(l[:-7])) - except IOError: - if vcs_settings.vcs == "cvs": - stats["CVS/Entries.IO_error"] += 1 - fails["CVS/Entries.IO_error"].append(checkdir + "/CVS/Entries") - else: - raise - continue +############### + status_check = VCSStatus(vcs_settings, checkdir, checkdir_relative, xpkg) + status_check.check(check_ebuild_notadded) + eadded.extend(status_check.eadded) + for key in list(status_check.stats): + stats[key] += status_check.stats[key] + fails[key].extend(status_check.fails[key]) +############### mf = repoman_settings.repositories.get_repo_for_location( os.path.dirname(os.path.dirname(checkdir))) diff --git a/pym/repoman/vcs/vcsstatus.py b/pym/repoman/vcs/vcsstatus.py new file mode 100644 index 0000000..346c20e --- /dev/null +++ b/pym/repoman/vcs/vcsstatus.py @@ -0,0 +1,134 @@ + + +import portage +from portage import os + +from repoman._subprocess import repoman_popen + + + +class VCSStatus(object): + '''Determines the status of the vcs repositories + to determine if files are not added''' + + def __init__(self, vcs_settings, checkdir, checkdir_relative, xpkg): + self.vcs_settings = vcs_settings + self.vcs = vcs_settings.vcs + self.eadded = [] + self.checkdir = checkdir + self.checkdir_relative = checkdir_relative + self.xpkg = xpkg + self.stats = {} + self.fails = {} + + + def check(self, check_not_added): + if check_not_added: + vcscheck = getattr(self, 'check_%s' % self.vcs) + vcscheck() + + + def post_git_hg(self, myf): + for l in myf: + if l[:-1][-7:] == ".ebuild": + if "ebuild.notadded" in list(self.fails): + self.stats["ebuild.notadded"] += 1 + self.fails["ebuild.notadded"].append( + os.path.join(self.xpkg, os.path.basename(l[:-1]))) + else: + self.stats["ebuild.notadded"] = 1 + self.fails["ebuild.notadded"] = [os.path.join( + self.xpkg, os.path.basename(l[:-1]))] + myf.close() + + + def check_git(self): + myf = repoman_popen( + "git ls-files --others %s" % + (portage._shell_quote(self.checkdir_relative),)) + self.post_git_hg(myf) + + + def check_hg(self): + myf = repoman_popen( + "hg status --no-status --unknown %s" % + (portage._shell_quote(self.checkdir_relative),)) + self.post_git_hg(myf) + + + def check_cvs(self): + try: + myf = open(self.checkdir + "/CVS/Entries", "r") + myl = myf.readlines() + myf.close() + except IOError: + if "CVS/Entries.IO_error" in list(self.fails): + self.stats["CVS/Entries.IO_error"] += 1 + self.fails["CVS/Entries.IO_error"].append( + self.checkdir + "/CVS/Entries") + else: + self.stats["CVS/Entries.IO_error"] = 1 + self.fails["CVS/Entries.IO_error"] = [ + self.checkdir + "/CVS/Entries"] + return True + for l in myl: + if l[0] != "/": + continue + splitl = l[1:].split("/") + if not len(splitl): + continue + if splitl[0][-7:] == ".ebuild": + self.eadded.append(splitl[0][:-7]) + return True + + + def check_svn(self): + try: + myf = repoman_popen( + "svn status --depth=files --verbose " + + portage._shell_quote(self.checkdir)) + myl = myf.readlines() + myf.close() + except IOError: + raise + for l in myl: + if l[:1] == "?": + continue + if l[:7] == ' >': + # tree conflict, new in subversion 1.6 + continue + l = l.split()[-1] + if l[-7:] == ".ebuild": + self.eadded.append(os.path.basename(l[:-7])) + try: + myf = repoman_popen( + "svn status " + + portage._shell_quote(self.checkdir)) + myl = myf.readlines() + myf.close() + except IOError: + raise + for l in myl: + if l[0] == "A": + l = l.rstrip().split(' ')[-1] + if l[-7:] == ".ebuild": + self.eadded.append(os.path.basename(l[:-7])) + return True + + + def check_bzr(self): + try: + myf = repoman_popen( + "bzr ls -v --kind=file " + + portage._shell_quote(self.checkdir)) + myl = myf.readlines() + myf.close() + except IOError: + raise + for l in myl: + if l[1:2] == "?": + continue + l = l.split()[-1] + if l[-7:] == ".ebuild": + self.eadded.append(os.path.basename(l[:-7])) + return True