def autoswitch(svn, wcpath, wcurl, newbaseurl=None): """Switches between mirror, default_parent, or newbaseurl""" nobase = False mirror = mirror_url() repository = layout.repository_url() current = repository if repository is None: raise Error, "the option repository from mgarepo.conf is "\ "required" indefault = same_base(repository, wcurl) if not newbaseurl: if not mirror: raise Error, "an URL is needed when the option mirror "\ "from mgarepo.conf is not set" if indefault: chosen = mirror elif same_base(mirror, wcurl): current = mirror chosen = repository else: nobase = True else: if mirror and same_base(mirror, wcurl): current = mirror elif indefault: pass # !!!! else: nobase = True chosen = newbaseurl if nobase: raise Error, "the URL of this working copy is not based in "\ "repository nor mirror URLs" assert current != chosen newurl = mirror_relocate(current, chosen, wcurl, wcpath) return newurl
def enabled(wcurl=None): mirror = mirror_url() repository = layout.repository_url() enabled = False if mirror and repository: enabled = True if wcurl and not same_base(mirror, wcurl): enabled = False return enabled
def switchto_mirror(svn, url, path): newurl = mirror_relocate(layout.repository_url(), mirror_url(), url, path) return newurl
def switchto_parent_url(url): newurl = relocate_path(mirror_url(), layout.repository_url(), url) return newurl
def switchto_parent(svn, url, path): """Relocates the working copy to default_parent""" newurl = mirror_relocate(mirror_url(), layout.repository_url(), url, path) return newurl