in maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/branch/SvnBranchCommand.java [56:128]
public ScmResult executeBranchCommand(
ScmProviderRepository repo, ScmFileSet fileSet, String branch, ScmBranchParameters scmBranchParameters)
throws ScmException {
if (branch == null || branch.trim().isEmpty()) {
throw new ScmException("branch name must be specified");
}
if (!fileSet.getFileList().isEmpty()) {
throw new ScmException("This provider doesn't support branching subsets of a directory");
}
SvnScmProviderRepository repository = (SvnScmProviderRepository) repo;
File messageFile = FileUtils.createTempFile("maven-scm-", ".commit", null);
try {
FileUtils.fileWrite(messageFile.getAbsolutePath(), "UTF-8", scmBranchParameters.getMessage());
} catch (IOException ex) {
return new BranchScmResult(
null,
"Error while making a temporary file for the commit message: " + ex.getMessage(),
null,
false);
}
Commandline cl = createCommandLine(repository, fileSet.getBasedir(), branch, messageFile, scmBranchParameters);
CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
if (logger.isInfoEnabled()) {
logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
}
int exitCode;
try {
exitCode = SvnCommandLineUtils.execute(cl, stdout, stderr);
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
} finally {
try {
FileUtils.forceDelete(messageFile);
} catch (IOException ex) {
// ignore
}
}
if (exitCode != 0) {
return new BranchScmResult(cl.toString(), "The svn branch command failed.", stderr.getOutput(), false);
}
List<ScmFile> fileList = new ArrayList<>();
List<File> files = null;
try {
files = FileUtils.getFiles(fileSet.getBasedir(), "**", "**/.svn/**", false);
} catch (IOException e) {
throw new ScmException("Error while executing command.", e);
}
for (File f : files) {
fileList.add(new ScmFile(f.getPath(), ScmFileStatus.TAGGED));
}
return new BranchScmResult(cl.toString(), fileList);
}