public SVNMergeCallback createMergeCallback(SVNMergeDriver mergeDriver, SVNAdminArea adminArea, SVNURL url, SVNDiffOptions mergeOptions, Map conflictedPaths, boolean force, boolean dryRun) { int maxVersion = getMaxFormatVersion(); if (maxVersion < SVNAdminAreaFactory.WC_FORMAT_16) { return new SVNMergeCallback15(adminArea, url, force, dryRun, mergeOptions, conflictedPaths, mergeDriver); } return new SVNMergeCallback(adminArea, url, force, dryRun, mergeOptions, conflictedPaths, mergeDriver); }
public SVNStatusType propertiesChanged(String path, Map originalProperties, Map diff) throws SVNException { Map regularProps = new HashMap(); categorizeProperties(diff, regularProps, null, null); if (regularProps.isEmpty()) { return SVNStatusType.UNKNOWN; } try { File file = getFile(path); SVNStatusType result = SVNPropertiesManager.mergeProperties(getWCAccess(), file, originalProperties, regularProps, false, myIsDryRun); return result; } catch (SVNException e) { if (e.getErrorMessage().getErrorCode() == SVNErrorCode.UNVERSIONED_RESOURCE || e.getErrorMessage().getErrorCode() == SVNErrorCode.ENTRY_NOT_FOUND) { return SVNStatusType.MISSING; } throw e; } }
public SVNStatusType fileDeleted(String path, File file1, File file2, String mimeType1, String mimeType2, SVNProperties originalProperties, boolean[] isTreeConflicted) throws SVNException { setIsConflicted(isTreeConflicted, false); File mergedFile = getFile(path); SVNAdminArea dir = retrieve(mergedFile.getParentFile(), true); if (dir == null) { return SVNStatusType.MISSING; SVNStatusType obstructedStatus = getStatusForObstructedOrMissing(path); if (obstructedStatus != SVNStatusType.INAPPLICABLE) { return obstructedStatus; if (areFilesTheSame(file1, originalProperties, mergedFile, dir) || myMergeDriver.myIsForce || myMergeDriver.myIsRecordOnly) { ISVNEventHandler oldEventHandler = getWCAccess().getEventHandler(); getWCAccess().setEventHandler(null); try { delete(mergedFile, true, myIsDryRun, false); } catch (SVNException e) { return SVNStatusType.OBSTRUCTED; } finally { getWCAccess().setEventHandler(oldEventHandler); setIsConflicted(isTreeConflicted, true); return SVNStatusType.OBSTRUCTED; } else if (fileType == SVNFileType.DIRECTORY) { myMergeDriver.recordTreeConflict(mergedFile, dir, SVNNodeKind.FILE, SVNConflictAction.DELETE, SVNConflictReason.OBSTRUCTED); setIsConflicted(isTreeConflicted, true); return SVNStatusType.OBSTRUCTED; } else if (fileType == SVNFileType.NONE) { myMergeDriver.recordTreeConflict(mergedFile, dir, SVNNodeKind.FILE, SVNConflictAction.DELETE, SVNConflictReason.DELETED);
private SVNNodeKind getDiskKind(String path) { File file = getFile(path); SVNFileType type = null; type = SVNFileType.getType(file); if (type == SVNFileType.UNKNOWN) { return SVNNodeKind.UNKNOWN; } if (myIsDryRun && isPathDeleted(path)) { return SVNNodeKind.NONE; } return SVNFileType.getNodeKind(type); }
public void directoryOpened(String path, long revision, boolean[] isTreeConflicted) throws SVNException { setIsConflicted(isTreeConflicted, false); File mergedFile = getFile(path); SVNAdminArea dir = retrieve(mergedFile.getParentFile(), myIsDryRun); if (dir == null) { return; } SVNEntry entry = getWCAccess().getEntry(mergedFile, true); SVNFileType type = SVNFileType.getType(mergedFile); if (entry == null || entry.isScheduledForDeletion() || type != SVNFileType.DIRECTORY) { myMergeDriver.recordTreeConflict(mergedFile, dir, SVNNodeKind.DIR, SVNConflictAction.EDIT, SVNConflictReason.DELETED); setIsConflicted(isTreeConflicted, true); } }
public SVNStatusType fileDeleted(String path, File file1, File file2, String mimeType1, String mimeType2, Map originalProperties) throws SVNException { File mergedFile = getFile(path); SVNAdminArea dir = retrieve(mergedFile.getParentFile(), true); if (dir == null) { return SVNStatusType.MISSING; } SVNFileType fileType = SVNFileType.getType(mergedFile); if (fileType == SVNFileType.FILE || fileType == SVNFileType.SYMLINK) { ISVNEventHandler oldEventHandler = getWCAccess().getEventHandler(); getWCAccess().setEventHandler(null); try { delete(mergedFile, myIsForce, myIsDryRun); } catch (SVNException e) { return SVNStatusType.OBSTRUCTED; } finally { getWCAccess().setEventHandler(oldEventHandler); } return SVNStatusType.CHANGED; } else if (fileType == SVNFileType.DIRECTORY) { return SVNStatusType.OBSTRUCTED; } else if (fileType == SVNFileType.NONE) { return SVNStatusType.MISSING; } return SVNStatusType.UNKNOWN; }
public SVNStatusType[] fileAdded(String path, File file1, File file2, long revision1, long revision2, String mimeType1, String mimeType2, SVNProperties originalProperties, SVNProperties diff, boolean[] isTreeConflicted) throws SVNException { setIsConflicted(isTreeConflicted, false); SVNStatusType[] result = new SVNStatusType[] {null, SVNStatusType.UNKNOWN}; SVNProperties fileProps = new SVNProperties(originalProperties); File mergedFile = getFile(path); SVNAdminArea dir = retrieve(mergedFile.getParentFile(), true); if (dir == null) { if (myIsDryRun && myAddedPath != null && SVNPathUtil.isAncestor(myAddedPath, path)) { SVNStatusType obstructedStatus = getStatusForObstructedOrMissing(path); if (obstructedStatus != SVNStatusType.INAPPLICABLE) { return new SVNStatusType[] { obstructedStatus, SVNStatusType.UNCHANGED }; SVNTreeConflictDescription existingConflict = getWCAccess().getTreeConflict(mergedFile); if (existingConflict != null) { myMergeDriver.recordTreeConflictOnAdd(mergedFile, getAdminArea(), SVNNodeKind.FILE, SVNConflictAction.ADD, SVNConflictReason.ADDED); setIsConflicted(isTreeConflicted, true); } else { SVNWCManager.addRepositoryFile(dir, mergedFile.getName(), newFile, newBaseFile, newBaseProps, newProps, setIsConflicted(isTreeConflicted, true); if (myIsDryRun && isPathDeleted(path)) { result[0] = SVNStatusType.CHANGED; } else { if (myIsDryRun && isPathDeleted(path)) { result[0] = SVNStatusType.CHANGED; } else {
public SVNStatusType[] fileChanged(String path, File file1, File file2, long revision1, long revision2, String mimeType1, String mimeType2, SVNProperties originalProperties, SVNProperties diff, boolean[] isTreeConflicted) throws SVNException { setIsConflicted(isTreeConflicted, false); boolean needsMerge = true; File mergedFile = getFile(path); SVNAdminArea dir = retrieve(mergedFile.getParentFile(), myIsDryRun); if (dir == null) { return new SVNStatusType[] {SVNStatusType.MISSING, SVNStatusType.MISSING}; SVNStatusType obstructedStatus = getStatusForObstructedOrMissing(path); if (obstructedStatus != SVNStatusType.INAPPLICABLE) { return new SVNStatusType[] { obstructedStatus, SVNStatusType.UNCHANGED }; SVNEntry entry = getWCAccess().getEntry(mergedFile, false); SVNFileType fileType = null; if (entry != null) { setIsConflicted(isTreeConflicted, true); return new SVNStatusType[] {SVNStatusType.MISSING, SVNStatusType.MISSING}; result[1] = propertiesChanged(path, originalProperties, diff, isTreeConflicted2); if (isTreeConflicted2[0]) { setIsConflicted(isTreeConflicted, true); return result;
public SVNStatusType propertiesChanged(String path, SVNProperties originalProperties, SVNProperties diff, boolean[] isTreeConflicted) throws SVNException { setIsConflicted(isTreeConflicted, false); SVNStatusType obstructedStatus = getStatusForObstructedOrMissing(path); if (obstructedStatus != SVNStatusType.INAPPLICABLE) { return obstructedStatus; categorizeProperties(diff, regularProps, null, null); if (regularProps.isEmpty()) { return SVNStatusType.UNKNOWN; File file = getFile(path); SVNWCAccess wcAccess = getWCAccess(); if (wcAccess.getAdminArea(file) == null) { wcAccess.probeTry(file, true, SVNWCAccess.INFINITE_DEPTH); SVNStatusType status = SVNPropertiesManager.mergeProperties(getWCAccess(), file, originalProperties, regularProps, false, myIsDryRun); if (!myIsDryRun) { if (e.getErrorMessage().getErrorCode() == SVNErrorCode.UNVERSIONED_RESOURCE || e.getErrorMessage().getErrorCode() == SVNErrorCode.ENTRY_NOT_FOUND) { setIsConflicted(isTreeConflicted, true); return SVNStatusType.MISSING;
public SVNStatusType[] fileAdded(String path, File file1, File file2, long revision1, long revision2, String mimeType1, String mimeType2, Map originalProperties, Map diff) throws SVNException { SVNStatusType[] result = new SVNStatusType[] {null, SVNStatusType.UNKNOWN}; File mergedFile = getFile(path); SVNAdminArea dir = retrieve(mergedFile.getParentFile(), true); if (dir == null) { if (myIsDryRun && myAddedPath != null && SVNPathUtil.isAncestor(myAddedPath, path)) { SVNEntry entry = getWCAccess().getEntry(mergedFile, false); if (entry != null && !entry.isScheduledForDeletion()) { result[0] = SVNStatusType.OBSTRUCTED; if (myIsDryRun && isPathDeleted(path)){ result[0] = SVNStatusType.CHANGED; } else { SVNEntry entry = getWCAccess().getEntry(mergedFile, false); if (entry == null || entry.isScheduledForDeletion()) { result[0] = SVNStatusType.OBSTRUCTED; } else if (myIsDryRun && isPathDeleted(path)){ result[0] = SVNStatusType.CHANGED; } else { myIsAddNecessitatedMerge = true; result = fileChanged(path, file1, file2, revision1, revision2, mimeType1, mimeType2, originalProperties, diff); myIsAddNecessitatedMerge = false;
private SVNStatusType getStatusForObstructedOrMissing(String path) { File file = getFile(path); SVNEntry entry = null; try { entry = getWCAccess().getEntry(file, true); } catch (SVNException svne) { // } if (entry != null && entry.isAbsent()) { return SVNStatusType.MISSING; } SVNNodeKind expectedKind = getWorkingNodeKind(entry, path); SVNNodeKind diskKind = getDiskKind(path); if (entry != null && entry.isDirectory() && entry.isScheduledForDeletion() && diskKind == SVNNodeKind.DIR) { expectedKind = SVNNodeKind.DIR; } if (expectedKind == diskKind) { return SVNStatusType.INAPPLICABLE; } else if (diskKind == SVNNodeKind.NONE) { return SVNStatusType.MISSING; } return SVNStatusType.OBSTRUCTED; }
public SVNStatusType[] fileChanged(String path, File file1, File file2, long revision1, long revision2, String mimeType1, String mimeType2, Map originalProperties, Map diff) throws SVNException { boolean needsMerge = true; File mergedFile = getFile(path); SVNAdminArea dir = retrieve(mergedFile.getParentFile(), myIsDryRun); if (dir == null) { return new SVNStatusType[] {SVNStatusType.MISSING, SVNStatusType.MISSING}; SVNEntry entry = getWCAccess().getEntry(mergedFile, false); SVNFileType fileType = null; if (entry != null) { result[1] = propertiesChanged(path, originalProperties, diff);
protected void delete(File path, boolean force, boolean dryRun, boolean keepLocal) throws SVNException { if (!force && !keepLocal) { SVNWCManager.canDelete(path, getWCAccess().getOptions(), getWCAccess()); } SVNAdminArea root = getWCAccess().retrieve(path.getParentFile()); if (!dryRun) { SVNWCManager.delete(getWCAccess(), root, path, !keepLocal, false); } }
SVNMergeCallback callback = new SVNMergeCallback(info, url2, force, dryRun, getMergeOptions()); mergeResult = callback.fileChanged(name, f1, f2, rev1[0], rev2[0], mimeType1, mimeType2, props1, propsDiff); } finally { SVNFileUtil.deleteAll(f1, null);
private SVNNodeKind getWorkingNodeKind(SVNEntry entry, String path) { if (entry == null || entry.isScheduledForDeletion() || (myIsDryRun && isPathDeleted(path)) || (entry.isDeleted() && !entry.isScheduledForAddition())) { return SVNNodeKind.NONE; } return entry.getKind(); }
private boolean arePropsTheSame(SVNProperties props1, SVNProperties props2) { SVNProperties propsDiff = props2.compareTo(props1); SVNProperties regularPropsDiff = new SVNProperties(); categorizeProperties(propsDiff, regularPropsDiff, null, null); for (Iterator propNamesIter = regularPropsDiff.nameSet().iterator(); propNamesIter.hasNext();) { String propName = (String) propNamesIter.next(); if (!SVNProperty.MERGE_INFO.equals(propName)) { return false; } } return true; }
protected boolean areFilesTheSame(File older, SVNProperties originalProps, File mine, SVNAdminArea adminArea) throws SVNException { SVNProperties workingProps = adminArea.getProperties(mine.getName()).asMap(); if (arePropsTheSame(originalProps, workingProps)) { return !adminArea.hasVersionedFileTextChanges(mine, older, true); } return false; }
public SVNStatusType[] fileAdded(String path, File file1, File file2, long revision1, long revision2, String mimeType1, String mimeType2, SVNProperties originalProperties, SVNProperties diff, boolean[] isTreeConflicted) throws SVNException { setIsConflicted(isTreeConflicted, false); SVNStatusType[] result = new SVNStatusType[] {null, SVNStatusType.UNKNOWN}; SVNProperties fileProps = new SVNProperties(originalProperties); File mergedFile = getFile(path); SVNAdminArea dir = retrieve(mergedFile.getParentFile(), true); if (dir == null) { if (myIsDryRun && myAddedPath != null && SVNPathUtil.isAncestor(myAddedPath, path)) { SVNStatusType obstructedStatus = getStatusForObstructedOrMissing(path); if (obstructedStatus != SVNStatusType.INAPPLICABLE) { return new SVNStatusType[] { obstructedStatus, SVNStatusType.UNCHANGED }; SVNTreeConflictDescription existingConflict = getWCAccess().getTreeConflict(mergedFile); if (existingConflict != null) { myMergeDriver.recordTreeConflictOnAdd(mergedFile, getAdminArea(), SVNNodeKind.FILE, SVNConflictAction.ADD, SVNConflictReason.ADDED); setIsConflicted(isTreeConflicted, true); } else { SVNWCManager.addRepositoryFile(dir, mergedFile.getName(), newFile, newBaseFile, newBaseProps, newProps, setIsConflicted(isTreeConflicted, true); if (myIsDryRun && isPathDeleted(path)) { result[0] = SVNStatusType.CHANGED; } else { if (myIsDryRun && isPathDeleted(path)) { result[0] = SVNStatusType.CHANGED; } else {
public SVNStatusType[] fileChanged(String path, File file1, File file2, long revision1, long revision2, String mimeType1, String mimeType2, SVNProperties originalProperties, SVNProperties diff, boolean[] isTreeConflicted) throws SVNException { setIsConflicted(isTreeConflicted, false); boolean needsMerge = true; File mergedFile = getFile(path); SVNAdminArea dir = retrieve(mergedFile.getParentFile(), myIsDryRun); if (dir == null) { return new SVNStatusType[] {SVNStatusType.MISSING, SVNStatusType.MISSING}; SVNStatusType obstructedStatus = getStatusForObstructedOrMissing(path); if (obstructedStatus != SVNStatusType.INAPPLICABLE) { return new SVNStatusType[] { obstructedStatus, SVNStatusType.UNCHANGED }; SVNEntry entry = getWCAccess().getEntry(mergedFile, false); SVNFileType fileType = null; if (entry != null) { setIsConflicted(isTreeConflicted, true); return new SVNStatusType[] {SVNStatusType.MISSING, SVNStatusType.MISSING}; result[1] = propertiesChanged(path, originalProperties, diff, isTreeConflicted2); if (isTreeConflicted2[0]) { setIsConflicted(isTreeConflicted, true); return result;
public SVNStatusType propertiesChanged(String path, SVNProperties originalProperties, SVNProperties diff, boolean[] isTreeConflicted) throws SVNException { setIsConflicted(isTreeConflicted, false); SVNStatusType obstructedStatus = getStatusForObstructedOrMissing(path); if (obstructedStatus != SVNStatusType.INAPPLICABLE) { return obstructedStatus; categorizeProperties(diff, regularProps, null, null); if (regularProps.isEmpty()) { return SVNStatusType.UNKNOWN; File file = getFile(path); SVNWCAccess wcAccess = getWCAccess(); if (wcAccess.getAdminArea(file) == null) { wcAccess.probeTry(file, true, SVNWCAccess.INFINITE_DEPTH); SVNStatusType status = SVNPropertiesManager.mergeProperties(getWCAccess(), file, originalProperties, regularProps, false, myIsDryRun); if (!myIsDryRun) { if (e.getErrorMessage().getErrorCode() == SVNErrorCode.UNVERSIONED_RESOURCE || e.getErrorMessage().getErrorCode() == SVNErrorCode.ENTRY_NOT_FOUND) { setIsConflicted(isTreeConflicted, true); return SVNStatusType.MISSING;