From 2e0c7def5895fea29177718abb690b75bc21695e Mon Sep 17 00:00:00 2001 From: Bogdano Arendartchuk Date: Wed, 2 May 2007 19:41:47 +0000 Subject: Added initial support to mirrors, as requested by mrl. It was added an option "mirror" to repsys.conf, that will contain an URL to the mirror repository. Also added the subcommand "ci", which will relocate one working copy to the master repository before effectively commiting. --- RepSys/mirror.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 RepSys/mirror.py (limited to 'RepSys/mirror.py') 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 -- cgit v1.2.1