aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdano Arendartchuk <bogdano@mandriva.org>2007-04-25 20:41:53 +0000
committerBogdano Arendartchuk <bogdano@mandriva.org>2007-04-25 20:41:53 +0000
commit9ff10dd337e9de6e954b4125a17d89ec2b7cd8e9 (patch)
tree2ade2e1c6cc9791192a39eda2341161381f352c2
parent20cc82e177aee8c69478998847d52d183b39a99d (diff)
downloadmgarepo-9ff10dd337e9de6e954b4125a17d89ec2b7cd8e9.tar
mgarepo-9ff10dd337e9de6e954b4125a17d89ec2b7cd8e9.tar.gz
mgarepo-9ff10dd337e9de6e954b4125a17d89ec2b7cd8e9.tar.bz2
mgarepo-9ff10dd337e9de6e954b4125a17d89ec2b7cd8e9.tar.xz
mgarepo-9ff10dd337e9de6e954b4125a17d89ec2b7cd8e9.zip
Added support to "mirror repositories" for the subcommands co and ci.
Mirrors are intended to be used in read-only operations (such as co and rpmlog). For the moment the subcommand co will checkout the package source from the mirror, when it is defined. Also it was added the subcommand ci in order to allow relocating one package working copy to the write-enabled server before commiting, and then relocating back to the mirror when it is finished.
-rw-r--r--RepSys/rpmutil.py24
-rw-r--r--RepSys/svn.py19
-rwxr-xr-xrepsys1
-rw-r--r--repsys.conf1
4 files changed, 45 insertions, 0 deletions
diff --git a/RepSys/rpmutil.py b/RepSys/rpmutil.py
index 367fd45..12a8226 100644
--- a/RepSys/rpmutil.py
+++ b/RepSys/rpmutil.py
@@ -1,5 +1,6 @@
#!/usr/bin/python
from RepSys import Error, config, RepSysTree
+from RepSys import mirror
from RepSys.svn import SVN
from RepSys.rpm import SRPM
from RepSys.log import specfile_svn2rpm
@@ -357,8 +358,31 @@ def checkout(pkgdirurl, path=None, revision=None):
current = os.path.join(pkgdirurl, "current")
if path is None:
_, path = os.path.split(pkgdirurl)
+ if mirror.enabled():
+ current = mirror.checkout_url(current)
+ print "checking out from mirror", current
svn.checkout(current, path, rev=revision, show=1)
+def commit(target=".", message=None):
+ svn = SVN(noauth=True)
+ info = svn.info2(target)
+ url = info.get("URL")
+ if url is None:
+ raise Error, "working copy URL not provided by svn info"
+ if mirror.enabled():
+ newurl = mirror.switchto_parent(svn, url, target)
+ print "relocated to", newurl
+ try:
+ # we can't use the svn object here because pexpect hides VISUAL
+ mopt = ""
+ if message is not None:
+ mopt = "-m \"%s\"" % message
+ os.system("svn ci %s %s" % (mopt, target))
+ finally:
+ if mirror.enabled():
+ mirror.switchto_mirror(svn, newurl, target)
+ print "relocated back to", url
+
def get_submit_info(path):
path = os.path.abspath(path)
diff --git a/RepSys/svn.py b/RepSys/svn.py
index 4e073dc..a13db8b 100644
--- a/RepSys/svn.py
+++ b/RepSys/svn.py
@@ -169,6 +169,12 @@ class SVN:
if status == 0:
return output.splitlines()
return None
+
+ def info2(self, *args, **kwargs):
+ lines = self.info(*args, **kwargs)
+ pairs = [[w.strip() for w in line.split(":", 1)] for line in lines]
+ info = dict(pairs)
+ return info
def ls(self, path, **kwargs):
cmd = ["ls", path]
@@ -197,6 +203,19 @@ class SVN:
return [x.split() for x in output.split()]
return None
+ def switch(self, url, oldurl=None, path=None, relocate=False, **kwargs):
+ cmd = ["switch"]
+ if relocate:
+ if oldurl is None:
+ raise Error, "You must supply the old URL when "\
+ "relocating working copies"
+ cmd.append("--relocate")
+ cmd.append(oldurl)
+ cmd.append(url)
+ if path is not None:
+ cmd.append(path)
+ return self._execsvn_success(*cmd, **kwargs)
+
def update(self, path, **kwargs):
cmd = ["update", path]
self._add_revision(cmd, kwargs, optional=1)
diff --git a/repsys b/repsys
index 3ac7f81..4b864ef 100755
--- a/repsys
+++ b/repsys
@@ -11,6 +11,7 @@ Usage: repsys COMMAND [COMMAND ARGUMENTS]
Useful commands:
co
+ ci
submit
create
getspec
diff --git a/repsys.conf b/repsys.conf
index dce1fe3..87013b0 100644
--- a/repsys.conf
+++ b/repsys.conf
@@ -2,6 +2,7 @@
verbose = no
default_parent = svn+ssh://svn.mandriva.com/svn/packages/cooker
url-map = svn\+ssh://svn\.mandriva\.com/(.*) file:///\1
+#mirror = http://svn.mandriva.com/svn/packages/cooker/
#tempdir = /tmp
[log]