parentTag = tagPath.getCopyPath().substring(tagPath.getCopyPath().lastIndexOf("/") + 1);
}
// Create the ChangeSet related to the branch creation
Transaction changeSet = fModelMapper.createTransaction(logEntry.getDate());
// Here I don't check whether the logEntryPath points to a directory as It should already be done in isBranch.
Branch branch =
fModelMapper.createBranch(
logEntry.getDate(),
changeSet,
logEntry.getMessage(),
logEntry.getAuthor(),
tag,
parentTag,
tagPath.getPath(),
tagPath.getCopyPath(),
tagPath.getCopyRevision(),
logEntry.getRevision());
// I iterate over remaining log entry paths, as there might be some adds or deletes
sortedPaths.remove(tagPath.getPath());
ArrayList<SVNLogEntryPath> delete = new ArrayList<SVNLogEntryPath>();
TreeMap<String, SVNLogEntryPath> add = new TreeMap<String, SVNLogEntryPath>();
TreeMap<String, SVNLogEntryPath> replace = new TreeMap<String, SVNLogEntryPath>();
ArrayList<SVNLogEntryPath> alreadyAdded = new ArrayList<SVNLogEntryPath>();
for (SVNLogEntryPath logEntryPath : sortedPaths.values()) {
if (logEntryPath.getType() == SVNLogEntryPath.TYPE_DELETED) {
delete.add(logEntryPath);
} else if (logEntryPath.getType() == SVNLogEntryPath.TYPE_ADDED) {
add.put(logEntryPath.getPath().replace(tagPath.getPath(), ""), logEntryPath);
} else if (logEntryPath.getType() == SVNLogEntryPath.TYPE_REPLACED) {
replace.put(logEntryPath.getPath().replace(tagPath.getPath(), ""), logEntryPath);
}
}
for (SVNLogEntryPath replaceEntry : replace.values()) {
for (SVNLogEntryPath addEntry : add.values()) {
if (replaceEntry.getPath().contains(addEntry.getPath())) {
if (!alreadyAdded.contains(addEntry)) {
alreadyAdded.add(addEntry);
addToBranch(addEntry, logEntry, branch, changeSet);
}
}
}
// do the replace
fModelMapper.replaceInBranch(
branch,
changeSet,
logEntry.getDate(),
logEntry.getMessage(),
logEntry.getAuthor(),
replaceEntry.getPath(),
replaceEntry.getCopyPath(),
replaceEntry.getCopyRevision(),
logEntry.getRevision());
}
for (SVNLogEntryPath addEntry : add.values()) {
if (!alreadyAdded.contains(addEntry)) {
addToBranch(addEntry, logEntry, branch, changeSet);
}
}
// At last I take care of deletes, after I did all the replacement and additions in the current log
for (SVNLogEntryPath deletedEntry : delete) {
LOGGER.debug(NLS.bind(ImporterMessages.EvolizerSVNImporter_deleteFromBranch, deletedEntry.getPath(), branch
.getName()));
fModelMapper.removeFromBranch(branch, deletedEntry.getPath());
}
ArrayList<String> toDelete = new ArrayList<String>();
for (SVNLogEntryPath deleteEntry : delete) {
toDelete.add(deleteEntry.getPath());
}
fModelMapper.finalizeTransaction(changeSet, toDelete);
LOGGER.debug(NLS.bind(ImporterMessages.EvolizerSVNImporter_createdBranch, branch.getName()));
}