From: "Brian Dolbec" <brian.dolbec@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/vcs/
Date: Fri, 30 May 2014 13:03:32 +0000 (UTC) [thread overview]
Message-ID: <1401402981.3418e0f2e3fd983c61a1731eee6bb737325f9cba.dol-sen@gentoo> (raw)
commit: 3418e0f2e3fd983c61a1731eee6bb737325f9cba
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: Thu May 29 22:36:21 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3418e0f2
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 | 137 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 146 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..4f57c42
--- /dev/null
+++ b/pym/repoman/vcs/vcsstatus.py
@@ -0,0 +1,137 @@
+
+
+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()
+ 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])
+ 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
+
+
+ def check_svn(self):
+ try:
+ myf = repoman_popen(
+ "svn status --depth=files --verbose " +
+ portage._shell_quote(self.checkdir))
+ myl = myf.readlines()
+ myf.close()
+ 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]))
+ except IOError:
+ raise
+ 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()
+ 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]))
+ except IOError:
+ raise
+ return True
+
+
+ def post_cvs_svn_bzr(self, myf):
+ if self.vcs == "svn":
+ myf = repoman_popen(
+ "svn status " +
+ portage._shell_quote(self.checkdir))
+ myl = myf.readlines()
+ myf.close()
+ 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]))
+ else:
+ raise
+ #continue
next reply other threads:[~2014-05-30 13:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-30 13:03 Brian Dolbec [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-05-30 19:25 [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/vcs/ Brian Dolbec
2014-06-03 19:33 Brian Dolbec
2014-10-01 23:02 Brian Dolbec
2014-10-01 23:46 Brian Dolbec
2015-09-05 21:27 Brian Dolbec
2015-09-05 21:48 Brian Dolbec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1401402981.3418e0f2e3fd983c61a1731eee6bb737325f9cba.dol-sen@gentoo \
--to=brian.dolbec@gmail.com \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox