aboutsummaryrefslogtreecommitdiffstats
path: root/RepSys/mirror.py
diff options
context:
space:
mode:
authorBogdano Arendartchuk <bogdano@mandriva.org>2007-06-04 15:03:57 +0000
committerBogdano Arendartchuk <bogdano@mandriva.org>2007-06-04 15:03:57 +0000
commitb2ce8ef1c40f7c58f4bb4629b5b5e95ce8c252d2 (patch)
tree0d16405bf439725375a68146a342fa0f44f4b5fa /RepSys/mirror.py
parentf23797f8de1cdc3bb555fb4267ce9eec4c6f3968 (diff)
downloadmgarepo-b2ce8ef1c40f7c58f4bb4629b5b5e95ce8c252d2.tar
mgarepo-b2ce8ef1c40f7c58f4bb4629b5b5e95ce8c252d2.tar.gz
mgarepo-b2ce8ef1c40f7c58f4bb4629b5b5e95ce8c252d2.tar.bz2
mgarepo-b2ce8ef1c40f7c58f4bb4629b5b5e95ce8c252d2.tar.xz
mgarepo-b2ce8ef1c40f7c58f4bb4629b5b5e95ce8c252d2.zip
Frontported changes from V1_6_X since april
Diffstat (limited to 'RepSys/mirror.py')
-rw-r--r--RepSys/mirror.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/RepSys/mirror.py b/RepSys/mirror.py
new file mode 100644
index 0000000..a24f594
--- /dev/null
+++ b/RepSys/mirror.py
@@ -0,0 +1,42 @@
+import os
+import urlparse
+
+from RepSys import config
+from RepSys.svn import SVN
+
+def relocate_path(oldparent, newparent, url):
+ subpath = url[len(oldparent)-1:]
+ newurl = newparent + "/" + subpath # subpath usually gets / at begining
+ return newurl
+
+def enabled():
+ mirror = config.get("global", "mirror")
+ default_parent = config.get("global", "default_parent")
+ return (mirror is not None and
+ default_parent is not None)
+
+def mirror_relocate(oldparent, newparent, url, wcpath):
+ svn = SVN(noauth=True)
+ newurl = relocate_path(oldparent, newparent, url)
+ svn.switch(newurl, url, path=wcpath, relocate="True")
+ return newurl
+
+def switchto_parent(svn, url, path):
+ """Relocates the working copy to default_parent"""
+ mirror = config.get("global", "mirror")
+ default_parent = config.get("global", "default_parent")
+ newurl = mirror_relocate(mirror, default_parent, url, path)
+ return newurl
+
+def switchto_mirror(svn, url, path):
+ mirror = config.get("global", "mirror")
+ default_parent = config.get("global", "default_parent")
+ newurl = mirror_relocate(default_parent, mirror, url, path)
+ return newurl
+
+def checkout_url(url):
+ mirror = config.get("global", "mirror")
+ default_parent = config.get("global", "default_parent")
+ if mirror is not None and default_parent is not None:
+ return relocate_path(default_parent, mirror, url)
+ return url