public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/vcs/cvs/, pym/repoman/modules/vcs/bzr/, ...
@ 2016-01-30  8:00 Brian Dolbec
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2016-01-30  8:00 UTC (permalink / raw
  To: gentoo-commits

commit:     7c06bfba625e89ccad8c8c565999893028e01119
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 30 01:58:36 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 30 07:50:22 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=7c06bfba

repoman: Migrate actions.py vcs code to the vcs modules

Add missing changes code to the existing Changes classes.
This removes the duplicated code in the Actions class.
It alsosspeeds up the run by not calling the vcs binary to scan for changes a second time.
Optimize the code for the vcs modules.

 pym/repoman/actions.py                   | 208 ++++---------------------------
 pym/repoman/modules/vcs/None/__init__.py |   1 +
 pym/repoman/modules/vcs/bzr/__init__.py  |   1 +
 pym/repoman/modules/vcs/bzr/changes.py   |  15 ++-
 pym/repoman/modules/vcs/changes.py       |  13 ++
 pym/repoman/modules/vcs/cvs/__init__.py  |   1 +
 pym/repoman/modules/vcs/cvs/changes.py   |  13 +-
 pym/repoman/modules/vcs/git/__init__.py  |   1 +
 pym/repoman/modules/vcs/git/changes.py   |  20 +--
 pym/repoman/modules/vcs/hg/__init__.py   |   1 +
 pym/repoman/modules/vcs/hg/changes.py    |  27 +++-
 pym/repoman/modules/vcs/settings.py      |   5 +-
 pym/repoman/modules/vcs/svn/__init__.py  |   1 +
 pym/repoman/modules/vcs/svn/changes.py   |  24 +++-
 14 files changed, 118 insertions(+), 213 deletions(-)

diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py
index 3fd940c..8cf4a97 100644
--- a/pym/repoman/actions.py
+++ b/pym/repoman/actions.py
@@ -16,7 +16,6 @@ from itertools import chain
 from _emerge.UserQuery import UserQuery
 
 import portage
-from portage import cvstree
 from portage import os
 from portage import _encodings
 from portage import _unicode_encode
@@ -26,8 +25,7 @@ from portage.package.ebuild.digestgen import digestgen
 from portage.process import find_binary, spawn
 from portage.util import writemsg_level
 
-from repoman._subprocess import repoman_popen, repoman_getstatusoutput
-from repoman.errors import err
+from repoman._subprocess import repoman_getstatusoutput
 from repoman.gpg import gpgsign, need_signature
 from repoman import utilities
 from repoman.modules.vcs.vcs import vcs_files_to_cps
@@ -71,13 +69,11 @@ class Actions(object):
 
 
 	def perform(self, qa_output):
-		myunadded, mydeleted = self._vcs_unadded()
+		myautoadd = self._vcs_autoadd()
 
-		myautoadd = self._vcs_autoadd(myunadded)
+		self._vcs_deleted()
 
-		self._vcs_deleted(mydeleted)
-
-		changes = self.get_vcs_changed(mydeleted)
+		changes = self.get_vcs_changed()
 
 		mynew, mychanged, myremoved, no_expansion, expansion = changes
 
@@ -127,8 +123,8 @@ class Actions(object):
 
 		print("* %s files being committed..." % green(str(len(myupdates))), end=' ')
 
-		if self.vcs_settings.vcs not in ('cvs', 'svn'):
-			# With git, bzr and hg, there's never any keyword expansion, so
+		if self.vcs_settings.needs_keyword_expansion:
+			# With some VCS types there's never any keyword expansion, so
 			# there's no need to regenerate manifests and all files will be
 			# committed in one big commit at the end.
 			print()
@@ -261,62 +257,8 @@ class Actions(object):
 			sys.exit(1)
 
 
-	def _vcs_unadded(self):
-		myunadded = []
-		mydeleted = []
-		if self.vcs_settings.vcs == "cvs":
-			try:
-				myvcstree = portage.cvstree.getentries("./", recursive=1)
-				myunadded = portage.cvstree.findunadded(
-					myvcstree, recursive=1, basedir="./")
-			except SystemExit:
-				raise  # TODO propagate this
-			except:
-				err("Error retrieving CVS tree; exiting.")
-		if self.vcs_settings.vcs == "svn":
-			try:
-				with repoman_popen("svn status --no-ignore") as f:
-					svnstatus = f.readlines()
-				myunadded = [
-					"./" + elem.rstrip().split()[1]
-					for elem in svnstatus
-					if elem.startswith("?") or elem.startswith("I")]
-			except SystemExit:
-				raise  # TODO propagate this
-			except:
-				err("Error retrieving SVN info; exiting.")
-		if self.vcs_settings.vcs == "git":
-			# get list of files not under version control or missing
-			myf = repoman_popen("git ls-files --others")
-			myunadded = ["./" + elem[:-1] for elem in myf]
-			myf.close()
-		if self.vcs_settings.vcs == "bzr":
-			try:
-				with repoman_popen("bzr status -S .") as f:
-					bzrstatus = f.readlines()
-				myunadded = [
-					"./" + elem.rstrip().split()[1].split('/')[-1:][0]
-					for elem in bzrstatus
-					if elem.startswith("?") or elem[0:2] == " D"]
-			except SystemExit:
-				raise # TODO propagate this
-			except:
-				err("Error retrieving bzr info; exiting.")
-		if self.vcs_settings.vcs == "hg":
-			with repoman_popen("hg status --no-status --unknown .") as f:
-				myunadded = f.readlines()
-			myunadded = ["./" + elem.rstrip() for elem in myunadded]
-
-			# Mercurial doesn't handle manually deleted files as removed from
-			# the repository, so the user need to remove them before commit,
-			# using "hg remove [FILES]"
-			with repoman_popen("hg status --no-status --deleted .") as f:
-				mydeleted = f.readlines()
-			mydeleted = ["./" + elem.rstrip() for elem in mydeleted]
-		return myunadded, mydeleted
-
-
-	def _vcs_autoadd(self, myunadded):
+	def _vcs_autoadd(self):
+		myunadded = self.vcs_settings.changes.unadded
 		myautoadd = []
 		if myunadded:
 			for x in range(len(myunadded) - 1, -1, -1):
@@ -348,137 +290,35 @@ class Actions(object):
 		return myautoadd
 
 
-	def _vcs_deleted(self, mydeleted):
-		if self.vcs_settings.vcs == "hg" and mydeleted:
+	def _vcs_deleted(self):
+		if self.vcs_settings.changes.has_deleted():
 			print(red(
 				"!!! The following files are removed manually"
 				" from your local tree but are not"))
 			print(red(
 				"!!! removed from the repository."
-				" Please remove them, using \"hg remove [FILES]\"."))
-			for x in mydeleted:
+				" Please remove them, using \"%s remove [FILES]\"."
+				% self.vcs_settings.vcs))
+			for x in self.vcs_settings.changes.deleted:
 				print("   ", x)
 			print()
 			print()
 			sys.exit(1)
 
 
-	def get_vcs_changed(self, mydeleted):
+	def get_vcs_changed(self):
 		'''Holding function which calls the approriate VCS module for the data'''
-		changed = ([], [], [], [], [])
-		if self.vcs_settings.vcs:
-			vcs_module = getattr(self, '_get_changed_%s_' % self.vcs_settings.vcs)
-			changed = vcs_module(mydeleted)
-			mynew, mychanged, myremoved, no_expansion, expansion = changed
-
-			a_file_is_changed = mychanged or mynew or myremoved
-			a_file_is_deleted_hg = self.vcs_settings.vcs == "hg" and mydeleted
-
-			if not (a_file_is_changed or a_file_is_deleted_hg):
-				utilities.repoman_sez(
-					"\"Doing nothing is not always good for QA.\"")
-				print()
-				print("(Didn't find any changed files...)")
-				print()
-				sys.exit(1)
-		return changed
-
-
-	def _get_changed_cvs_(self, mydeleted):
-		mycvstree = cvstree.getentries("./", recursive=1)
-		mychanged = cvstree.findchanged(mycvstree, recursive=1, basedir="./")
-		mynew = cvstree.findnew(mycvstree, recursive=1, basedir="./")
-		myremoved = portage.cvstree.findremoved(mycvstree, recursive=1, basedir="./")
-		bin_blob_pattern = re.compile("^-kb$")
-		no_expansion = set(portage.cvstree.findoption(
-			mycvstree, bin_blob_pattern, recursive=1, basedir="./"))
-		expansion = {}
-		return  (mynew, mychanged, myremoved, no_expansion, expansion)
-
-	def _get_changed_svn_(self, mydeleted):
-		with repoman_popen("svn status") as f:
-			svnstatus = f.readlines()
-		mychanged = [
-			"./" + elem.split()[-1:][0]
-			for elem in svnstatus
-			if (elem[:1] in "MR" or elem[1:2] in "M")]
-		mynew = [
-			"./" + elem.split()[-1:][0]
-			for elem in svnstatus
-			if elem.startswith("A")]
-		myremoved = [
-			"./" + elem.split()[-1:][0]
-			for elem in svnstatus
-			if elem.startswith("D")]
-		# Subversion expands keywords specified in svn:keywords properties.
-		with repoman_popen("svn propget -R svn:keywords") as f:
-			props = f.readlines()
-		expansion = dict(
-			("./" + prop.split(" - ")[0], prop.split(" - ")[1].split())
-			for prop in props if " - " in prop)
-		no_expansion = set()
-		return  (mynew, mychanged, myremoved, no_expansion, expansion)
-
-	def _get_changed_git_(self, mydeleted):
-		with repoman_popen(
-			"git diff-index --name-only "
-			"--relative --diff-filter=M HEAD") as f:
-			mychanged = f.readlines()
-		mychanged = ["./" + elem[:-1] for elem in mychanged]
-		with repoman_popen(
-			"git diff-index --name-only "
-			"--relative --diff-filter=A HEAD") as f:
-			mynew = f.readlines()
-		mynew = ["./" + elem[:-1] for elem in mynew]
-		with repoman_popen(
-			"git diff-index --name-only "
-			"--relative --diff-filter=D HEAD") as f:
-			myremoved = f.readlines()
-		myremoved = ["./" + elem[:-1] for elem in myremoved]
-		no_expansion = set()
-		expansion = {}
-		return  (mynew, mychanged, myremoved, no_expansion, expansion)
-
-	def _get_changed_bzr_(self, mydeleted):
-		with repoman_popen("bzr status -S .") as f:
-			bzrstatus = f.readlines()
-		mychanged = [
-			"./" + elem.split()[-1:][0].split('/')[-1:][0]
-			for elem in bzrstatus
-			if elem and elem[1:2] == "M"]
-		mynew = [
-			"./" + elem.split()[-1:][0].split('/')[-1:][0]
-			for elem in bzrstatus
-			if elem and (elem[1:2] in "NK" or elem[0:1] == "R")]
-		myremoved = [
-			"./" + elem.split()[-1:][0].split('/')[-1:][0]
-			for elem in bzrstatus
-			if elem.startswith("-")]
-		myremoved = [
-			"./" + elem.split()[-3:-2][0].split('/')[-1:][0]
-			for elem in bzrstatus
-			if elem and (elem[1:2] == "K" or elem[0:1] == "R")]
-		# Bazaar expands nothing.
-		no_expansion = set()
-		expansion = {}
-		return  (mynew, mychanged, myremoved, no_expansion, expansion)
-
-	def _get_changed_hg_(self, mydeleted):
-		with repoman_popen("hg status --no-status --modified .") as f:
-			mychanged = f.readlines()
-		mychanged = ["./" + elem.rstrip() for elem in mychanged]
-
-		with repoman_popen("hg status --no-status --added .") as f:
-			mynew = f.readlines()
-		mynew = ["./" + elem.rstrip() for elem in mynew]
-
-		with repoman_popen("hg status --no-status --removed .") as f:
-			myremoved = f.readlines()
-		myremoved = ["./" + elem.rstrip() for elem in myremoved]
-		no_expansion = set()
-		expansion = {}
-		return  (mynew, mychanged, myremoved, no_expansion, expansion)
+		changes = self.vcs_settings.vcs.changes
 
+		if not changes.has_changes:
+			utilities.repoman_sez(
+				"\"Doing nothing is not always good for QA.\"")
+			print()
+			print("(Didn't find any changed files...)")
+			print()
+			sys.exit(1)
+		return (changes.new, changes.changed, changes.removed,
+				changes.no_expansion, changes.expansion)
 
 	def get_commit_footer(self):
 		portage_version = getattr(portage, "VERSION", None)

diff --git a/pym/repoman/modules/vcs/None/__init__.py b/pym/repoman/modules/vcs/None/__init__.py
index 4146e1e..2859325 100644
--- a/pym/repoman/modules/vcs/None/__init__.py
+++ b/pym/repoman/modules/vcs/None/__init__.py
@@ -19,6 +19,7 @@ module_spec = {
 			'func_desc': {
 			},
 			'vcs_preserves_mtime': False,
+			'needs_keyword_expansion': False,
 		},
 		'None-changes': {
 			'name': "None_changes",

diff --git a/pym/repoman/modules/vcs/bzr/__init__.py b/pym/repoman/modules/vcs/bzr/__init__.py
index ccdbddf..1192782 100644
--- a/pym/repoman/modules/vcs/bzr/__init__.py
+++ b/pym/repoman/modules/vcs/bzr/__init__.py
@@ -19,6 +19,7 @@ module_spec = {
 			'func_desc': {
 			},
 			'vcs_preserves_mtime': True,
+			'needs_keyword_expansion': False,
 		},
 		'bzr-changes': {
 			'name': "bzr_changes",

diff --git a/pym/repoman/modules/vcs/bzr/changes.py b/pym/repoman/modules/vcs/bzr/changes.py
index 0f70613..dab5d73 100644
--- a/pym/repoman/modules/vcs/bzr/changes.py
+++ b/pym/repoman/modules/vcs/bzr/changes.py
@@ -25,8 +25,13 @@ class Changes(ChangesBase):
 			"./" + elem.split()[-1:][0].split('/')[-1:][0]
 			for elem in bzrstatus
 			if elem and (elem[1:2] == "NK" or elem[0:1] == "R")]
-		if self.options.if_modified == "y":
-			self.removed = [
-				"./" + elem.split()[-3:-2][0].split('/')[-1:][0]
-				for elem in bzrstatus
-				if elem and (elem[1:2] == "K" or elem[0:1] == "R")]
+		#if self.options.if_modified == "y":
+		self.removed = [
+			"./" + elem.split()[-3:-2][0].split('/')[-1:][0]
+			for elem in bzrstatus
+			if elem and (elem[1:2] == "K" or elem[0:1] == "R")]
+		self.unadded = [
+			"./" + elem.rstrip().split()[1].split('/')[-1:][0]
+			for elem in bzrstatus
+			if elem.startswith("?") or elem[0:2] == " D"]
+		# Bazaar expands nothing.

diff --git a/pym/repoman/modules/vcs/changes.py b/pym/repoman/modules/vcs/changes.py
index 6553ac9..b677964 100644
--- a/pym/repoman/modules/vcs/changes.py
+++ b/pym/repoman/modules/vcs/changes.py
@@ -21,6 +21,10 @@ class ChangesBase(object):
 		self.changed = []
 		self.new = []
 		self.removed = []
+		self.no_expansion = set()
+		self.expansion = {}
+		self.deleted = []
+		self.unadded = []
 
 	def scan(self):
 		self._reset()
@@ -37,3 +41,12 @@ class ChangesBase(object):
 		'''Placeholder for subclassing'''
 		pass
 
+	@property
+	def has_deleted(self):
+		'''Placeholder for VCS that requires manual deletion of files'''
+		return self.deleted != []
+
+	@property
+	def has_changes(self):
+		'''Placeholder for VCS repo common has changes result'''
+		return (self.changed or self.new or self.removed or self.deleted) == []

diff --git a/pym/repoman/modules/vcs/cvs/__init__.py b/pym/repoman/modules/vcs/cvs/__init__.py
index 6db6078..ba60e2c 100644
--- a/pym/repoman/modules/vcs/cvs/__init__.py
+++ b/pym/repoman/modules/vcs/cvs/__init__.py
@@ -19,6 +19,7 @@ module_spec = {
 			'func_desc': {
 			},
 			'vcs_preserves_mtime': True,
+			'needs_keyword_expansion': True,
 		},
 		'cvs-changes': {
 			'name': "cvs_changes",

diff --git a/pym/repoman/modules/vcs/cvs/changes.py b/pym/repoman/modules/vcs/cvs/changes.py
index f0893a1..ca07f1f 100644
--- a/pym/repoman/modules/vcs/cvs/changes.py
+++ b/pym/repoman/modules/vcs/cvs/changes.py
@@ -1,7 +1,9 @@
 
 
-from portage import cvstree
+from repoman._portage import portage
 from repoman.modules.vcs.changes import ChangesBase
+from portage import cvstree
+
 
 class Changes(ChangesBase):
 	'''Class object to scan and hold the resultant data
@@ -14,9 +16,12 @@ class Changes(ChangesBase):
 		super(Changes, self).__init__(options)
 
 	def _scan(self):
-		tree = cvstree.getentries("./", recursive=1)
+		tree = portage.cvstree.getentries("./", recursive=1)
 		self.changed = cvstree.findchanged(tree, recursive=1, basedir="./")
 		self.new = cvstree.findnew(tree, recursive=1, basedir="./")
-		if self.options.if_modified == "y":
-			self.removed = cvstree.findremoved(tree, recursive=1, basedir="./")
+		self.removed = cvstree.findremoved(tree, recursive=1, basedir="./")
+		myunadded = portage.cvstree.findunadded(myvcstree, recursive=1, basedir="./")
+		bin_blob_pattern = re.compile("^-kb$")
+		self.no_expansion = set(portage.cvstree.findoption(
+			mycvstree, bin_blob_pattern, recursive=1, basedir="./"))
 		del tree

diff --git a/pym/repoman/modules/vcs/git/__init__.py b/pym/repoman/modules/vcs/git/__init__.py
index 4e1d599..e077767 100644
--- a/pym/repoman/modules/vcs/git/__init__.py
+++ b/pym/repoman/modules/vcs/git/__init__.py
@@ -19,6 +19,7 @@ module_spec = {
 			'func_desc': {
 			},
 			'vcs_preserves_mtime': False,
+			'needs_keyword_expansion': False,
 		},
 		'git-changes': {
 			'name': "git_changes",

diff --git a/pym/repoman/modules/vcs/git/changes.py b/pym/repoman/modules/vcs/git/changes.py
index 6ee39a0..26ffff3 100644
--- a/pym/repoman/modules/vcs/git/changes.py
+++ b/pym/repoman/modules/vcs/git/changes.py
@@ -27,11 +27,17 @@ class Changes(ChangesBase):
 			"--relative --diff-filter=A HEAD") as f:
 			new = f.readlines()
 		self.new = ["./" + elem[:-1] for elem in new]
-		if self.options.if_modified == "y":
-			with repoman_popen(
-				"git diff-index --name-only "
-				"--relative --diff-filter=D HEAD") as f:
-				removed = f.readlines()
-			self.removed = ["./" + elem[:-1] for elem in removed]
-			del removed
+		del new
 
+		with repoman_popen(
+			"git diff-index --name-only "
+			"--relative --diff-filter=D HEAD") as f:
+			removed = f.readlines()
+		self.removed = ["./" + elem[:-1] for elem in removed]
+		del removed
+
+		# get list of files not under version control or missing
+		with repoman_popen("git ls-files --others") as f:
+			unadded = f.readlines()
+		self.unadded = ["./" + elem[:-1] for elem in unadded]
+		del unadded

diff --git a/pym/repoman/modules/vcs/hg/__init__.py b/pym/repoman/modules/vcs/hg/__init__.py
index 6f8a376..6737dfb 100644
--- a/pym/repoman/modules/vcs/hg/__init__.py
+++ b/pym/repoman/modules/vcs/hg/__init__.py
@@ -19,6 +19,7 @@ module_spec = {
 			'func_desc': {
 			},
 			'vcs_preserves_mtime': False,
+			'needs_keyword_expansion': False,
 		},
 		'hg-changes': {
 			'name': "hg_changes",

diff --git a/pym/repoman/modules/vcs/hg/changes.py b/pym/repoman/modules/vcs/hg/changes.py
index 86dffff..621b0d4 100644
--- a/pym/repoman/modules/vcs/hg/changes.py
+++ b/pym/repoman/modules/vcs/hg/changes.py
@@ -18,12 +18,27 @@ class Changes(ChangesBase):
 		with repoman_popen("hg status --no-status --modified .") as f:
 			changed = f.readlines()
 		self.changed = ["./" + elem.rstrip() for elem in changed]
+		del changed
+
 		with repoman_popen("hg status --no-status --added .") as f:
 			new = f.readlines()
 		self.new = ["./" + elem.rstrip() for elem in new]
-		if self.options.if_modified == "y":
-			with repoman_popen("hg status --no-status --removed .") as f:
-				removed = f.readlines()
-			self.removed = ["./" + elem.rstrip() for elem in removed]
-			del removed
-		del changed, new
+		del new
+
+		with repoman_popen("hg status --no-status --removed .") as f:
+			removed = f.readlines()
+		self.removed = ["./" + elem.rstrip() for elem in removed]
+		del removed
+
+		with repoman_popen("hg status --no-status --unknown .") as f:
+			unadded = f.readlines()
+		self.unadded = ["./" + elem.rstrip() for elem in unadded]
+		del unadded
+
+		# Mercurial doesn't handle manually deleted files as removed from
+		# the repository, so the user need to remove them before commit,
+		# using "hg remove [FILES]"
+		with repoman_popen("hg status --no-status --deleted .") as f:
+			deleted = f.readlines()
+		self.deleted = ["./" + elem.rstrip() for elem in deleted]
+		del deleted

diff --git a/pym/repoman/modules/vcs/settings.py b/pym/repoman/modules/vcs/settings.py
index 34f1c78..bcd5f18 100644
--- a/pym/repoman/modules/vcs/settings.py
+++ b/pym/repoman/modules/vcs/settings.py
@@ -4,7 +4,6 @@ from __future__ import print_function, unicode_literals
 import logging
 import sys
 
-from repoman._portage import portage
 from portage.output import red
 from repoman.modules.vcs import module_controller, module_names
 from repoman.modules.vcs.vcs import FindVCS
@@ -58,6 +57,8 @@ class VCSSettings(object):
 			logging.error("VCSSettings: Unknown VCS type: %s", self.vcs)
 			logging.error("Available modules: %s", module_controller.parents)
 
+		self.needs_keyword_expansion = module_controller.modules[
+				"%s_status" % self.vcs]['needs_keyword_expansion']
 		self.vcs_local_opts = repoman_settings.get(
 			"REPOMAN_VCS_LOCAL_OPTS", "").split()
 		self.vcs_global_opts = repoman_settings.get(
@@ -88,5 +89,5 @@ class VCSSettings(object):
 	def changes(self):
 		if not self._changes:
 			changes = self.module_controller.get_class('%s_changes' % self.vcs)
-			self._changes = changes(self.options)
+			self._changes = changes(self.options, self.vcs)
 		return self._changes

diff --git a/pym/repoman/modules/vcs/svn/__init__.py b/pym/repoman/modules/vcs/svn/__init__.py
index 41e481a..becb93e 100644
--- a/pym/repoman/modules/vcs/svn/__init__.py
+++ b/pym/repoman/modules/vcs/svn/__init__.py
@@ -19,6 +19,7 @@ module_spec = {
 			'func_desc': {
 			},
 			'vcs_preserves_mtime': False,
+			'needs_keyword_expansion': True,
 		},
 		'svn-changes': {
 			'name': "svn_changes",

diff --git a/pym/repoman/modules/vcs/svn/changes.py b/pym/repoman/modules/vcs/svn/changes.py
index 3567b61..f12b47d 100644
--- a/pym/repoman/modules/vcs/svn/changes.py
+++ b/pym/repoman/modules/vcs/svn/changes.py
@@ -25,9 +25,23 @@ class Changes(ChangesBase):
 			"./" + elem.split()[-1:][0]
 			for elem in svnstatus
 			if elem.startswith("A")]
-		if self.options.if_modified == "y":
-			self.removed = [
-				"./" + elem.split()[-1:][0]
-				for elem in svnstatus
-				if elem.startswith("D")]
+		self.removed = [
+			"./" + elem.split()[-1:][0]
+			for elem in svnstatus
+			if elem.startswith("D")]
+
+		# Subversion expands keywords specified in svn:keywords properties.
+		with repoman_popen("svn propget -R svn:keywords") as f:
+			props = f.readlines()
+		self.expansion = dict(
+			("./" + prop.split(" - ")[0], prop.split(" - ")[1].split())
+			for prop in props if " - " in prop)
+		del props
 
+		with repoman_popen("svn status --no-ignore") as f:
+			svnstatus = f.readlines()
+		self.unadded = [
+			"./" + elem.rstrip().split()[1]
+			for elem in svnstatus
+			if elem.startswith("?") or elem.startswith("I")]
+		del svnstatus


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/vcs/cvs/, pym/repoman/modules/vcs/bzr/, ...
@ 2016-01-30  8:00 Brian Dolbec
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2016-01-30  8:00 UTC (permalink / raw
  To: gentoo-commits

commit:     7ed3cb06a165bdd933a2faf43ff839920cf5d704
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 30 07:58:04 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 30 07:58:04 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=7ed3cb06

repoman: Create docstrings for all new vcs module files

 pym/repoman/modules/vcs/None/changes.py |  9 ++++++++-
 pym/repoman/modules/vcs/None/status.py  | 35 ++++++++++++++++++++++++++++++---
 pym/repoman/modules/vcs/bzr/__init__.py |  2 +-
 pym/repoman/modules/vcs/bzr/changes.py  |  9 ++++++++-
 pym/repoman/modules/vcs/bzr/status.py   | 30 ++++++++++++++++++++++++++++
 pym/repoman/modules/vcs/changes.py      |  3 +++
 pym/repoman/modules/vcs/cvs/__init__.py |  2 +-
 pym/repoman/modules/vcs/cvs/changes.py  |  9 ++++++++-
 pym/repoman/modules/vcs/cvs/status.py   | 18 +++++++++++++++++
 pym/repoman/modules/vcs/git/__init__.py |  2 +-
 pym/repoman/modules/vcs/git/changes.py  |  9 ++++++++-
 pym/repoman/modules/vcs/git/status.py   | 33 +++++++++++++++++++++++++++----
 pym/repoman/modules/vcs/hg/__init__.py  |  2 +-
 pym/repoman/modules/vcs/hg/changes.py   |  9 ++++++++-
 pym/repoman/modules/vcs/hg/status.py    | 31 +++++++++++++++++++++++++++++
 pym/repoman/modules/vcs/settings.py     |  2 +-
 pym/repoman/modules/vcs/svn/__init__.py |  2 +-
 pym/repoman/modules/vcs/svn/changes.py  |  9 ++++++++-
 pym/repoman/modules/vcs/svn/status.py   | 27 ++++++++++++++++++++++---
 19 files changed, 221 insertions(+), 22 deletions(-)

diff --git a/pym/repoman/modules/vcs/None/changes.py b/pym/repoman/modules/vcs/None/changes.py
index f95af69..759b554 100644
--- a/pym/repoman/modules/vcs/None/changes.py
+++ b/pym/repoman/modules/vcs/None/changes.py
@@ -1,4 +1,6 @@
-
+'''
+None module Changes class submodule
+'''
 
 from repoman.modules.vcs.changes import ChangesBase
 
@@ -11,7 +13,12 @@ class Changes(ChangesBase):
 	vcs = 'None'
 
 	def __init__(self, options):
+		'''Class init
+
+		@param options: commandline options
+		'''
 		super(Changes, self).__init__(options)
 
 	def scan(self):
+		'''VCS type scan function, looks for all detectable changes'''
 		pass

diff --git a/pym/repoman/modules/vcs/None/status.py b/pym/repoman/modules/vcs/None/status.py
index b23fa10..d6e5ca0 100644
--- a/pym/repoman/modules/vcs/None/status.py
+++ b/pym/repoman/modules/vcs/None/status.py
@@ -1,24 +1,53 @@
-
+'''
+None (non-VCS) module Status class submodule
+'''
 
 
 class Status(object):
+	'''Performs status checks on the svn repository'''
 
 	def __init__(self, qatracker, eadded):
+		'''Class init
+
+		@param qatracker: QATracker class instance
+		@param eadded: list
+		'''
 		self.qatracker = qatracker
 		self.eadded = eadded
 
 	def check(self, checkdir, checkdir_relative, xpkg):
+		'''Perform the svn status check
+
+		@param checkdir: string of the directory being checked
+		@param checkdir_relative: string of the relative directory being checked
+		@param xpkg: string of the package being checked
+		@returns: boolean
+		'''
 		return True
 
 	@staticmethod
-	def supports_gpg_sign():
+	def detect_conflicts(options):
+		'''Are there any merge conflicts present in the VCS tracking system
+
+		@param options: command line options
+		@returns: Boolean
+		'''
 		return False
 
 	@staticmethod
-	def detect_conflicts(options):
+	def supports_gpg_sign():
+		'''Does this vcs system support gpg commit signatures
+
+		@returns: Boolean
+		'''
 		return False
 
 	@staticmethod
 	def isVcsDir(dirname):
+		'''Is the directory belong to the vcs system
+
+		@param dirname: string, directory name
+		@returns: Boolean
+		'''
 		return False
 

diff --git a/pym/repoman/modules/vcs/bzr/__init__.py b/pym/repoman/modules/vcs/bzr/__init__.py
index 1192782..4490ed8 100644
--- a/pym/repoman/modules/vcs/bzr/__init__.py
+++ b/pym/repoman/modules/vcs/bzr/__init__.py
@@ -1,7 +1,7 @@
 # Copyright 2014-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-doc = """BZR plug-in module for portage.
+doc = """Bazaar (bzr) plug-in module for portage.
 Performs variaous Bazaar actions and checks on repositories."""
 __doc__ = doc[:]
 

diff --git a/pym/repoman/modules/vcs/bzr/changes.py b/pym/repoman/modules/vcs/bzr/changes.py
index dab5d73..751d803 100644
--- a/pym/repoman/modules/vcs/bzr/changes.py
+++ b/pym/repoman/modules/vcs/bzr/changes.py
@@ -1,4 +1,6 @@
-
+'''
+Bazaar module Changes class submodule
+'''
 
 from repoman.modules.vcs.changes import ChangesBase
 from repoman._subprocess import repoman_popen
@@ -12,9 +14,14 @@ class Changes(ChangesBase):
 	vcs = 'bzr'
 
 	def __init__(self, options):
+		'''Class init
+
+		@param options: commandline options
+		'''
 		super(Changes, self).__init__(options)
 
 	def _scan(self):
+		'''VCS type scan function, looks for all detectable changes'''
 		with repoman_popen("bzr status -S .") as f:
 			bzrstatus = f.readlines()
 		self.changed = [

diff --git a/pym/repoman/modules/vcs/bzr/status.py b/pym/repoman/modules/vcs/bzr/status.py
index e375b05..d5f3326 100644
--- a/pym/repoman/modules/vcs/bzr/status.py
+++ b/pym/repoman/modules/vcs/bzr/status.py
@@ -1,3 +1,6 @@
+'''
+Bazaar module Status class submodule
+'''
 
 from repoman._portage import portage
 from portage import os
@@ -5,12 +8,25 @@ from repoman._subprocess import repoman_popen
 
 
 class Status(object):
+	'''Performs status checks on the svn repository'''
 
 	def __init__(self, qatracker, eadded):
+		'''Class init
+
+		@param qatracker: QATracker class instance
+		@param eadded: list
+		'''
 		self.qatracker = qatracker
 		self.eadded = eadded
 
 	def check(self, checkdir, checkdir_relative, xpkg):
+		'''Perform the svn status check
+
+		@param checkdir: string of the directory being checked
+		@param checkdir_relative: string of the relative directory being checked
+		@param xpkg: string of the package being checked
+		@returns: boolean
+		'''
 		try:
 			myf = repoman_popen(
 				"bzr ls -v --kind=file " +
@@ -29,12 +45,26 @@ class Status(object):
 
 	@staticmethod
 	def detect_conflicts(options):
+		'''Are there any merge conflicts present in the VCS tracking system
+
+		@param options: command line options
+		@returns: Boolean
+		'''
 		return False
 
 	@staticmethod
 	def supports_gpg_sign():
+		'''Does this vcs system support gpg commit signatures
+
+		@returns: Boolean
+		'''
 		return False
 
 	@staticmethod
 	def isVcsDir(dirname):
+		'''Is the directory belong to the vcs system
+
+		@param dirname: string, directory name
+		@returns: Boolean
+		'''
 		return dirname in [".bzr"]

diff --git a/pym/repoman/modules/vcs/changes.py b/pym/repoman/modules/vcs/changes.py
index b677964..558ca39 100644
--- a/pym/repoman/modules/vcs/changes.py
+++ b/pym/repoman/modules/vcs/changes.py
@@ -1,3 +1,6 @@
+'''
+Base Changes class
+'''
 
 import os
 from itertools import chain

diff --git a/pym/repoman/modules/vcs/cvs/__init__.py b/pym/repoman/modules/vcs/cvs/__init__.py
index ba60e2c..0b4587b 100644
--- a/pym/repoman/modules/vcs/cvs/__init__.py
+++ b/pym/repoman/modules/vcs/cvs/__init__.py
@@ -1,7 +1,7 @@
 # Copyright 2014-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-doc = """CVS plug-in module for portage.
+doc = """CVS (cvs) plug-in module for portage.
 Performs variaous CVS actions and checks on repositories."""
 __doc__ = doc[:]
 

diff --git a/pym/repoman/modules/vcs/cvs/changes.py b/pym/repoman/modules/vcs/cvs/changes.py
index ca07f1f..a8f3311 100644
--- a/pym/repoman/modules/vcs/cvs/changes.py
+++ b/pym/repoman/modules/vcs/cvs/changes.py
@@ -1,4 +1,6 @@
-
+'''
+CVS module Changes class submodule
+'''
 
 from repoman._portage import portage
 from repoman.modules.vcs.changes import ChangesBase
@@ -13,9 +15,14 @@ class Changes(ChangesBase):
 	vcs = 'cvs'
 
 	def __init__(self, options):
+		'''Class init
+
+		@param options: commandline options
+		'''
 		super(Changes, self).__init__(options)
 
 	def _scan(self):
+		'''VCS type scan function, looks for all detectable changes'''
 		tree = portage.cvstree.getentries("./", recursive=1)
 		self.changed = cvstree.findchanged(tree, recursive=1, basedir="./")
 		self.new = cvstree.findnew(tree, recursive=1, basedir="./")

diff --git a/pym/repoman/modules/vcs/cvs/status.py b/pym/repoman/modules/vcs/cvs/status.py
index 24e2825..1917bde 100644
--- a/pym/repoman/modules/vcs/cvs/status.py
+++ b/pym/repoman/modules/vcs/cvs/status.py
@@ -1,3 +1,6 @@
+'''
+CVS module Status class submodule
+'''
 
 import logging
 import subprocess
@@ -11,8 +14,14 @@ from portage import _unicode_encode, _unicode_decode
 
 
 class Status(object):
+	'''Performs status checks on the svn repository'''
 
 	def __init__(self, qatracker, eadded):
+		'''Class init
+
+		@param qatracker: QATracker class instance
+		@param eadded: list
+		'''
 		self.qatracker = qatracker
 		self.eadded = eadded
 
@@ -106,8 +115,17 @@ class Status(object):
 
 	@staticmethod
 	def supports_gpg_sign():
+		'''Does this vcs system support gpg commit signatures
+
+		@returns: Boolean
+		'''
 		return False
 
 	@staticmethod
 	def isVcsDir(dirname):
+		'''Is the directory belong to the vcs system
+
+		@param dirname: string, directory name
+		@returns: Boolean
+		'''
 		return dirname in ["CVS"]

diff --git a/pym/repoman/modules/vcs/git/__init__.py b/pym/repoman/modules/vcs/git/__init__.py
index e077767..eecd4a1 100644
--- a/pym/repoman/modules/vcs/git/__init__.py
+++ b/pym/repoman/modules/vcs/git/__init__.py
@@ -1,7 +1,7 @@
 # Copyright 2014-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-doc = """Git plug-in module for portage.
+doc = """Git (git) plug-in module for portage.
 Performs variaous git actions and checks on repositories."""
 __doc__ = doc[:]
 

diff --git a/pym/repoman/modules/vcs/git/changes.py b/pym/repoman/modules/vcs/git/changes.py
index 26ffff3..3ce6e9d 100644
--- a/pym/repoman/modules/vcs/git/changes.py
+++ b/pym/repoman/modules/vcs/git/changes.py
@@ -1,4 +1,6 @@
-
+'''
+Git module Changes class submodule
+'''
 
 from repoman.modules.vcs.changes import ChangesBase
 from repoman._subprocess import repoman_popen
@@ -12,9 +14,14 @@ class Changes(ChangesBase):
 	vcs = 'git'
 
 	def __init__(self, options):
+		'''Class init
+
+		@param options: commandline options
+		'''
 		super(Changes, self).__init__(options)
 
 	def _scan(self):
+		'''VCS type scan function, looks for all detectable changes'''
 		with repoman_popen(
 			"git diff-index --name-only "
 			"--relative --diff-filter=M HEAD") as f:

diff --git a/pym/repoman/modules/vcs/git/status.py b/pym/repoman/modules/vcs/git/status.py
index 5ab5f94..963abf6 100644
--- a/pym/repoman/modules/vcs/git/status.py
+++ b/pym/repoman/modules/vcs/git/status.py
@@ -1,3 +1,6 @@
+'''
+Git module Status class submodule
+'''
 
 import re
 
@@ -7,12 +10,25 @@ from repoman._subprocess import repoman_popen, repoman_getstatusoutput
 
 
 class Status(object):
+	'''Performs status checks on the svn repository'''
 
 	def __init__(self, qatracker, eadded):
+		'''Class init
+
+		@param qatracker: QATracker class instance
+		@param eadded: list
+		'''
 		self.qatracker = qatracker
 		self.eadded = eadded
 
 	def check(self, checkdir, checkdir_relative, xpkg):
+		'''Perform the svn status check
+
+		@param checkdir: string of the directory being checked
+		@param checkdir_relative: string of the relative directory being checked
+		@param xpkg: string of the package being checked
+		@returns: boolean
+		'''
 		myf = repoman_popen(
 			"git ls-files --others %s" %
 			(portage._shell_quote(checkdir_relative),))
@@ -25,7 +41,20 @@ class Status(object):
 		return True
 
 	@staticmethod
+	def detect_conflicts(options):
+		'''Are there any merge conflicts present in the VCS tracking system
+
+		@param options: command line options
+		@returns: Boolean
+		'''
+		return False
+
+	@staticmethod
 	def supports_gpg_sign():
+		'''Does this vcs system support gpg commit signatures
+
+		@returns: Boolean
+		'''
 		status, cmd_output = \
 			repoman_getstatusoutput("git --version")
 		cmd_output = cmd_output.split()
@@ -40,10 +69,6 @@ class Status(object):
 		return False
 
 	@staticmethod
-	def detect_conflicts(options):
-		return False
-
-	@staticmethod
 	def isVcsDir(dirname):
 		return dirname in [".git"]
 

diff --git a/pym/repoman/modules/vcs/hg/__init__.py b/pym/repoman/modules/vcs/hg/__init__.py
index 6737dfb..2e39970 100644
--- a/pym/repoman/modules/vcs/hg/__init__.py
+++ b/pym/repoman/modules/vcs/hg/__init__.py
@@ -1,7 +1,7 @@
 # Copyright 2014-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-doc = """HG plug-in module for portage.
+doc = """Mercurial (hg) plug-in module for portage.
 Performs variaous mercurial actions and checks on repositories."""
 __doc__ = doc[:]
 

diff --git a/pym/repoman/modules/vcs/hg/changes.py b/pym/repoman/modules/vcs/hg/changes.py
index 621b0d4..f7103bd 100644
--- a/pym/repoman/modules/vcs/hg/changes.py
+++ b/pym/repoman/modules/vcs/hg/changes.py
@@ -1,4 +1,6 @@
-
+'''
+Mercurial module Changes class submodule
+'''
 
 from repoman.modules.vcs.changes import ChangesBase
 from repoman._subprocess import repoman_popen
@@ -12,9 +14,14 @@ class Changes(ChangesBase):
 	vcs = 'hg'
 
 	def __init__(self, options):
+		'''Class init
+
+		@param options: commandline options
+		'''
 		super(Changes, self).__init__(options)
 
 	def _scan(self):
+		'''VCS type scan function, looks for all detectable changes'''
 		with repoman_popen("hg status --no-status --modified .") as f:
 			changed = f.readlines()
 		self.changed = ["./" + elem.rstrip() for elem in changed]

diff --git a/pym/repoman/modules/vcs/hg/status.py b/pym/repoman/modules/vcs/hg/status.py
index 0058794..a3081cb 100644
--- a/pym/repoman/modules/vcs/hg/status.py
+++ b/pym/repoman/modules/vcs/hg/status.py
@@ -1,15 +1,32 @@
+'''
+Mercurial module Status class submodule
+'''
 
 from repoman._portage import portage
 from portage import os
 from repoman._subprocess import repoman_popen
 
+
 class Status(object):
+	'''Performs status checks on the svn repository'''
 
 	def __init__(self, qatracker, eadded):
+		'''Class init
+
+		@param qatracker: QATracker class instance
+		@param eadded: list
+		'''
 		self.qatracker = qatracker
 		self.eadded = eadded
 
 	def check(self, checkdir, checkdir_relative, xpkg):
+		'''Perform the svn status check
+
+		@param checkdir: string of the directory being checked
+		@param checkdir_relative: string of the relative directory being checked
+		@param xpkg: string of the package being checked
+		@returns: boolean
+		'''
 		myf = repoman_popen(
 			"hg status --no-status --unknown %s" %
 			(portage._shell_quote(checkdir_relative),))
@@ -23,12 +40,26 @@ class Status(object):
 
 	@staticmethod
 	def detect_conflicts(options):
+		'''Are there any merge conflicts present in the VCS tracking system
+
+		@param options: command line options
+		@returns: Boolean
+		'''
 		return False
 
 	@staticmethod
 	def supports_gpg_sign():
+		'''Does this vcs system support gpg commit signatures
+
+		@returns: Boolean
+		'''
 		return False
 
 	@staticmethod
 	def isVcsDir(dirname):
+		'''Is the directory belong to the vcs system
+
+		@param dirname: string, directory name
+		@returns: Boolean
+		'''
 		return dirname in [".hg"]

diff --git a/pym/repoman/modules/vcs/settings.py b/pym/repoman/modules/vcs/settings.py
index bcd5f18..f51c3b2 100644
--- a/pym/repoman/modules/vcs/settings.py
+++ b/pym/repoman/modules/vcs/settings.py
@@ -89,5 +89,5 @@ class VCSSettings(object):
 	def changes(self):
 		if not self._changes:
 			changes = self.module_controller.get_class('%s_changes' % self.vcs)
-			self._changes = changes(self.options, self.vcs)
+			self._changes = changes(self.options)
 		return self._changes

diff --git a/pym/repoman/modules/vcs/svn/__init__.py b/pym/repoman/modules/vcs/svn/__init__.py
index becb93e..6bb0b9a 100644
--- a/pym/repoman/modules/vcs/svn/__init__.py
+++ b/pym/repoman/modules/vcs/svn/__init__.py
@@ -1,7 +1,7 @@
 # Copyright 2014-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-doc = """SVN plug-in module for portage.
+doc = """Subversion (svn) plug-in module for portage.
 Performs variaous subversion actions and checks on repositories."""
 __doc__ = doc[:]
 

diff --git a/pym/repoman/modules/vcs/svn/changes.py b/pym/repoman/modules/vcs/svn/changes.py
index f12b47d..17ff5b5 100644
--- a/pym/repoman/modules/vcs/svn/changes.py
+++ b/pym/repoman/modules/vcs/svn/changes.py
@@ -1,4 +1,6 @@
-
+'''
+Subversion module Changes class submodule
+'''
 
 from repoman.modules.vcs.changes import ChangesBase
 from repoman._subprocess import repoman_popen
@@ -12,9 +14,14 @@ class Changes(ChangesBase):
 	vcs = 'svn'
 
 	def __init__(self, options):
+		'''Class init
+
+		@param options: commandline options
+		'''
 		super(Changes, self).__init__(options)
 
 	def _scan(self):
+		'''VCS type scan function, looks for all detectable changes'''
 		with repoman_popen("svn status") as f:
 			svnstatus = f.readlines()
 		self.changed = [

diff --git a/pym/repoman/modules/vcs/svn/status.py b/pym/repoman/modules/vcs/svn/status.py
index ea8e102..3b57149 100644
--- a/pym/repoman/modules/vcs/svn/status.py
+++ b/pym/repoman/modules/vcs/svn/status.py
@@ -1,5 +1,5 @@
 '''
-SVN module Status class submodule
+Subversion module Status class submodule
 '''
 
 import logging
@@ -19,10 +19,22 @@ class Status(object):
 	'''Performs status checks on the svn repository'''
 
 	def __init__(self, qatracker, eadded):
+		'''Class init
+
+		@param qatracker: QATracker class instance
+		@param eadded: list
+		'''
 		self.qatracker = qatracker
 		self.eadded = eadded
 
 	def check(self, checkdir, checkdir_relative, xpkg):
+		'''Perform the svn status check
+
+		@param checkdir: string of the directory being checked
+		@param checkdir_relative: string of the relative directory being checked
+		@param xpkg: string of the package being checked
+		@returns: boolean
+		'''
 		try:
 			myf = repoman_popen(
 				"svn status --depth=files --verbose " +
@@ -68,8 +80,8 @@ class Status(object):
 
 		Args:
 			vcs - A string identifying the version control system in use
-		Returns:
-			None (calls sys.exit on fatal problems)
+		Returns: boolean
+			(calls sys.exit on fatal problems)
 		"""
 
 		cmd = "svn status -u 2>&1 | egrep -v '^.  +.*/digest-[^/]+' | head -n-1"
@@ -122,8 +134,17 @@ class Status(object):
 
 	@staticmethod
 	def supports_gpg_sign():
+		'''Does this vcs system support gpg commit signatures
+
+		@returns: Boolean
+		'''
 		return False
 
 	@staticmethod
 	def isVcsDir(dirname):
+		'''Is the directory belong to the vcs system
+
+		@param dirname: string, directory name
+		@returns: Boolean
+		'''
 		return dirname in [".svn"]


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-01-30  8:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-30  8:00 [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/vcs/cvs/, pym/repoman/modules/vcs/bzr/, Brian Dolbec
  -- strict thread matches above, loose matches on Subject: below --
2016-01-30  8:00 Brian Dolbec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox