myTmpFiles = tmpFiles;
myRepositoryRoot = reposRoot;
}
public boolean handleCommitPath(String commitPath, ISVNEditor commitEditor) throws SVNException {
SVNCommitItem item = (SVNCommitItem) myCommitItems.get(commitPath);
SVNWCAccess wcAccess = item.getWCAccess();
wcAccess.checkCancelled();
if (item.isCopied()) {
if (item.getCopyFromURL() == null) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.BAD_URL, "Commit item ''{0}'' has copy flag but no copyfrom URL", item.getFile());
SVNErrorManager.error(err, SVNLogType.WC);
} else if (item.getRevision().getNumber() < 0) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_BAD_REVISION, "Commit item ''{0}'' has copy flag but an invalid revision", item.getFile());
SVNErrorManager.error(err, SVNLogType.WC);
}
}
SVNEvent event = null;
boolean closeDir = false;
File file = null;
if (item.getFile() != null) {
file = item.getFile();
} else if (item.getPath() != null) {
file = new File(wcAccess.getAnchor(), item.getPath());
}
long rev = item.getRevision().getNumber();
if (item.isAdded() && item.isDeleted()) {
event = SVNEventFactory.createSVNEvent(file, item.getKind(), null, SVNRepository.INVALID_REVISION, SVNEventAction.COMMIT_REPLACED, null, null, null);
event.setPreviousRevision(rev);
} else if (item.isAdded()) {
String mimeType = null;
if (item.getKind() == SVNNodeKind.FILE && file != null) {
SVNAdminArea dir = item.getWCAccess().retrieve(file.getParentFile());
mimeType = dir.getProperties(file.getName()).getStringPropertyValue(SVNProperty.MIME_TYPE);
}
event = SVNEventFactory.createSVNEvent(file, item.getKind(), mimeType, SVNRepository.INVALID_REVISION, SVNEventAction.COMMIT_ADDED, null, null, null);
event.setPreviousRevision(item.getCopyFromRevision() != null ? item.getCopyFromRevision().getNumber() : -1);
event.setPreviousURL(item.getCopyFromURL());
} else if (item.isDeleted()) {
event = SVNEventFactory.createSVNEvent(file, item.getKind(), null, SVNRepository.INVALID_REVISION, SVNEventAction.COMMIT_DELETED, null, null, null);
event.setPreviousRevision(rev);
} else if (item.isContentsModified() || item.isPropertiesModified()) {
event = SVNEventFactory.createSVNEvent(file, item.getKind(), null, SVNRepository.INVALID_REVISION, SVNEventAction.COMMIT_MODIFIED, null, null, null);
event.setPreviousRevision(rev);
}
if (event != null) {
event.setURL(item.getURL());
wcAccess.handleEvent(event, ISVNEventHandler.UNKNOWN);
}
long cfRev = item.getCopyFromRevision().getNumber();//item.getCopyFromURL() != null ? rev : -1;
if (item.isDeleted()) {
commitEditor.deleteEntry(commitPath, rev);
}
boolean fileOpen = false;
Map outgoingProperties = item.getOutgoingProperties();
if (item.isAdded()) {
String copyFromPath = getCopyFromPath(item.getCopyFromURL());
if (item.getKind() == SVNNodeKind.FILE) {
commitEditor.addFile(commitPath, copyFromPath, cfRev);
fileOpen = true;
} else {
commitEditor.addDir(commitPath, copyFromPath, cfRev);
closeDir = true;
}
if (outgoingProperties != null) {
for (Iterator propsIter = outgoingProperties.keySet().iterator(); propsIter.hasNext();) {
String propName = (String) propsIter.next();
SVNPropertyValue propValue = (SVNPropertyValue) outgoingProperties.get(propName);
if (item.getKind() == SVNNodeKind.FILE) {
commitEditor.changeFileProperty(commitPath, propName, propValue);
} else {
commitEditor.changeDirProperty(propName, propValue);
}
}
outgoingProperties = null;
}
}
if (item.isPropertiesModified()) {
if (item.getKind() == SVNNodeKind.FILE) {
if (!fileOpen) {
commitEditor.openFile(commitPath, rev);
}
fileOpen = true;
} else if (!item.isAdded()) {
// do not open dir twice.
if ("".equals(commitPath)) {
commitEditor.openRoot(rev);
} else {
commitEditor.openDir(commitPath, rev);
}
closeDir = true;
}
sendPropertiesDelta(commitPath, item, commitEditor);
if (outgoingProperties != null) {
for (Iterator propsIter = outgoingProperties.keySet().iterator(); propsIter.hasNext();) {
String propName = (String) propsIter.next();
SVNPropertyValue propValue = (SVNPropertyValue) outgoingProperties.get(propName);
if (item.getKind() == SVNNodeKind.FILE) {
commitEditor.changeFileProperty(commitPath, propName, propValue);
} else {
commitEditor.changeDirProperty(propName, propValue);
}
}
}
}
if (item.isContentsModified() && item.getKind() == SVNNodeKind.FILE) {
if (!fileOpen) {
commitEditor.openFile(commitPath, rev);
}
myModifiedFiles.put(commitPath, item);
} else if (fileOpen) {