public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <brian.dolbec@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/
Date: Tue,  3 Jun 2014 18:15:42 +0000 (UTC)	[thread overview]
Message-ID: <1401818832.9a17984d163ea81df5cbf0b54eda6b9cbb38301a.dol-sen@gentoo> (raw)

commit:     9a17984d163ea81df5cbf0b54eda6b9cbb38301a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jun  3 18:00:05 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Jun  3 18:07:12 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9a17984d

Repoman: Refactor repos.RepoSettings class, fix the repoman_settings not being re-assigned

When the repo is not in the confiig'd repos, it creates a ne repoman_settings object which contains
the temporaily activated repo.  main.py was not re-assigning repoman_settings to the new object.
Split out _add_repo() to it's own function.
Split out the gpg-sign specific function for git into plugin-ready functions, for later.

---
 pym/repoman/main.py  |   2 +
 pym/repoman/repos.py | 119 ++++++++++++++++++++++++++++++++-------------------
 2 files changed, 77 insertions(+), 44 deletions(-)

diff --git a/pym/repoman/main.py b/pym/repoman/main.py
index 425b891..a96f38f 100755
--- a/pym/repoman/main.py
+++ b/pym/repoman/main.py
@@ -128,6 +128,8 @@ vcs_settings = VCSSettings(options, repoman_settings)
 repo_settings = RepoSettings(config_root, portdir, portdir_overlay,
 		repoman_settings, vcs_settings, options, qawarnings)
 
+repoman_settings = repo_settings.repoman_settings
+
 portdb = repo_settings.portdb
 ##################
 

diff --git a/pym/repoman/repos.py b/pym/repoman/repos.py
index b79e241..6bd1eb4 100644
--- a/pym/repoman/repos.py
+++ b/pym/repoman/repos.py
@@ -26,75 +26,46 @@ class RepoSettings(object):
 	def __init__(self, config_root, portdir, portdir_overlay,
 		repoman_settings=None, vcs_settings=None, options=None,
 		qawarnings=None):
+		self.repoman_settings = repoman_settings
+		self.vcs_settings = vcs_settings
+
 		# Ensure that current repository is in the list of enabled repositories.
 		self.repodir = os.path.realpath(portdir_overlay)
 		try:
 			repoman_settings.repositories.get_repo_for_location(self.repodir)
 		except KeyError:
-			self.repo_conf = portage.repository.config
-			self.repo_name = self.repo_conf.RepoConfig._read_valid_repo_name(portdir_overlay)[0]
-			self.layout_conf_data = self.repo_conf.parse_layout_conf(portdir_overlay)[0]
-			if self.layout_conf_data['repo-name']:
-				self.repo_name = self.layout_conf_data['repo-name']
-			tmp_conf_file = io.StringIO(textwrap.dedent("""
-				[%s]
-				location = %s
-				""") % (self.repo_name, portdir_overlay))
-			# Ensure that the repository corresponding to $PWD overrides a
-			# repository of the same name referenced by the existing PORTDIR
-			# or PORTDIR_OVERLAY settings.
-			repoman_settings['PORTDIR_OVERLAY'] = "%s %s" % (
-				repoman_settings.get('PORTDIR_OVERLAY', ''),
-				portage._shell_quote(portdir_overlay))
-			self.repositories = self.repo_conf.load_repository_config(
-				repoman_settings, extra_files=[tmp_conf_file])
-			# We have to call the config constructor again so that attributes
-			# dependent on config.repositories are initialized correctly.
-			repoman_settings = portage.config(
-				config_root=config_root, local_config=False, repositories=self.repositories)
+			self._add_repo(config_root, portdir_overlay)
 
-		self.root = repoman_settings['EROOT']
+		self.root = self.repoman_settings['EROOT']
 		self.trees = {
-			self.root: {'porttree': portage.portagetree(settings=repoman_settings)}
+			self.root: {'porttree': portage.portagetree(settings=self.repoman_settings)}
 		}
 		self.portdb = self.trees[self.root]['porttree'].dbapi
 
 		# Constrain dependency resolution to the master(s)
 		# that are specified in layout.conf.
-		self.repo_config = repoman_settings.repositories.get_repo_for_location(self.repodir)
+		self.repo_config = self.repoman_settings.repositories.get_repo_for_location(self.repodir)
 		self.portdb.porttrees = list(self.repo_config.eclass_db.porttrees)
 		self.portdir = self.portdb.porttrees[0]
 		self.commit_env = os.environ.copy()
 		# list() is for iteration on a copy.
-		for repo in list(repoman_settings.repositories):
+		for repo in list(self.repoman_settings.repositories):
 			# all paths are canonical
 			if repo.location not in self.repo_config.eclass_db.porttrees:
-				del repoman_settings.repositories[repo.name]
+				del self.repoman_settings.repositories[repo.name]
 
 		if self.repo_config.allow_provide_virtual:
 			qawarnings.add("virtual.oldstyle")
 
 		if self.repo_config.sign_commit:
-			if vcs_settings.vcs == 'git':
-				# NOTE: It's possible to use --gpg-sign=key_id to specify the key in
-				# the commit arguments. If key_id is unspecified, then it must be
-				# configured by `git config user.signingkey key_id`.
-				vcs_settings.vcs_local_opts.append("--gpg-sign")
-				if repoman_settings.get("PORTAGE_GPG_DIR"):
-					# Pass GNUPGHOME to git for bug #462362.
-					self.commit_env["GNUPGHOME"] = repoman_settings["PORTAGE_GPG_DIR"]
-
-				# Pass GPG_TTY to git for bug #477728.
-				try:
-					self.commit_env["GPG_TTY"] = os.ttyname(sys.stdin.fileno())
-				except OSError:
-					pass
+			func = getattr(self, '_vcs_gpg_%s' % vcs_settings.vcs)
+			func()
 
 		# In order to disable manifest signatures, repos may set
 		# "sign-manifests = false" in metadata/layout.conf. This
 		# can be used to prevent merge conflicts like those that
 		# thin-manifests is designed to prevent.
-		self.sign_manifests = "sign" in repoman_settings.features and \
+		self.sign_manifests = "sign" in self.repoman_settings.features and \
 			self.repo_config.sign_manifest
 
 		if self.repo_config.sign_manifest and self.repo_config.name == "gentoo" and \
@@ -110,13 +81,13 @@ class RepoSettings(object):
 				logging.warn(line)
 
 		is_commit = options.mode in ("commit",)
-		valid_gpg_key = repoman_settings.get("PORTAGE_GPG_KEY") and re.match(
-			r'^%s$' % GPG_KEY_ID_REGEX, repoman_settings["PORTAGE_GPG_KEY"])
+		valid_gpg_key = self.repoman_settings.get("PORTAGE_GPG_KEY") and re.match(
+			r'^%s$' % GPG_KEY_ID_REGEX, self.repoman_settings["PORTAGE_GPG_KEY"])
 
 		if self.sign_manifests and is_commit and not valid_gpg_key:
 			logging.error(
 				"PORTAGE_GPG_KEY value is invalid: %s" %
-				repoman_settings["PORTAGE_GPG_KEY"])
+				self.repoman_settings["PORTAGE_GPG_KEY"])
 			sys.exit(1)
 
 		manifest_hashes = self.repo_config.manifest_hashes
@@ -150,6 +121,66 @@ class RepoSettings(object):
 					logging.error(line)
 				sys.exit(1)
 
+
+	def _add_repo(self, config_root, portdir_overlay):
+			self.repo_conf = portage.repository.config
+			self.repo_name = self.repo_conf.RepoConfig._read_valid_repo_name(portdir_overlay)[0]
+			self.layout_conf_data = self.repo_conf.parse_layout_conf(portdir_overlay)[0]
+			if self.layout_conf_data['repo-name']:
+				self.repo_name = self.layout_conf_data['repo-name']
+			tmp_conf_file = io.StringIO(textwrap.dedent("""
+				[%s]
+				location = %s
+				""") % (self.repo_name, portdir_overlay))
+			# Ensure that the repository corresponding to $PWD overrides a
+			# repository of the same name referenced by the existing PORTDIR
+			# or PORTDIR_OVERLAY settings.
+			self.repoman_settings['PORTDIR_OVERLAY'] = "%s %s" % (
+				self.repoman_settings.get('PORTDIR_OVERLAY', ''),
+				portage._shell_quote(portdir_overlay))
+			self.repositories = self.repo_conf.load_repository_config(
+				self.repoman_settings, extra_files=[tmp_conf_file])
+			# We have to call the config constructor again so that attributes
+			# dependent on config.repositories are initialized correctly.
+			self.repoman_settings = portage.config(
+				config_root=config_root, local_config=False, repositories=self.repositories)
+
+	###########  future vcs plugin functions
+
+	def _vcs_gpg_bzr(self):
+		pass
+
+
+	def _vcs_gpg_cvs(self):
+		pass
+
+
+	def _vcs_gpg_git(self):
+		# NOTE: It's possible to use --gpg-sign=key_id to specify the key in
+		# the commit arguments. If key_id is unspecified, then it must be
+		# configured by `git config user.signingkey key_id`.
+		self.vcs_settings.vcs_local_opts.append("--gpg-sign")
+		if self.repoman_settings.get("PORTAGE_GPG_DIR"):
+			# Pass GNUPGHOME to git for bug #462362.
+			self.commit_env["GNUPGHOME"] = self.repoman_settings["PORTAGE_GPG_DIR"]
+
+		# Pass GPG_TTY to git for bug #477728.
+		try:
+			self.commit_env["GPG_TTY"] = os.ttyname(sys.stdin.fileno())
+		except OSError:
+			pass
+
+
+	def _vcs_gpg_hg(self):
+		pass
+
+
+	def _vcs_gpg_svn(self):
+		pass
+
+
+
+
 def list_checks(kwlist, liclist, uselist, repoman_settings):
 	liclist_deprecated = set()
 	if "DEPRECATED" in repoman_settings._license_manager._license_groups:


             reply	other threads:[~2014-06-03 18:15 UTC|newest]

Thread overview: 216+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-03 18:15 Brian Dolbec [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-05-03  9:33 [gentoo-commits] proj/portage:repoman commit in: pym/repoman/ Brian Dolbec
2016-04-29 17:24 [gentoo-commits] proj/portage:master " Brian Dolbec
2016-04-28 15:05 ` [gentoo-commits] proj/portage:repoman " Brian Dolbec
2016-04-29 17:24 [gentoo-commits] proj/portage:master " Brian Dolbec
2016-04-28 15:05 ` [gentoo-commits] proj/portage:repoman " Brian Dolbec
2016-04-29 17:24 [gentoo-commits] proj/portage:master " Brian Dolbec
2016-04-26 14:47 ` [gentoo-commits] proj/portage:repoman " Brian Dolbec
2016-04-28 15:05 Brian Dolbec
2016-04-27  5:22 Brian Dolbec
2016-04-27  5:22 Brian Dolbec
2016-04-27  5:22 Brian Dolbec
2016-04-26 18:08 Zac Medico
2016-04-25 15:32 Brian Dolbec
2016-04-25 15:32 Brian Dolbec
2016-04-25 15:32 Brian Dolbec
2016-04-21 16:54 Brian Dolbec
2016-04-21 16:54 Brian Dolbec
2016-04-21 16:54 Brian Dolbec
2016-04-21 16:54 Brian Dolbec
2016-04-17 15:42 Brian Dolbec
2016-04-16 20:00 Zac Medico
2016-03-15 19:00 Brian Dolbec
2016-03-12 18:10 Brian Dolbec
2016-03-12 18:10 Brian Dolbec
2016-03-12 18:10 Brian Dolbec
2016-03-11  0:41 Brian Dolbec
2016-03-11  0:41 Brian Dolbec
2016-03-11  0:41 Brian Dolbec
2016-03-07 21:53 Brian Dolbec
2016-03-07 21:53 Brian Dolbec
2016-03-07 21:53 Brian Dolbec
2016-02-01  7:55 Zac Medico
2016-02-01  7:21 Zac Medico
2016-01-31 20:03 Brian Dolbec
2016-01-31 20:03 Brian Dolbec
2016-01-31 20:03 Brian Dolbec
2016-01-30  8:00 Brian Dolbec
2016-01-30  8:00 Brian Dolbec
2016-01-30  8:00 Brian Dolbec
2016-01-30  6:58 Brian Dolbec
2016-01-30  6:58 Brian Dolbec
2016-01-30  6:58 Brian Dolbec
2016-01-29  5:01 Brian Dolbec
2016-01-29  5:01 Brian Dolbec
2016-01-29  5:01 Brian Dolbec
2016-01-27 23:15 Brian Dolbec
2016-01-27 23:15 Brian Dolbec
2016-01-27 23:15 Brian Dolbec
2016-01-23  1:42 Brian Dolbec
2016-01-23  1:42 Brian Dolbec
2016-01-23  1:42 Brian Dolbec
2016-01-22 20:55 Brian Dolbec
2016-01-22 20:55 Brian Dolbec
2016-01-22 20:55 Brian Dolbec
2016-01-21 19:42 Brian Dolbec
2016-01-21 19:42 Brian Dolbec
2016-01-21 19:15 Brian Dolbec
2016-01-21 18:30 Brian Dolbec
2016-01-21 18:30 Brian Dolbec
2016-01-18 19:23 Brian Dolbec
2016-01-18 19:23 Brian Dolbec
2016-01-11  8:01 Brian Dolbec
2016-01-11  8:01 Brian Dolbec
2016-01-11  6:31 Brian Dolbec
2016-01-11  6:31 Brian Dolbec
2016-01-11  6:31 Brian Dolbec
2016-01-10 20:17 Brian Dolbec
2016-01-10 20:17 Brian Dolbec
2016-01-10 20:17 Brian Dolbec
2016-01-10  3:26 Brian Dolbec
2016-01-10  3:26 Brian Dolbec
2016-01-10  3:26 Brian Dolbec
2016-01-06  4:21 Brian Dolbec
2016-01-06  4:21 Brian Dolbec
2015-12-30 23:38 Brian Dolbec
2015-09-21 23:51 [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 ` [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 ` [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 ` [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 ` [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 ` [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:47 Brian Dolbec
2015-09-21 23:47 Brian Dolbec
2015-09-21 23:47 Brian Dolbec
2015-09-21 23:47 Brian Dolbec
2015-09-21 23:47 Brian Dolbec
2015-09-21 23:47 Brian Dolbec
2015-09-21 23:47 Brian Dolbec
2015-09-21 23:47 Brian Dolbec
2015-09-21 23:47 Brian Dolbec
2015-09-21 23:47 Brian Dolbec
2015-09-21 23:47 Brian Dolbec
2015-09-21 23:47 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  2:06 Brian Dolbec
2015-09-20  0:20 Brian Dolbec
2015-09-19 17:32 Brian Dolbec
2015-09-19 16:48 Brian Dolbec
2015-09-19 16:28 Brian Dolbec
2015-09-19 16:28 Brian Dolbec
2015-09-19  4:36 Brian Dolbec
2015-09-19  4:36 Brian Dolbec
2015-09-19  4:36 Brian Dolbec
2015-09-19  4:36 Brian Dolbec
2015-09-19  4:36 Brian Dolbec
2015-09-19  4:36 Brian Dolbec
2015-09-19  4:36 Brian Dolbec
2015-09-19  4:36 Brian Dolbec
2015-09-19  4:36 Brian Dolbec
2015-09-19  4:36 Brian Dolbec
2015-09-19  1:22 Brian Dolbec
2015-09-19  1:22 Brian Dolbec
2015-09-17 18:58 Brian Dolbec
2015-09-17 18:58 Brian Dolbec
2015-09-17 15:32 Brian Dolbec
2015-09-17  4:51 Brian Dolbec
2015-09-17  4:51 Brian Dolbec
2015-09-17  4:51 Brian Dolbec
2015-09-17  4:51 Brian Dolbec
2015-09-17  4:51 Brian Dolbec
2015-09-17  4:51 Brian Dolbec
2015-09-17  4:51 Brian Dolbec
2015-09-17  4:51 Brian Dolbec
2015-09-17  4:51 Brian Dolbec
2015-09-17  3:08 Brian Dolbec
2015-09-17  3:08 Brian Dolbec
2015-09-17  3:08 Brian Dolbec
2015-09-17  3:08 Brian Dolbec
2015-09-17  3:08 Brian Dolbec
2015-09-17  3:08 Brian Dolbec
2015-09-17  3:08 Brian Dolbec
2015-09-17  3:08 Brian Dolbec
2015-09-17  3:08 Brian Dolbec
2015-09-17  2:45 Brian Dolbec
2015-09-17  2:45 Brian Dolbec
2015-09-17  2:45 Brian Dolbec
2015-09-05 21:48 Brian Dolbec
2015-09-05 21:48 Brian Dolbec
2015-09-05 21:48 Brian Dolbec
2015-09-05 21:48 Brian Dolbec
2015-09-05 21:48 Brian Dolbec
2015-09-05 21:48 Brian Dolbec
2015-09-05 21:27 Brian Dolbec
2015-09-05 21:27 Brian Dolbec
2015-09-05 21:27 Brian Dolbec
2015-09-05 21:27 Brian Dolbec
2015-09-05 21:27 Brian Dolbec
2015-09-05 21:27 Brian Dolbec
2015-08-11 23:54 Brian Dolbec
2015-08-11 23:54 Brian Dolbec
2015-08-11 23:54 Brian Dolbec
2015-08-11 23:54 Brian Dolbec
2015-08-11 23:54 Brian Dolbec
2015-08-11 23:54 Brian Dolbec
2015-08-10 14:45 Michał Górny
2015-08-10 14:45 Michał Górny
2015-08-10 14:45 Michał Górny
2015-08-10 14:45 Michał Górny
2015-08-10 14:45 Michał Górny
2015-08-10 14:45 Michał Górny
2015-08-10 13:44 Brian Dolbec
2015-08-10 13:44 Brian Dolbec
2015-08-10 13:44 Brian Dolbec
2015-08-10 13:44 Brian Dolbec
2015-08-10 13:44 Brian Dolbec
2015-08-10 13:44 Brian Dolbec
2014-11-17  2:08 Brian Dolbec
2014-11-17  0:55 Brian Dolbec
2014-11-17  0:55 Brian Dolbec
2014-11-17  0:55 Brian Dolbec
2014-11-17  0:55 Brian Dolbec
2014-11-17  0:55 Brian Dolbec
2014-10-01 23:46 Brian Dolbec
2014-10-01 23:46 Brian Dolbec
2014-10-01 23:46 Brian Dolbec
2014-10-01 23:46 Brian Dolbec
2014-10-01 23:46 Brian Dolbec
2014-10-01 23:02 Brian Dolbec
2014-10-01 23:02 Brian Dolbec
2014-10-01 23:02 Brian Dolbec
2014-10-01 23:02 Brian Dolbec
2014-10-01 23:02 Brian Dolbec
2014-06-03 19:33 Brian Dolbec
2014-06-03 18:15 Brian Dolbec
2014-06-03 11:29 Tom Wijsman
2014-06-02 17:01 Tom Wijsman
2014-06-02 15:44 Brian Dolbec
2014-06-02 15:44 Brian Dolbec
2014-06-02 15:44 Brian Dolbec
2014-06-02 15:01 Tom Wijsman
2014-06-02 14:24 Brian Dolbec
2014-06-02 14:11 Tom Wijsman
2014-06-02  1:10 Brian Dolbec
2014-06-02  1:10 Brian Dolbec
2014-05-30 13:03 Brian Dolbec
2014-05-30 13:03 Brian Dolbec
2014-05-30 13:03 Brian Dolbec
2014-05-27  6:04 Brian Dolbec
2014-05-27  6:04 Brian Dolbec
2014-05-27  6:04 Brian Dolbec
2014-05-27  6:04 Brian Dolbec
2014-05-27  5:04 Brian Dolbec
2014-05-27  5:04 Brian Dolbec
2014-05-27  5:04 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=1401818832.9a17984d163ea81df5cbf0b54eda6b9cbb38301a.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