def remote( self, url ): if url.startswith( 'svn+ssh://' ): return SVN.SVNRepository( url ) elif url.startswith( 'https://' ) or url.endswith( '.git' ): return Git.RemoteGitRepository( url ) else: raise EnvironmentError( 'Unexpected revision control URL' )
def runCommon(self, templateName, verbatim, templatize): import subprocess from ToolBOSCore.Platforms.Platforms import getHostPlatform from ToolBOSCore.Tools import SVN Any.requireIsTextNonEmpty(templateName) Any.requireIsSet(verbatim) Any.requireIsDict(templatize) hostPlatform = getHostPlatform() if not 'buildDir' in self.values: self.values['buildDir'] = os.path.join('build', hostPlatform) if not 'MAKEFILE_PLATFORM' in self.values: self.values['MAKEFILE_PLATFORM'] = hostPlatform srcDir = os.path.join(self.templateDir, templateName) dstDir = self.outputDir for item in verbatim: srcFile = os.path.join(srcDir, item) dstFile = os.path.join(dstDir, item) self.copyVerbatim(srcFile, dstFile) for key, value in templatize.items(): srcFile = os.path.join(srcDir, key) dstFile = os.path.join(dstDir, value) self.templatize(srcFile, dstFile) # enable VCS integration if SVN information found try: wc = SVN.WorkingCopy() url = wc.getRepositoryURL() except subprocess.CalledProcessError as details: # most likely is no working copy --> ignore url = None logging.debug(details) srcFile = os.path.join(srcDir, 'misc.xml.mako') dstFile = os.path.join(dstDir, 'misc.xml') if url: logging.info('VCS integration enabled') self.values['repositoryUrl'] = url else: self.values['repositoryUrl'] = '' logging.info('VCS integration disabled (not an SVN working copy)') self.templatize(srcFile, dstFile)
def local( self ): rcsInfoDir = self._detectInfoDir( os.getcwd() ) if rcsInfoDir is None: raise EnvironmentError( 'No revision control system information found' ) elif rcsInfoDir.endswith( '.svn' ): logging.debug( 'found SVN info in %s', rcsInfoDir ) return SVN.WorkingCopy() elif rcsInfoDir.endswith( '.git' ): logging.debug( 'found Git info in %s', rcsInfoDir ) return Git.LocalGitRepository() else: raise EnvironmentError( 'No revision control system information found' )
def _retrieveSVNInfo(self): from ToolBOSCore.Tools import SVN try: wc = SVN.WorkingCopy() self.svnRevision = wc.getRevision() self.svnRepositoryURL = wc.getRepositoryURL() self.svnRepositoryRoot = wc.getRepositoryRoot() self.svnRelPath = os.path.relpath(self.svnRepositoryURL, self.svnRepositoryRoot) self.svnFound = True except (subprocess.CalledProcessError, OSError): logging.debug('this is not an SVN working copy') self.svnRevision = -1 self.svnRepositoryURL = '' self.svnRepositoryRoot = '' self.svnFound = False
def __init__(self, url): Any.requireIsTextNonEmpty(url) self._svnRepo = SVN.SVNRepository(url) super(GitSVNBridge, self).__init__()
except (AssertionError, IOError): logging.error('') logging.error('unable to detect last globally installed revision') logging.error('falling back to HEAD revision') logging.error('') projectName = ProjectProperties.splitPath(package)[1] Any.requireIsTextNonEmpty(projectName) # create directory with name of package when downloading a particular version, # and cd into it if not fetchAll: FastScript.mkdir(projectName) FastScript.changeDirectory(projectName) repo = SVN.SVNRepository(url) repo.checkIsOnMasterServer() try: if userName: repo.setUserName(userName) else: repo.setConfiguredUserName() repo.checkout(revision) if os.path.exists(projectName): logging.debug('chmod 0700 %s', projectName) os.chmod(projectName, 0o700) except OSError as details:
logging.info('category: %s' % category) logging.info('package name: %s' % packageName) logging.info('repository: %s' % repositoryURL) # prevent importing an existing working copy (by looking for ".svn" # directories) for root, dirs, files in os.walk(cwd): for entry in dirs: if entry == '.svn': path = os.path.join(root, entry) msg = 'Found directory "%s"! You can\'t import an ' \ 'existing working copy!' % path FastScript.prettyPrintError(msg) repo = SVN.SVNRepository(repositoryURL) # check if repository exists (we won't overwrite!) try: if repo.exists(): msg = "CANCELLED! Repository exists!" FastScript.prettyPrintError(msg) except ValueError as details: if str(details).find('Permission denied') != -1: msg = "CANCELLED! Repository exists! (but permission denied)" FastScript.prettyPrintError(msg) # create new repository repo.create()