source: soft/build_system/build_system/repsys/tags/V1_6_17_1/RepSys/mirror.py @ 1

Last change on this file since 1 was 1, checked in by fasma, 12 years ago

Initial Import from Mandriva's soft revision 224062 and package revision 45733

File size: 1.4 KB
Line 
1import os
2import urlparse
3
4from RepSys import config
5from RepSys.svn import SVN
6
7def relocate_path(oldparent, newparent, url):
8    subpath = url[len(oldparent)-1:]
9    newurl = newparent + "/" + subpath # subpath usually gets / at begining
10    return newurl
11
12def enabled():
13    mirror = config.get("global", "mirror")
14    default_parent = config.get("global", "default_parent")
15    return (mirror is not None and 
16            default_parent is not None)
17
18def mirror_relocate(oldparent, newparent, url, wcpath):
19    svn = SVN(noauth=True)
20    newurl = relocate_path(oldparent, newparent, url)
21    svn.switch(newurl, url, path=wcpath, relocate="True")
22    return newurl
23
24def switchto_parent(svn, url, path):
25    """Relocates the working copy to default_parent"""
26    mirror = config.get("global", "mirror")
27    default_parent = config.get("global", "default_parent")
28    newurl = mirror_relocate(mirror, default_parent, url, path)
29    return newurl
30
31def switchto_mirror(svn, url, path):
32    mirror = config.get("global", "mirror")
33    default_parent = config.get("global", "default_parent")
34    newurl = mirror_relocate(default_parent, mirror, url, path)
35    return newurl
36
37def checkout_url(url):
38    mirror = config.get("global", "mirror")
39    default_parent = config.get("global", "default_parent")
40    if mirror is not None and default_parent is not None:
41        return relocate_path(default_parent, mirror, url)
42    return url
Note: See TracBrowser for help on using the repository browser.