SVNRelease release,
Branch branch,
String path,
long replacementRevisionNum,
long currentRevisionNum) throws SVNImporterException {
SVNVersionedFile toUpdate = fFiles.get(path);
/*
* Now I need to check whether the file I'm updating exists or not.
* In fact in an update there could be files and sub directories that don't exist
* in the directory that is being updated. In that case, I need to create them.
*/
if (toUpdate != null) {
// that file actually exists
SVNRevision revision = getClosestRevision(toCopy, replacementRevisionNum);
if (revision != null) {
((SVNRevision) toUpdate.getLatestRevision()).setAncestor(revision);
}
} else {
// That file does not exist yet
toUpdate = (SVNVersionedFile) createFile(path);
toUpdate.setCopiedFrom(toCopy);
toCopy.setCopiedTo(toUpdate);
SVNRevision revision = getClosestRevision(toCopy, replacementRevisionNum);
ModificationReport report = this.createModificationReport(date, message, author);
SVNRevision newRevision = new SVNRevision("" + currentRevisionNum);
// Usual SVNRevision initialization
changeSet.addRevision(newRevision); // Transaction -> SVNRevision
newRevision.setChangeSet(changeSet); // SVNRevision -> Transaction
newRevision.setAncestor(revision);
toUpdate.addRevision(newRevision); // File -> SVNRevision
newRevision.setFile(toUpdate); // SVNRevision -> File
newRevision.setReport(report); // SVNRevision -> ModificationReport
if (release != null) {
release.addReleaseRevision(newRevision); // Release -> SVNRevision
LOGGER.debug(NLS.bind(MapperMessages.SVNModelMapper_addedFileToRelease, new String[]{
toUpdate.getPath(),
toUpdate.getLatestRevision().getNumber(),
release.getName()}));
} else if (branch != null) {
branch.addRevision(newRevision); // Release -> SVNRevision
LOGGER.debug(NLS.bind(MapperMessages.SVNModelMapper_addedFileToBranch, new String[]{
toUpdate.getPath(),
toUpdate.getLatestRevision().getNumber(),
branch.getName()}));
} else {
throw new SVNImporterException(MapperMessages.SVNModelMapper_misuse);
}
}