From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 748B71387FF for ; Tue, 21 Oct 2014 05:05:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 16C6BE08A0; Tue, 21 Oct 2014 05:05:14 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id F1625E087A for ; Tue, 21 Oct 2014 05:05:12 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id EA74334049B for ; Tue, 21 Oct 2014 05:05:10 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E408F8612 for ; Tue, 21 Oct 2014 05:05:07 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1413867847.a56ee8b456ea059f92e5e4fd142cde85be249a23.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/svn/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/sync/modules/svn/__init__.py pym/portage/sync/modules/svn/svn.py X-VCS-Directories: pym/portage/sync/modules/svn/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: a56ee8b456ea059f92e5e4fd142cde85be249a23 X-VCS-Branch: plugin-sync Date: Tue, 21 Oct 2014 05:05:07 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 0aac8c63-9f80-43ef-96a2-fe17f087074f X-Archives-Hash: 6189ea0f5535a5bdc5fdd0f42f80178f commit: a56ee8b456ea059f92e5e4fd142cde85be249a23 Author: David Heidelberger ixit cz> AuthorDate: Mon Jun 16 16:04:06 2014 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue Oct 21 05:04:07 2014 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a56ee8b4 portage/sync/modules: Add svn sync module Module submitted by: David Heidelberger edits by Brian Dolbec : Remove CheckSVNConfig class. Use the default CheckSyncConfig class instead. Copying the sync-cvs-repo option from the cvs module was incorrect and not needed. Fixed the new()'s spawn_bash(...) call. --- pym/portage/sync/modules/svn/__init__.py | 32 +++++++++++++ pym/portage/sync/modules/svn/svn.py | 81 ++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) diff --git a/pym/portage/sync/modules/svn/__init__.py b/pym/portage/sync/modules/svn/__init__.py new file mode 100644 index 0000000..1fda55a --- /dev/null +++ b/pym/portage/sync/modules/svn/__init__.py @@ -0,0 +1,32 @@ +# Copyright 2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +"""SVN plug-in module for portage. +Performs a svn up on repositories +""" + + +from portage.localization import _ +from portage.sync.config_checks import CheckSyncConfig +from portage.util import writemsg_level + + +module_spec = { + 'name': 'svn', + 'description': __doc__, + 'provides':{ + 'svn-module': { + 'name': "svn", + 'class': "SVNSync", + 'description': __doc__, + 'functions': ['sync', 'new', 'exists'], + 'func_desc': { + 'sync': 'Performs a svn up on the repository', + 'new': 'Creates the new repository at the specified location', + 'exists': 'Returns a boolean of whether the specified dir ' + + 'exists and is a valid SVN repository', + }, + 'validate_config': CheckSyncConfig, + } + } +} diff --git a/pym/portage/sync/modules/svn/svn.py b/pym/portage/sync/modules/svn/svn.py new file mode 100644 index 0000000..182a7ac --- /dev/null +++ b/pym/portage/sync/modules/svn/svn.py @@ -0,0 +1,81 @@ +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +import logging +import errno + +import portage +from portage import os +from portage.util import writemsg_level +from portage.sync.syncbase import SyncBase + + +class SVNSync(SyncBase): + '''SVN sync module''' + + short_desc = "Perform sync operations on SVN repositories" + + @staticmethod + def name(): + return "SVNSync" + + + def __init__(self): + SyncBase.__init__(self, "svn", "dev-vcs/subversion") + + + def new(self, **kwargs): + if kwargs: + self._kwargs(kwargs) + #initial checkout + msg = ">>> Starting initial svn checkout with %s..." % self.repo.sync_uri + self.logger(self.xterm_titles, msg) + writemsg_level(msg + "\n") + try: + os.rmdir(self.repo.location) + except OSError as e: + if e.errno != errno.ENOENT: + msg = "!!! existing '%s' directory; exiting." % self.repo.location + self.logger(self.xterm_titles, msg) + writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR) + return (1, False) + del e + svn_root = self.repo.sync_uri + exitcode = portage.process.spawn_bash( + "cd %s; exec svn %s" % + (portage._shell_quote(os.path.dirname(self.repo.location)), + portage._shell_quote(svn_root)), + **portage._native_kwargs(self.spawn_kwargs)) + if exitcode != os.EX_OK: + msg = "!!! svn checkout error; exiting." + self.logger(self.xterm_titles, msg) + writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR) + return (exitcode, False) + + + def _sync(self): + """ + Internal function to sync an existing SVN repository + + @return: tuple of return code (0=success), whether the cache + needs to be updated + @rtype: (int, bool) + """ + + svn_root = self.repo.sync_uri + + if svn_root.startswith("svn://"): + svn_root = svn_root[6:] + #svn update + msg = ">>> Starting svn update with %s..." % self.repo.sync_uri + self.logger(self.xterm_titles, msg) + writemsg_level(msg + "\n") + exitcode = portage.process.spawn_bash( + "cd %s; exec svn update" % \ + (portage._shell_quote(self.repo.location),), + **portage._native_kwargs(self.spawn_kwargs)) + if exitcode != os.EX_OK: + msg = "!!! svn update error; exiting." + self.logger(self.xterm_titles, msg) + writemsg_level(msg + "\n", noiselevel=-1, level=logging.ERROR) + return (exitcode, False)