in maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/update/LocalUpdateCommand.java [50:121]
protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version)
throws ScmException {
LocalScmProviderRepository repository = (LocalScmProviderRepository) repo;
if (version != null) {
throw new ScmException("The local scm doesn't support tags.");
}
File root = new File(repository.getRoot());
String module = repository.getModule();
File source = new File(root, module);
File baseDestination = fileSet.getBasedir();
if (!baseDestination.exists()) {
throw new ScmException("The working directory doesn't exist (" + baseDestination.getAbsolutePath() + ").");
}
if (!root.exists()) {
throw new ScmException("The base directory doesn't exist (" + root.getAbsolutePath() + ").");
}
if (!source.exists()) {
throw new ScmException("The module directory doesn't exist (" + source.getAbsolutePath() + ").");
}
if (!baseDestination.exists() && !baseDestination.isDirectory()) {
throw new ScmException("The destination directory isn't a directory or doesn't exist ("
+ baseDestination.getAbsolutePath() + ").");
}
List<ScmFile> updatedFiles;
try {
if (logger.isInfoEnabled()) {
logger.info("Updating '" + baseDestination.getAbsolutePath() + "' from '" + source.getAbsolutePath()
+ "'.");
}
List<File> fileList = FileUtils.getFiles(source.getAbsoluteFile(), "**", null);
updatedFiles = update(source, baseDestination, fileList);
// process deletions in repository
LocalScmMetadataUtils metadataUtils = new LocalScmMetadataUtils();
LocalScmMetadata originalMetadata = metadataUtils.readMetadata(baseDestination);
if (originalMetadata != null) {
LocalScmMetadata newMetadata = metadataUtils.buildMetadata(source);
for (Iterator<String> it =
originalMetadata.getRepositoryFileNames().iterator();
it.hasNext(); ) {
String filename = it.next();
if (!newMetadata.getRepositoryFileNames().contains(filename)) {
File localFile = new File(baseDestination, filename);
if (localFile.exists()) {
localFile.delete();
updatedFiles.add(new ScmFile("/" + filename, ScmFileStatus.UPDATED));
}
}
}
}
// rewrite metadata file
metadataUtils.writeMetadata(baseDestination, metadataUtils.buildMetadata(source));
} catch (IOException ex) {
throw new ScmException("Error while checking out the files.", ex);
}
return new LocalUpdateScmResult(null, updatedFiles);
}