aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec <dolsen@gentoo.org>2012-10-08 04:33:51 (GMT)
committerBrian Dolbec <dolsen@gentoo.org>2012-10-08 04:33:51 (GMT)
commitfc3cd9942ac71e118796d823fe3303a8c7cecdc2 (patch)
tree437df72934f5923699842c0ffc7cf7015024c649
parentAdd setting the default user name and email when adding new git based overlay... (diff)
downloadlayman-fc3cd9942ac71e118796d823fe3303a8c7cecdc2.zip
layman-fc3cd9942ac71e118796d823fe3303a8c7cecdc2.tar.gz
layman-fc3cd9942ac71e118796d823fe3303a8c7cecdc2.tar.bz2
An an automatic 'svn upgrade' capability for svn type repos. Bug 408039.
-rw-r--r--layman/overlays/svn.py39
1 files changed, 37 insertions, 2 deletions
diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index 3e5497c..9785025 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -18,14 +18,19 @@
__version__ = "$Id: svn.py 236 2006-09-05 20:39:37Z wrobel $"
+
+import os
+from subprocess import PIPE, Popen
+
#==============================================================================
#
# Dependencies
#
#------------------------------------------------------------------------------
-from layman.utils import path
-from layman.overlays.source import OverlaySource, require_supported
+from layman.utils import path
+from layman.overlays.source import (OverlaySource, require_supported,
+ _resolve_command)
#==============================================================================
#
@@ -86,6 +91,10 @@ class SvnOverlay(OverlaySource):
cfg_opts = self.config["svn_syncopts"]
self.target = checkout_location()
+ # first check if an svn upgrade is needed.
+ self.output.debug("SVN: check_upgrade() call", 4)
+ self.check_upgrade(path([base, self.parent.name]))
+
# svn up [-q] TARGET
args = ['up']
if self.config['quiet']:
@@ -114,3 +123,29 @@ class SvnOverlay(OverlaySource):
args.append(self.target)
cleanup = self.run_command(self.command(), args, cmd="svn cleanup")
return
+
+ def check_upgrade(self, target):
+ '''Code to check the installed svn version and
+ run "svn upgrade" if needed.'''
+ file_to_run = _resolve_command(self.command(), self.output.error)[1]
+ args = file_to_run + ' -q --version'
+ pipe = Popen(args, shell=True, stdout=PIPE)
+ if pipe:
+ self.output.debug("SVN: check_upgrade()... have a valid pipe", 4)
+ version = pipe.stdout.readline().strip('\n')
+ self.output.debug("SVN: check_upgrade()... svn version found: %s"
+ % version, 4)
+ pipe.terminate()
+ if version >= '1.7.0':
+ self.output.debug("SVN: check_upgrade()... svn upgrade maybe",
+ 4)
+ _path = path([target,'.svn/wc.db'])
+ if not os.path.exists(_path):
+ self.output.info("An svn upgrade needs to be run...",
+ 2)
+ args = ["upgrade"]
+ return self.run_command(self.command(), args,
+ cwd=target, cmd="svn upgrade")
+ return
+ else:
+ return