1*2d57dc69SVladimir Kotal# 2*2d57dc69SVladimir Kotal# CDDL HEADER START 3*2d57dc69SVladimir Kotal# 4*2d57dc69SVladimir Kotal# The contents of this file are subject to the terms of the 5*2d57dc69SVladimir Kotal# Common Development and Distribution License (the "License"). 6*2d57dc69SVladimir Kotal# You may not use this file except in compliance with the License. 7*2d57dc69SVladimir Kotal# 8*2d57dc69SVladimir Kotal# See LICENSE.txt included in this distribution for the specific 9*2d57dc69SVladimir Kotal# language governing permissions and limitations under the License. 10*2d57dc69SVladimir Kotal# 11*2d57dc69SVladimir Kotal# When distributing Covered Code, include this CDDL HEADER in each 12*2d57dc69SVladimir Kotal# file and include the License file at LICENSE.txt. 13*2d57dc69SVladimir Kotal# If applicable, add the following below this CDDL HEADER, with the 14*2d57dc69SVladimir Kotal# fields enclosed by brackets "[]" replaced with your own identifying 15*2d57dc69SVladimir Kotal# information: Portions Copyright [yyyy] [name of copyright owner] 16*2d57dc69SVladimir Kotal# 17*2d57dc69SVladimir Kotal# CDDL HEADER END 18*2d57dc69SVladimir Kotal# 19*2d57dc69SVladimir Kotal 20*2d57dc69SVladimir Kotal# 21*2d57dc69SVladimir Kotal# Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. 22*2d57dc69SVladimir Kotal# Portions Copyright (c) 2020, Krystof Tulinger <k.tulinger@seznam.cz> 23*2d57dc69SVladimir Kotal# 24*2d57dc69SVladimir Kotal 25*2d57dc69SVladimir Kotalfrom shutil import which 26*2d57dc69SVladimir Kotal 27*2d57dc69SVladimir Kotalfrom .repository import Repository, RepositoryException 28*2d57dc69SVladimir Kotal 29*2d57dc69SVladimir Kotal 30*2d57dc69SVladimir Kotalclass SubversionRepository(Repository): 31*2d57dc69SVladimir Kotal def __init__(self, logger, path, project, command, env, hooks, timeout): 32*2d57dc69SVladimir Kotal super().__init__(logger, path, project, command, env, hooks, timeout) 33*2d57dc69SVladimir Kotal 34*2d57dc69SVladimir Kotal self.command = self._repository_command(command, default=lambda: which('svn')) 35*2d57dc69SVladimir Kotal 36*2d57dc69SVladimir Kotal if not self.command: 37*2d57dc69SVladimir Kotal raise RepositoryException("Cannot get svn command") 38*2d57dc69SVladimir Kotal 39*2d57dc69SVladimir Kotal def reposync(self): 40*2d57dc69SVladimir Kotal svn_command = [self.command] 41*2d57dc69SVladimir Kotal 42*2d57dc69SVladimir Kotal # 43*2d57dc69SVladimir Kotal # The proxy configuration in SVN does not heed environment variables so 44*2d57dc69SVladimir Kotal # they need to be converted to the options. 45*2d57dc69SVladimir Kotal # 46*2d57dc69SVladimir Kotal http_proxy = self.env.get('http_proxy') 47*2d57dc69SVladimir Kotal if http_proxy: 48*2d57dc69SVladimir Kotal data = http_proxy.split(':') 49*2d57dc69SVladimir Kotal if len(data) != 2: 50*2d57dc69SVladimir Kotal self.logger.error("Cannot split '{}' into two strings by ':'". 51*2d57dc69SVladimir Kotal format(http_proxy)) 52*2d57dc69SVladimir Kotal return 1 53*2d57dc69SVladimir Kotal 54*2d57dc69SVladimir Kotal svn_command.append("--config-option") 55*2d57dc69SVladimir Kotal svn_command.append("servers:global:http-proxy-host=" + data[0]) 56*2d57dc69SVladimir Kotal svn_command.append("--config-option") 57*2d57dc69SVladimir Kotal svn_command.append("servers:global:http-proxy-port=" + data[1]) 58*2d57dc69SVladimir Kotal 59*2d57dc69SVladimir Kotal no_proxy = self.env.get('no_proxy') 60*2d57dc69SVladimir Kotal if no_proxy: 61*2d57dc69SVladimir Kotal svn_command.append("--config-option") 62*2d57dc69SVladimir Kotal svn_command.append("servers:global:http-proxy-exceptions=" + 63*2d57dc69SVladimir Kotal no_proxy) 64*2d57dc69SVladimir Kotal 65*2d57dc69SVladimir Kotal svn_command.append("update") 66*2d57dc69SVladimir Kotal return self._run_custom_sync_command(svn_command) 67