public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] svn sync: fix the module
@ 2015-01-17 17:35 Michał Górny
  2015-01-18  0:13 ` Zac Medico
  0 siblings, 1 reply; 4+ messages in thread
From: Michał Górny @ 2015-01-17 17:35 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Michał Górny

Fix the svn sync module since it doesn't work at all right now. More
specifically:

1. add exists() method that uses 'svn info' to determine whether
the repository was checked out already.

2. Fix the initial clone to use valid svn commands. Do not remove
the just-created directory to avoid permission issues, just run checkout
on top of it.

3. Fix the sync method to run update unconditionally to whether the URI
starts with svn:// or not. In fact, remove the whole check since it
doesn't serve any purpose.
---
 pym/portage/sync/modules/svn/svn.py | 54 ++++++++++++++++++++-----------------
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/pym/portage/sync/modules/svn/svn.py b/pym/portage/sync/modules/svn/svn.py
index 73c4b83..3ab15f5 100644
--- a/pym/portage/sync/modules/svn/svn.py
+++ b/pym/portage/sync/modules/svn/svn.py
@@ -24,23 +24,31 @@ class SVNSync(SyncBase):
 		SyncBase.__init__(self, "svn", "dev-vcs/subversion")
 
 
+	def exists(self, **kwargs):
+		'''Tests whether the repo actually exists'''
+		if kwargs:
+			self._kwargs(kwargs)
+		elif not self.repo:
+			return False
+
+		if not os.path.exists(self.repo.location):
+			return False
+		exitcode = portage.process.spawn_bash("cd %s ; svn info &>/dev/null" %\
+			(portage._shell_quote(self.repo.location),),
+			**portage._native_kwargs(self.spawn_kwargs))
+		if exitcode != 0:
+			return False
+		return True
+
+
 	def new(self, **kwargs):
 		if kwargs:
 			self._kwargs(kwargs)
 		#initial checkout
-		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)),
+		exitcode = portage.process.spawn_bash(
+			"cd %s; exec svn co %s ." %
+			(portage._shell_quote(self.repo.location),
 			portage._shell_quote(svn_root)),
 			**portage._native_kwargs(self.spawn_kwargs))
 		if exitcode != os.EX_OK:
@@ -63,19 +71,15 @@ class SVNSync(SyncBase):
 		if exitcode != os.EX_OK:
 			return (exitcode, False)
 
-		svn_root = self.repo.sync_uri
-
-		if svn_root.startswith("svn://"):
-			svn_root = svn_root[6:]
-			#svn update
-			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)
+		#svn update
+		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)
 
 
-- 
2.2.1



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

* Re: [gentoo-portage-dev] [PATCH] svn sync: fix the module
  2015-01-17 17:35 [gentoo-portage-dev] [PATCH] svn sync: fix the module Michał Górny
@ 2015-01-18  0:13 ` Zac Medico
  2015-01-18 10:35   ` [gentoo-portage-dev] [PATCH v2] " Michał Górny
  0 siblings, 1 reply; 4+ messages in thread
From: Zac Medico @ 2015-01-18  0:13 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Michał Górny

On 01/17/2015 09:35 AM, Michał Górny wrote:
> Fix the svn sync module since it doesn't work at all right now. More
> specifically:
> 
> 1. add exists() method that uses 'svn info' to determine whether
> the repository was checked out already.
> 
> 2. Fix the initial clone to use valid svn commands. Do not remove
> the just-created directory to avoid permission issues, just run checkout
> on top of it.

In case the reader is wondering, we could clarify that
SyncManager.pre_sync creates the directory and sets the permissions.

> 3. Fix the sync method to run update unconditionally to whether the URI
> starts with svn:// or not. In fact, remove the whole check since it
> doesn't serve any purpose.
> ---
>  pym/portage/sync/modules/svn/svn.py | 54 ++++++++++++++++++++-----------------
>  1 file changed, 29 insertions(+), 25 deletions(-)

LGTM.
-- 
Thanks,
Zac


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

* [gentoo-portage-dev] [PATCH v2] svn sync: fix the module
  2015-01-18  0:13 ` Zac Medico
@ 2015-01-18 10:35   ` Michał Górny
  2015-01-18 16:36     ` Brian Dolbec
  0 siblings, 1 reply; 4+ messages in thread
From: Michał Górny @ 2015-01-18 10:35 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Michał Górny

Fix the svn sync module since it doesn't work at all right now. More
specifically:

1. add exists() method that checks for the '.svn' directory to determine
whether the repository was checked out already.

2. Fix the initial clone to use valid svn commands. Do not remove
the just-created (in pre_sync()) directory to avoid permission issues,
just run checkout on top of it.

3. Fix the sync method to run update unconditionally to whether the URI
starts with svn:// or not. In fact, remove the whole check since it
doesn't serve any purpose.
---
 pym/portage/sync/modules/svn/svn.py | 42 +++++++++++++++----------------------
 1 file changed, 17 insertions(+), 25 deletions(-)

diff --git a/pym/portage/sync/modules/svn/svn.py b/pym/portage/sync/modules/svn/svn.py
index 73c4b83..60ead4b 100644
--- a/pym/portage/sync/modules/svn/svn.py
+++ b/pym/portage/sync/modules/svn/svn.py
@@ -24,23 +24,19 @@ class SVNSync(SyncBase):
 		SyncBase.__init__(self, "svn", "dev-vcs/subversion")
 
 
+	def exists(self, **kwargs):
+		'''Tests whether the repo actually exists'''
+		return os.path.exists(os.path.join(self.repo.location, '.svn'))
+
+
 	def new(self, **kwargs):
 		if kwargs:
 			self._kwargs(kwargs)
 		#initial checkout
-		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)),
+		exitcode = portage.process.spawn_bash(
+			"cd %s; exec svn co %s ." %
+			(portage._shell_quote(self.repo.location),
 			portage._shell_quote(svn_root)),
 			**portage._native_kwargs(self.spawn_kwargs))
 		if exitcode != os.EX_OK:
@@ -63,19 +59,15 @@ class SVNSync(SyncBase):
 		if exitcode != os.EX_OK:
 			return (exitcode, False)
 
-		svn_root = self.repo.sync_uri
-
-		if svn_root.startswith("svn://"):
-			svn_root = svn_root[6:]
-			#svn update
-			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)
+		#svn update
+		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)
 
 
-- 
2.2.1



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

* Re: [gentoo-portage-dev] [PATCH v2] svn sync: fix the module
  2015-01-18 10:35   ` [gentoo-portage-dev] [PATCH v2] " Michał Górny
@ 2015-01-18 16:36     ` Brian Dolbec
  0 siblings, 0 replies; 4+ messages in thread
From: Brian Dolbec @ 2015-01-18 16:36 UTC (permalink / raw
  To: gentoo-portage-dev

On Sun, 18 Jan 2015 11:35:18 +0100
Michał Górny <mgorny@gentoo.org> wrote:

> Fix the svn sync module since it doesn't work at all right now. More
> specifically:
> 
> 1. add exists() method that checks for the '.svn' directory to
> determine whether the repository was checked out already.
> 
> 2. Fix the initial clone to use valid svn commands. Do not remove
> the just-created (in pre_sync()) directory to avoid permission issues,
> just run checkout on top of it.
> 
> 3. Fix the sync method to run update unconditionally to whether the
> URI starts with svn:// or not. In fact, remove the whole check since
> it doesn't serve any purpose.
> ---
>  pym/portage/sync/modules/svn/svn.py | 42
> +++++++++++++++---------------------- 1 file changed, 17
> insertions(+), 25 deletions(-)
> 
>

Looks good, thank you for this update.

-- 
Brian Dolbec <dolsen>



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

end of thread, other threads:[~2015-01-18 16:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-17 17:35 [gentoo-portage-dev] [PATCH] svn sync: fix the module Michał Górny
2015-01-18  0:13 ` Zac Medico
2015-01-18 10:35   ` [gentoo-portage-dev] [PATCH v2] " Michał Górny
2015-01-18 16:36     ` Brian Dolbec

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