public void addArgument( ScmFileSet f ) { info( "files: " + f.getBasedir().getAbsolutePath() ); Iterator<File> iter = f.getFileList().iterator(); while ( iter.hasNext() ) { command.createArg().setValue( ( (File) iter.next() ).getPath() ); } }
public InfoScmResult executeInfoCommand( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters, boolean recursive, String revision ) throws ScmException { SvnJavaScmProviderRepository javaRepo = (SvnJavaScmProviderRepository) repository; List<InfoItem> infoItems = new ArrayList<InfoItem>(); InfoScmResult svnInfoScmResult = new InfoScmResult( null, infoItems ); @SuppressWarnings( "rawtypes" ) Iterator i = fileSet.getFileList().iterator(); if ( i.hasNext() ) { while ( i.hasNext() ) { InfoItem currentItem = executeSingleInfoCommand( javaRepo, (File) ( i.next() ), revision ); infoItems.add( currentItem ); } } else { // no files just a base directory InfoItem currentItem = executeSingleInfoCommand( javaRepo, fileSet.getBasedir(), revision ); infoItems.add( currentItem ); } return svnInfoScmResult; }
File basedir = getAbsoluteFilePath( currentFileSet.getBasedir() ); List<File> files = currentFileSet.getFileList(); throw new ScmException( "Invalid file set.", e );
/** * {@inheritDoc} */ protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) throws ScmException { if ( getLogger().isInfoEnabled() ) { getLogger().info( "SVN status directory: " + fileSet.getBasedir().getAbsolutePath() ); } SvnJavaScmProviderRepository javaRepo = (SvnJavaScmProviderRepository) repo; SvnStatusHandler handler = new SvnStatusHandler( fileSet.getBasedir() ); try { SvnJavaUtil.status( javaRepo.getClientManager(), fileSet.getBasedir(), true, // isRecursive true, // isRemote handler ); return new StatusScmResult( SvnJavaScmProvider.COMMAND_LINE, handler.getFiles() ); } catch ( SVNException e ) { return new StatusScmResult( SvnJavaScmProvider.COMMAND_LINE, "SVN status failed.", e.getMessage(), false ); } } }
/** {@inheritDoc} */ protected ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag, ScmTagParameters scmTagParameters ) throws ScmException { if ( !fileSet.getFileList().isEmpty() ) { throw new ScmException( "This provider doesn't support tagging subsets of a directory" ); } if ( tag == null || tag.trim().length() == 0 ) { throw new ScmException( "tag must be specified" ); } if ( getLogger().isInfoEnabled() ) { getLogger().info( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); } StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo; StarteamTagConsumer consumer = new StarteamTagConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); Commandline cl = createCommandLine( repository, fileSet.getBasedir(), tag ); int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new TagScmResult( cl.toString(), "The starteam command failed.", stderr.getOutput(), false ); } return new TagScmResult( cl.toString(), consumer.getTaggedFiles() ); }
@Override protected ScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) throws ScmException, AccuRevException { ScmVersion scmVersion = parameters.getScmVersion( CommandParameter.SCM_VERSION, null ); File basedir = fileSet.getBasedir(); String outputDirectory = parameters.getString( CommandParameter.OUTPUT_DIRECTORY, null ); if ( outputDirectory != null ) { basedir = new File( outputDirectory ); } if ( !basedir.exists() ) { basedir.mkdirs(); } if ( !basedir.isDirectory() || basedir.list().length != 0 ) { throw new ScmException( "Checkout directory " + basedir.getAbsolutePath() + " not empty" ); } AccuRevVersion accuRevVersion = repository.getAccuRevVersion( scmVersion ); List<File> checkedOutFiles = extractSource( repository, basedir, accuRevVersion ); List<ScmFile> scmFiles = checkedOutFiles == null ? null : getScmFiles( checkedOutFiles, ScmFileStatus.CHECKED_OUT ); return getScmResult( repository, scmFiles, scmVersion ); }
public static Commandline createSpecificPushCommandLine(ScmLogger logger, GitScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version) throws ScmException { Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "push"); String branch = GitBranchCommand.getCurrentBranch(logger, repository, fileSet); if (branch == null || branch.length() == 0) { throw new ScmException("Could not detect the current branch. Don't know where I should push to!"); } // Overloaded branch name here : if repository.getUrl() is kept, during checkin(), current *local* branch // reference is not updated, whereas by using origin, it will be done ! cl.createArg().setValue("origin"); cl.createArg().setValue(branch + ":" + branch); return cl; }
public static Commandline createCommandLine( ScmFileSet scmFileSet ) { Commandline command = new Commandline(); File workingDirectory = scmFileSet.getBasedir(); command.setWorkingDirectory( workingDirectory.getAbsolutePath() ); command.setExecutable( "cleartool" ); command.createArg().setValue( "update" ); command.createArg().setValue( "-f" ); return command; } }
public void addArgument( ScmFileSet fileSet ) { logInfoMessage( "files: " + fileSet.getBasedir().getAbsolutePath() ); Iterator<File> iter = fileSet.getFileList().iterator(); while ( iter.hasNext() ) { fCommand.createArg().setValue( iter.next().getPath() ); } }
/** {@inheritDoc} */ protected ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag, ScmTagParameters scmTagParameters ) throws ScmException { if ( !fileSet.getFileList().isEmpty() ) { throw new ScmException( "This provider doesn't support tagging subsets of a directory" ); } if ( tag == null || tag.trim().length() == 0 ) { throw new ScmException( "tag must be specified" ); } if ( getLogger().isInfoEnabled() ) { getLogger().info( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); } StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo; StarteamTagConsumer consumer = new StarteamTagConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); Commandline cl = createCommandLine( repository, fileSet.getBasedir(), tag ); int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new TagScmResult( cl.toString(), "The starteam command failed.", stderr.getOutput(), false ); } return new TagScmResult( cl.toString(), consumer.getTaggedFiles() ); }
@Override protected ScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) throws ScmException, AccuRevException { ScmVersion scmVersion = parameters.getScmVersion( CommandParameter.SCM_VERSION, null ); File basedir = fileSet.getBasedir(); String outputDirectory = parameters.getString( CommandParameter.OUTPUT_DIRECTORY, null ); if ( outputDirectory != null ) { basedir = new File( outputDirectory ); } if ( !basedir.exists() ) { basedir.mkdirs(); } if ( !basedir.isDirectory() || basedir.list().length != 0 ) { throw new ScmException( "Checkout directory " + basedir.getAbsolutePath() + " not empty" ); } AccuRevVersion accuRevVersion = repository.getAccuRevVersion( scmVersion ); List<File> checkedOutFiles = extractSource( repository, basedir, accuRevVersion ); List<ScmFile> scmFiles = checkedOutFiles == null ? null : getScmFiles( checkedOutFiles, ScmFileStatus.CHECKED_OUT ); return getScmResult( repository, scmFiles, scmVersion ); }
public static Commandline createPushCommandLine( ScmLogger logger, GitScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version ) throws ScmException { Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( fileSet.getBasedir(), "push" ); String branch = GitBranchCommand.getCurrentBranch( logger, repository, fileSet ); if ( branch == null || branch.length() == 0 ) { throw new ScmException( "Could not detect the current branch. Don't know where I should push to!" ); } cl.createArg().setValue( repository.getPushUrl() ); cl.createArg().setValue( "refs/heads/" + branch + ":" + "refs/heads/" + branch ); return cl; }
@Override protected ScmResult executeRemoveCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message) throws ScmException { if (fileSet.getFileList().isEmpty()) { throw new ScmException("You must provide at least one file/directory to remove"); } Commandline cl = createCommandLine(fileSet.getBasedir(), fileSet.getFileList()); GitRemoveConsumer consumer = new GitRemoveConsumer(getLogger()); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; exitCode = GitCommandLineUtils.execute(cl, consumer, stderr, getLogger()); if (exitCode != 0) { return new RemoveScmResult(cl.toString(), "The git command failed.", stderr.getOutput(), false); } return new RemoveScmResult(cl.toString(), consumer.getRemovedFiles()); }
protected AddScmResult executeAddFileSet(ScmFileSet fileSet) throws ScmException { File workingDirectory = fileSet.getBasedir(); List<File> files = fileSet.getFileList(); // command line can be too long for windows so add files individually (see SCM-697) if (Os.isFamily(Os.FAMILY_WINDOWS)) { for (File file : files) { AddScmResult result = executeAddFiles(workingDirectory, Collections.singletonList(file)); if (result != null) { return result; } } } else { AddScmResult result = executeAddFiles(workingDirectory, files); if (result != null) { return result; } } return null; }
public static Commandline createCommandLine( ScmFileSet scmFileSet ) { Commandline command = new Commandline(); File workingDirectory = scmFileSet.getBasedir(); command.setWorkingDirectory( workingDirectory.getAbsolutePath() ); command.setExecutable( "cleartool" ); command.createArg().setValue( "update" ); command.createArg().setValue( "-f" ); return command; } }
public void addArgument( ScmFileSet fileSet ) { logInfoMessage( "files: " + fileSet.getBasedir().getAbsolutePath() ); Iterator<File> iter = fileSet.getFileList().iterator(); while ( iter.hasNext() ) { fCommand.createArg().setValue( iter.next().getPath() ); } }
/** {@inheritDoc} */ protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) throws ScmException { if ( getLogger().isInfoEnabled() ) { getLogger().info( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); } if ( fileSet.getFileList().size() != 0 ) { throw new ScmException( "This provider doesn't support checking status of a subsets of a directory" ); } StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo; StarteamStatusConsumer consumer = new StarteamStatusConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); Commandline cl = createCommandLine( repository, fileSet ); int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new StatusScmResult( cl.toString(), "The starteam command failed.", stderr.getOutput(), false ); } return new StatusScmResult( cl.toString(), consumer.getChangedFiles() ); }
throws ScmException Commandline cl = createCommandLine( fileSet.getBasedir(), startRevision, endRevision ); CvsDiffConsumer consumer = new CvsDiffConsumer( getLogger(), fileSet.getBasedir() ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); getLogger().debug( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); getLogger().debug( "Command line: " + cl ); throw new ScmException( "Error while executing command.", ex );
File workingDir = fileSet.getBasedir(); throw new ScmException( "Error while executing command " + cmd.toString() );
/** * {@inheritDoc} */ protected ScmResult executeRemoveCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message ) throws ScmException { if ( fileSet.getFileList().isEmpty() ) { throw new ScmException( "You must provide at least one file/directory to remove" ); } Commandline cl = createCommandLine( fileSet.getBasedir(), fileSet.getFileList() ); GitRemoveConsumer consumer = new GitRemoveConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; exitCode = GitCommandLineUtils.execute( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new RemoveScmResult( cl.toString(), "The git command failed.", stderr.getOutput(), false ); } return new RemoveScmResult( cl.toString(), consumer.getRemovedFiles() ); }