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 Kotalfrom ..utils.command import Command 29*2d57dc69SVladimir Kotal 30*2d57dc69SVladimir Kotal 31*2d57dc69SVladimir Kotalclass CVSRepository(Repository): 32*2d57dc69SVladimir Kotal def __init__(self, logger, path, project, command, env, hooks, timeout): 33*2d57dc69SVladimir Kotal super().__init__(logger, path, project, command, env, hooks, timeout) 34*2d57dc69SVladimir Kotal 35*2d57dc69SVladimir Kotal self.command = self._repository_command(command, default=lambda: which('cvs')) 36*2d57dc69SVladimir Kotal 37*2d57dc69SVladimir Kotal if not self.command: 38*2d57dc69SVladimir Kotal raise RepositoryException("Cannot get cvs command") 39*2d57dc69SVladimir Kotal 40*2d57dc69SVladimir Kotal def reposync(self): 41*2d57dc69SVladimir Kotal hg_command = [self.command, "update", "-dP"] 42*2d57dc69SVladimir Kotal cmd = self.getCommand(hg_command, work_dir=self.path, 43*2d57dc69SVladimir Kotal env_vars=self.env, logger=self.logger) 44*2d57dc69SVladimir Kotal cmd.execute() 45*2d57dc69SVladimir Kotal self.logger.info("output of {}:".format(cmd)) 46*2d57dc69SVladimir Kotal self.logger.info(cmd.getoutputstr()) 47*2d57dc69SVladimir Kotal if cmd.getretcode() != 0 or cmd.getstate() != Command.FINISHED: 48*2d57dc69SVladimir Kotal self.logger.error("failed to perform update: command {}" 49*2d57dc69SVladimir Kotal "in directory {} exited with {}". 50*2d57dc69SVladimir Kotal format(hg_command, self.path, cmd.getretcode())) 51*2d57dc69SVladimir Kotal return 1 52*2d57dc69SVladimir Kotal 53*2d57dc69SVladimir Kotal return 0 54