boolean propConflicts;
boolean textConflicts = false;
boolean treeConflicts = dir.hasTreeConflict(entry.getName());
SVNAdminArea entries = null;
if (entry.getKind() == SVNNodeKind.DIR) {
SVNAdminArea childDir = null;
try {
childDir = dir.getWCAccess().retrieve(dir.getFile(entry.getName()));
} catch (SVNException e) {
if (e.getErrorMessage().getErrorCode() == SVNErrorCode.WC_NOT_LOCKED) {
childDir = null;
} else {
throw e;
}
}
if (childDir != null && childDir.entries(true) != null) {
entries = childDir;
if (entries.getEntry("", false) != null) {
entry = entries.getEntry("", false);
dir = childDir;
}
}
propConflicts = dir.hasPropConflict(entry.getName());
Map tcs = entry.getTreeConflicts();
for (Iterator keys = tcs.keySet().iterator(); keys.hasNext();) {
File entryPath = (File) keys.next();
SVNTreeConflictDescription tc = (SVNTreeConflictDescription) tcs.get(entryPath);
if (tc.getNodeKind() == SVNNodeKind.DIR && depth == SVNDepth.FILES) {
continue;
}
SVNEntry conflictingEntry = null;
if (tc.getNodeKind() == SVNNodeKind.DIR) {
// get dir admin area and root entry
SVNAdminArea childConflictingDir = dir.getWCAccess().getAdminArea(entryPath);
if (childConflictingDir != null) {
conflictingEntry = childConflictingDir.getEntry("", true);
}
conflictingEntry = childDir.getEntry(entryPath.getName(), true);
} else {
conflictingEntry = dir.getEntry(entryPath.getName(), true);
}
if (changelists == null || changelists.isEmpty() ||
(conflictingEntry != null && SVNWCAccess.matchesChangeList(changelists, conflictingEntry))) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_FOUND_CONFLICT,
"Aborting commit: ''{0}'' remains in conflict", path);
SVNErrorManager.error(err, SVNLogType.WC);
}
}
} else {
propConflicts = dir.hasPropConflict(entry.getName());
textConflicts = dir.hasTextConflict(entry.getName());
}
if (propConflicts || textConflicts || treeConflicts) {
if (SVNWCAccess.matchesChangeList(changelists, entry)) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_FOUND_CONFLICT,
"Aborting commit: ''{0}'' remains in conflict", path);
SVNErrorManager.error(err, SVNLogType.WC);
}
}
if (entry.getURL() != null && !copyMode) {
url = entry.getURL();
}
boolean commitDeletion = !addsOnly
&& ((entry.isDeleted() && entry.getSchedule() == null) || entry.isScheduledForDeletion() || entry.isScheduledForReplacement());
if (!addsOnly && !commitDeletion && fileType == SVNFileType.NONE && params != null) {
ISVNCommitParameters.Action action =
entry.getKind() == SVNNodeKind.DIR ? params.onMissingDirectory(path) : params.onMissingFile(path);
if (action == ISVNCommitParameters.ERROR) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_NOT_LOCKED, "Working copy file ''{0}'' is missing", path);
SVNErrorManager.error(err, SVNLogType.WC);
} else if (action == ISVNCommitParameters.DELETE) {
commitDeletion = true;
entry.scheduleForDeletion();
dir.saveEntries(false);
}
}
boolean commitAddition = false;
boolean commitCopy = false;
if (entry.isScheduledForAddition() || entry.isScheduledForReplacement()) {
commitAddition = true;
if (entry.getCopyFromURL() != null) {
cfURL = entry.getCopyFromURL();
addsOnly = false;
commitCopy = true;
} else {
addsOnly = true;
}
}
if ((entry.isCopied() || copyMode) && !entry.isDeleted() && entry.getSchedule() == null) {
long parentRevision = entry.getRevision() - 1;
boolean switched = false;
if (entry != null && parentEntry != null) {
switched = !entry.getURL().equals(SVNPathUtil.append(parentEntry.getURL(),
SVNEncodingUtil.uriEncode(path.getName())));
}
if (!switched && !dir.getWCAccess().isWCRoot(path)) {
if (parentEntry != null) {
parentRevision = parentEntry.getRevision();
}
} else if (!copyMode) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_CORRUPT,
"Did not expect ''{0}'' to be a working copy root", path);
SVNErrorManager.error(err, SVNLogType.WC);
}
if (parentRevision != entry.getRevision()) {
commitAddition = true;
commitCopy = true;
addsOnly = false;
cfRevision = entry.getRevision();
if (copyMode) {
cfURL = entry.getURL();
} else if (copyFromURL != null) {
cfURL = copyFromURL;
} else {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.BAD_URL,
"Commit item ''{0}'' has copy flag but no copyfrom URL", path);
SVNErrorManager.error(err, SVNLogType.WC);
}
}
}
boolean textModified = false;
boolean propsModified = false;
boolean commitLock;
if (commitAddition) {
SVNFileType addedFileType = SVNFileType.getType(path);
if (addedFileType == SVNFileType.NONE) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_PATH_NOT_FOUND,
"''{0}'' is scheduled for addition, but is missing", path);
SVNErrorManager.error(err, SVNLogType.WC);
}
SVNVersionedProperties props = dir.getProperties(entry.getName());
SVNVersionedProperties baseProps = dir.getBaseProperties(entry.getName());
SVNProperties propDiff = null;
if (entry.isScheduledForReplacement()) {
propDiff = props.asMap();
} else {
propDiff = baseProps.compareTo(props).asMap();
}
boolean eolChanged = textModified = propDiff != null && propDiff.containsName(SVNProperty.EOL_STYLE);
boolean charsetChanged = propDiff != null && propDiff.containsName(SVNProperty.CHARSET);
textModified = eolChanged || charsetChanged;
if (entry.getKind() == SVNNodeKind.FILE) {
if (commitCopy) {
textModified = propDiff != null && (propDiff.containsName(SVNProperty.EOL_STYLE) || propDiff.containsName(SVNProperty.CHARSET));
if (!textModified) {
textModified = dir.hasTextModifications(entry.getName(), eolChanged);
}
} else {
textModified = true;
}
}
propsModified = propDiff != null && !propDiff.isEmpty();
} else if (!commitDeletion) {
SVNVersionedProperties props = dir.getProperties(entry.getName());
SVNVersionedProperties baseProps = dir.getBaseProperties(entry.getName());
SVNProperties propDiff = baseProps.compareTo(props).asMap();
boolean forceComparison = textModified = propDiff != null && (propDiff.containsName(SVNProperty.EOL_STYLE) || propDiff.containsName(SVNProperty.CHARSET));
propsModified = propDiff != null && !propDiff.isEmpty();
if (entry.getKind() == SVNNodeKind.FILE) {
textModified = dir.hasTextModifications(entry.getName(), forceComparison);
}
}
commitLock = entry.getLockToken() != null && (justLocked || textModified || propsModified
|| commitDeletion || commitAddition || commitCopy);
if (commitAddition || commitDeletion || textModified || propsModified
|| commitCopy || commitLock) {
if (SVNWCAccess.matchesChangeList(changelists, entry)) {
SVNCommitItem item = new SVNCommitItem(path,
SVNURL.parseURIEncoded(url), cfURL != null ? SVNURL.parseURIEncoded(cfURL) : null, entry.getKind(),
SVNRevision.create(entry.getRevision()), SVNRevision.create(cfRevision),
commitAddition, commitDeletion, propsModified, textModified, commitCopy,
commitLock);
String itemPath = dir.getRelativePath(dir.getWCAccess().retrieve(dir.getWCAccess().getAnchor()));
if ("".equals(itemPath)) {
itemPath += entry.getName();
} else if (!"".equals(entry.getName())) {
itemPath += "/" + entry.getName();
}
item.setPath(itemPath);
commitables.put(path, item);
if (lockTokens != null && entry.getLockToken() != null) {
lockTokens.put(url, entry.getLockToken());
}
}
}
//collect externals properties
if (pathsToExternalsProperties != null && SVNWCAccess.matchesChangeList(changelists, entry)) {
SVNVersionedProperties props = dir.getProperties(entry.getName());
String externalsProperty = props.getStringPropertyValue(SVNProperty.EXTERNALS);
if (externalsProperty != null) {
pathsToExternalsProperties.put(dir.getFile(entry.getName()), externalsProperty);
}
}
if (entries != null && SVNDepth.EMPTY.compareTo(depth) < 0 && (commitAddition || !commitDeletion)) {
// recurse.
for (Iterator ents = entries.entries(copyMode); ents.hasNext();) {
if (dir != null && dir.getWCAccess() != null) {
dir.getWCAccess().checkCancelled();
}
SVNEntry currentEntry = (SVNEntry) ents.next();
if (currentEntry.isThisDir()) {
continue;
}
// if recursion is forced and entry is explicitly copied, skip it.
if (forcedRecursion && currentEntry.isCopied() && currentEntry.getCopyFromURL() != null) {
continue;
}
if (currentEntry.getDepth() == SVNDepth.EXCLUDE) {
continue;
}
if (entry.isScheduledForReplacement() && currentEntry.isScheduledForDeletion()) {
continue;
}
String currentCFURL = cfURL != null ? cfURL : copyFromURL;
if (currentCFURL != null) {
currentCFURL = SVNPathUtil.append(currentCFURL, SVNEncodingUtil.uriEncode(currentEntry.getName()));
}
String currentURL = currentEntry.getURL();
if (copyMode || currentEntry.getURL() == null) {
currentURL = SVNPathUtil.append(url, SVNEncodingUtil.uriEncode(currentEntry.getName()));
}
File currentFile = dir.getFile(currentEntry.getName());
SVNAdminArea childDir;
if (currentEntry.getKind() == SVNNodeKind.DIR) {
if (SVNDepth.FILES.compareTo(depth) >= 0) {
continue;
}