private void showConflictedChunks(SVNMergeFileSet files) throws SVNException { byte[] conflictStartMarker = "<<<<<<< MINE (select with 'mc')".getBytes(); byte[] conflictSeparator = "=======".getBytes(); byte[] conflictEndMarker = ">>>>>>> THEIRS (select with 'tc')".getBytes(); byte[] conflictOriginalMarker = "||||||| ORIGINAL".getBytes(); SVNDiffOptions options = new SVNDiffOptions(false, false, true); FSMergerBySequence merger = new FSMergerBySequence(conflictStartMarker, conflictSeparator, conflictEndMarker, conflictOriginalMarker); RandomAccessFile localIS = null; RandomAccessFile latestIS = null; RandomAccessFile baseIS = null; try { localIS = new RandomAccessFile(files.getWCFile(), "r"); latestIS = new RandomAccessFile(files.getRepositoryFile(), "r"); baseIS = new RandomAccessFile(files.getBaseFile(), "r"); QSequenceLineRAData baseData = new QSequenceLineRAFileData(baseIS); QSequenceLineRAData localData = new QSequenceLineRAFileData(localIS); QSequenceLineRAData latestData = new QSequenceLineRAFileData(latestIS); merger.merge(baseData, localData, latestData, options, mySVNEnvironment.getOut(), SVNDiffConflictChoiceStyle.CHOOSE_ONLY_CONFLICTS); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage()); SVNErrorManager.error(err, e, SVNLogType.WC); } finally { SVNFileUtil.closeFile(localIS); SVNFileUtil.closeFile(baseIS); SVNFileUtil.closeFile(latestIS); } }
private void showConflictedChunks(SVNMergeFileSet files) throws SVNException { byte[] conflictStartMarker = "<<<<<<< MINE (select with 'mc')".getBytes(); byte[] conflictSeparator = "=======".getBytes(); byte[] conflictEndMarker = ">>>>>>> THEIRS (select with 'tc')".getBytes(); byte[] conflictOriginalMarker = "||||||| ORIGINAL".getBytes(); SVNDiffOptions options = new SVNDiffOptions(false, false, true); FSMergerBySequence merger = new FSMergerBySequence(conflictStartMarker, conflictSeparator, conflictEndMarker, conflictOriginalMarker); RandomAccessFile localIS = null; RandomAccessFile latestIS = null; RandomAccessFile baseIS = null; try { localIS = new RandomAccessFile(files.getWCFile(), "r"); latestIS = new RandomAccessFile(files.getRepositoryFile(), "r"); baseIS = new RandomAccessFile(files.getBaseFile(), "r"); QSequenceLineRAData baseData = new QSequenceLineRAFileData(baseIS); QSequenceLineRAData localData = new QSequenceLineRAFileData(localIS); QSequenceLineRAData latestData = new QSequenceLineRAFileData(latestIS); merger.merge(baseData, localData, latestData, options, mySVNEnvironment.getOut(), SVNDiffConflictChoiceStyle.CHOOSE_ONLY_CONFLICTS); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage()); SVNErrorManager.error(err, e, SVNLogType.WC); } finally { SVNFileUtil.closeFile(localIS); SVNFileUtil.closeFile(baseIS); SVNFileUtil.closeFile(latestIS); } }
if (cdf.getRepositoryFile() != null) { final File path = SVNFileUtil.isAbsolute(cdf.getRepositoryFile()) ? cdf.getRepositoryFile() : SVNFileUtil.createFilePath(dir_path, cdf.getRepositoryFile()); final SVNNodeKind kind = SVNFileType.getNodeKind(SVNFileType.getType(path)); if (kind == SVNNodeKind.FILE) { if (!done && (cdf.getBaseFile() != null || cdf.getRepositoryFile() != null || cdf.getLocalFile() != null)) { resolvedText = true; if (cdf.getRepositoryFile() != null) { final File path = SVNFileUtil.isAbsolute(cdf.getRepositoryFile()) ? cdf.getRepositoryFile() : SVNFileUtil.createFilePath(rootPath, cdf.getRepositoryFile()); final SVNNodeKind kind = SVNFileType.getNodeKind(SVNFileType.getType(path)); if (kind == SVNNodeKind.FILE) {
conflictNewAbsPath = mergeFiles.getRepositoryFile(); prejAbsPath = mergeFiles.getRepositoryFile();
if (files.getBaseFile() != null && files.getLocalFile() != null && files.getRepositoryFile() != null && files.getResultFile() != null) { if (myIsExternalFailed) { try { SVNCommandUtil.mergeFileExternally(mySVNEnvironment, files.getBaseFile().getAbsolutePath(), files.getRepositoryFile().getAbsolutePath(), files.getLocalFile().getAbsolutePath(), files.getResultFile().getAbsolutePath(), files.getWCPath(), remainsInConflict); } catch (SVNException svne) { if ((files.getLocalFile() == null && files.getRepositoryFile() != null) || (files.getLocalFile() != null && files.getRepositoryFile() == null)) { if (files.getLocalFile() != null) { String myVal = SVNFileUtil.readFile(files.getLocalFile()); mySVNEnvironment.getErr().println(message); } else { String reposVal = SVNFileUtil.readFile(files.getRepositoryFile()); message = MessageFormat.format("They want to change the property value to ''{0}'', you want to delete the property.", new Object[] { reposVal }); files.getLocalFile() != null && files.getRepositoryFile() != null)) { diffAllowed = true; mySVNEnvironment.getErr().println(); continue; } else if (files.getLocalFile() == null || files.getBaseFile() == null || files.getRepositoryFile() == null) { mySVNEnvironment.getErr().println("Invalid option; original files not available."); mySVNEnvironment.getErr().println();
if (files.getBaseFile() != null && files.getLocalFile() != null && files.getRepositoryFile() != null && files.getResultFile() != null) { if (myIsExternalFailed) { try { SVNCommandUtil.mergeFileExternally(mySVNEnvironment, files.getBaseFile().getAbsolutePath(), files.getRepositoryFile().getAbsolutePath(), files.getLocalFile().getAbsolutePath(), files.getResultFile().getAbsolutePath(), files.getWCPath(), remainsInConflict); } catch (SVNException svne) { if ((files.getLocalFile() == null && files.getRepositoryFile() != null) || (files.getLocalFile() != null && files.getRepositoryFile() == null)) { if (files.getLocalFile() != null) { String myVal = SVNFileUtil.readFile(files.getLocalFile()); mySVNEnvironment.getErr().println(message); } else { String reposVal = SVNFileUtil.readFile(files.getRepositoryFile()); message = MessageFormat.format("They want to change the property value to ''{0}'', you want to delete the property.", new Object[] { reposVal }); files.getLocalFile() != null && files.getRepositoryFile() != null)) { diffAllowed = true; mySVNEnvironment.getErr().println(); continue; } else if (files.getLocalFile() == null || files.getBaseFile() == null || files.getRepositoryFile() == null) { mySVNEnvironment.getErr().println("Invalid option; original files not available."); mySVNEnvironment.getErr().println();
public SVNMergeResult mergeText(SVNMergeFileSet files, boolean dryRun, SVNDiffOptions options) throws SVNException { SVNStatusType status; if (files.isBinary()) { status = mergeBinary(files.getBaseFile(), files.getLocalFile(), files.getRepositoryFile(), options, files.getResultFile()); } else { status = mergeText(files.getBaseFile(), files.getLocalFile(), files.getRepositoryFile(), options, files.getResultFile()); } if (!files.isBinary() && status != SVNStatusType.CONFLICTED) { if (files.getCopyFromFile() != null) { status = SVNStatusType.MERGED; } else { SVNAdminArea adminArea = files.getAdminArea(); SVNVersionedProperties props = adminArea.getProperties(files.getWCPath()); boolean isSpecial = props.getPropertyValue(SVNProperty.SPECIAL) != null; // compare merge result with 'wcFile' (in case of text and no conflict). boolean isSameContents = SVNFileUtil.compareFiles(isSpecial ? files.getLocalFile() : files.getWCFile(), files.getResultFile(), null); status = isSameContents ? SVNStatusType.UNCHANGED : status; } } final SVNMergeResult result = SVNMergeResult.createMergeResult(status, null); if (dryRun) { return result; } return processMergedFiles(files, result); }
public SVNMergeResult mergeText(SVNMergeFileSet files, boolean dryRun, SVNDiffOptions options) throws SVNException { myDiffOptions = options; SVNStatusType status; if (files.isBinary()) { status = mergeBinary(files.getBaseFile(), files.getLocalFile(), files.getRepositoryFile(), options, files.getResultFile()); } else { status = mergeText(files.getBaseFile(), files.getLocalFile(), files.getRepositoryFile(), options, files.getResultFile()); } if (!files.isBinary() && status != SVNStatusType.CONFLICTED) { if (files.getCopyFromFile() != null) { status = SVNStatusType.MERGED; } else { SVNAdminArea adminArea = files.getAdminArea(); SVNVersionedProperties props = adminArea.getProperties(files.getWCPath()); boolean isSpecial = props.getPropertyValue(SVNProperty.SPECIAL) != null; // compare merge result with 'wcFile' (in case of text and no conflict). boolean isSameContents = SVNFileUtil.compareFiles(isSpecial ? files.getLocalFile() : files.getWCFile(), files.getResultFile(), null); status = isSameContents ? SVNStatusType.UNCHANGED : status; } } final SVNMergeResult result = SVNMergeResult.createMergeResult(status, null); if (dryRun) { return result; } return processMergedFiles(files, result); }
public SVNMergeResult mergeText(SVNMergeFileSet files, boolean dryRun, SVNDiffOptions options) throws SVNException { SVNStatusType status; if (files.isBinary()) { status = mergeBinary(files.getBaseFile(), files.getLocalFile(), files.getRepositoryFile(), options, files.getResultFile()); } else { status = mergeText(files.getBaseFile(), files.getLocalFile(), files.getRepositoryFile(), options, files.getResultFile()); } if (!files.isBinary() && status != SVNStatusType.CONFLICTED) { if (files.getCopyFromFile() != null) { status = SVNStatusType.MERGED; } else { SVNAdminArea adminArea = files.getAdminArea(); SVNVersionedProperties props = adminArea.getProperties(files.getWCPath()); boolean isSpecial = props.getPropertyValue(SVNProperty.SPECIAL) != null; // compare merge result with 'wcFile' (in case of text and no conflict). boolean isSameContents = SVNFileUtil.compareFiles(isSpecial ? files.getLocalFile() : files.getWCFile(), files.getResultFile(), null); status = isSameContents ? SVNStatusType.UNCHANGED : status; } } final SVNMergeResult result = SVNMergeResult.createMergeResult(status, null); if (dryRun) { return result; } return processMergedFiles(files, result); }
if (desc.isTextConflict()) { conflictOld = desc.getMergeFiles().getBaseFile(); conflictNew = desc.getMergeFiles().getRepositoryFile(); conflictWorking = desc.getMergeFiles().getLocalFile(); } else if (desc.isPropertyConflict()) { propRejectFile = desc.getMergeFiles().getRepositoryFile();
protected SVNMergeResult handleChooseConflicted(boolean chooseMine, SVNMergeFileSet files) throws SVNException { File tmpFile = SVNAdminUtil.createTmpFile(files.getAdminArea()); setDiffConflictStyle(chooseMine ? SVNDiffConflictChoiceStyle.CHOOSE_MODIFIED : SVNDiffConflictChoiceStyle.CHOOSE_LATEST); File leftFile = files.getBaseFile(); File rightFile = files.getRepositoryFile(); File detranslatedTarget = files.getLocalFile(); mergeText(leftFile, detranslatedTarget, rightFile, getDiffOptions(), tmpFile); SVNLog log = files.getLog(); if (log != null) { SVNProperties command = new SVNProperties(); String tmpBasePath = SVNFileUtil.getBasePath(tmpFile); command.put(SVNLog.NAME_ATTR, tmpBasePath); command.put(SVNLog.DEST_ATTR, files.getWCPath()); log.addCommand(SVNLog.COPY_AND_TRANSLATE, command, false); command.clear(); command.put(SVNLog.NAME_ATTR, tmpBasePath); log.addCommand(SVNLog.DELETE, command, false); command.clear(); } return SVNMergeResult.createMergeResult(SVNStatusType.MERGED, null); }
conflictNewAbsPath = mergeFiles.getRepositoryFile(); prejAbsPath = mergeFiles.getRepositoryFile();
conflictOld = conflictDescription.getMergeFiles().getBaseFile().getName(); if (conflictDescription.getMergeFiles().getRepositoryFile() != null) { conflictNew = conflictDescription.getMergeFiles().getRepositoryFile().getName(); propRejectFile = conflictDescription.getMergeFiles().getRepositoryFile().getName();
protected SVNMergeResult handleMarkBinaryConflicted(SVNMergeFileSet files) throws SVNException { SVNProperties command = new SVNProperties(); File root = files.getAdminArea().getRoot(); SVNLog log = files.getLog(); File oldFile = SVNFileUtil.createUniqueFile(root, files.getWCPath(), files.getBaseLabel(), false); File newFile = SVNFileUtil.createUniqueFile(root, files.getWCPath(), files.getRepositoryLabel(), false); SVNFileUtil.copyFile(files.getBaseFile(), oldFile, false); SVNFileUtil.copyFile(files.getRepositoryFile(), newFile, false); if (!files.getLocalPath().equals(files.getWCPath())) { File mineFile = SVNFileUtil.createUniqueFile(root, files.getWCPath(), files.getLocalLabel(), false); String minePath = SVNFileUtil.getBasePath(mineFile); if (log != null) { command.put(SVNLog.NAME_ATTR, files.getLocalPath()); command.put(SVNLog.DEST_ATTR, minePath); log.addCommand(SVNLog.MOVE, command, false); command.clear(); } command.put(SVNProperty.shortPropertyName(SVNProperty.CONFLICT_WRK), minePath); } else { command.put(SVNProperty.shortPropertyName(SVNProperty.CONFLICT_WRK), ""); } String newPath = SVNFileUtil.getBasePath(newFile); String oldPath = SVNFileUtil.getBasePath(oldFile); makeBinaryConflictEntry(files, newPath, oldPath); return SVNMergeResult.createMergeResult(SVNStatusType.CONFLICTED, null); }
protected SVNMergeResult handleMarkBinaryConflicted(SVNMergeFileSet files) throws SVNException { SVNProperties command = new SVNProperties(); File root = files.getAdminArea().getRoot(); SVNLog log = files.getLog(); File oldFile = SVNFileUtil.createUniqueFile(root, files.getWCPath(), files.getBaseLabel(), false); File newFile = SVNFileUtil.createUniqueFile(root, files.getWCPath(), files.getRepositoryLabel(), false); SVNFileUtil.copyFile(files.getBaseFile(), oldFile, false); SVNFileUtil.copyFile(files.getRepositoryFile(), newFile, false); if (!files.getLocalPath().equals(files.getWCPath())) { File mineFile = SVNFileUtil.createUniqueFile(root, files.getWCPath(), files.getLocalLabel(), false); String minePath = SVNFileUtil.getBasePath(mineFile); command.put(SVNLog.NAME_ATTR, files.getLocalPath()); command.put(SVNLog.DEST_ATTR, minePath); log.addCommand(SVNLog.MOVE, command, false); command.clear(); command.put(SVNProperty.shortPropertyName(SVNProperty.CONFLICT_WRK), minePath); } else { command.put(SVNProperty.shortPropertyName(SVNProperty.CONFLICT_WRK), ""); } String newPath = SVNFileUtil.getBasePath(newFile); String oldPath = SVNFileUtil.getBasePath(oldFile); makeBinaryConflictEntry(files, newPath, oldPath); return SVNMergeResult.createMergeResult(SVNStatusType.CONFLICTED, null); }
protected SVNMergeResult handleMarkBinaryConflicted(SVNMergeFileSet files) throws SVNException { SVNProperties command = new SVNProperties(); File root = files.getAdminArea().getRoot(); SVNLog log = files.getLog(); File oldFile = SVNFileUtil.createUniqueFile(root, files.getWCPath(), files.getBaseLabel(), false); File newFile = SVNFileUtil.createUniqueFile(root, files.getWCPath(), files.getRepositoryLabel(), false); SVNFileUtil.copyFile(files.getBaseFile(), oldFile, false); SVNFileUtil.copyFile(files.getRepositoryFile(), newFile, false); if (!files.getLocalPath().equals(files.getWCPath())) { File mineFile = SVNFileUtil.createUniqueFile(root, files.getWCPath(), files.getLocalLabel(), false); String minePath = SVNFileUtil.getBasePath(mineFile); if (log != null) { command.put(SVNLog.NAME_ATTR, files.getLocalPath()); command.put(SVNLog.DEST_ATTR, minePath); log.addCommand(SVNLog.MOVE, command, false); command.clear(); } command.put(SVNProperty.shortPropertyName(SVNProperty.CONFLICT_WRK), minePath); } else { command.put(SVNProperty.shortPropertyName(SVNProperty.CONFLICT_WRK), ""); } String newPath = SVNFileUtil.getBasePath(newFile); String oldPath = SVNFileUtil.getBasePath(oldFile); makeBinaryConflictEntry(files, newPath, oldPath); return SVNMergeResult.createMergeResult(SVNStatusType.CONFLICTED, null); }
if (conflict.getMergeFiles() != null) { SVNFileUtil.deleteFile(conflict.getMergeFiles().getBaseFile()); SVNFileUtil.deleteFile(conflict.getMergeFiles().getRepositoryFile()); SVNFileUtil.deleteFile(conflict.getMergeFiles().getLocalFile()); SVNFileUtil.deleteFile(conflict.getMergeFiles().getRepositoryFile());
private ConflictDescriptor getConflictDescription(SVNConflictDescription conflictDescription) throws ClientException { ConflictVersion srcLeft = null; ConflictVersion srcRight = null; ConflictDescriptor.Operation operation = Operation.none; if (conflictDescription instanceof SVNTreeConflictDescription) { SVNTreeConflictDescription treeConflictDescription = (SVNTreeConflictDescription) conflictDescription; srcLeft = getConflictVersion(treeConflictDescription.getSourceLeftVersion()); srcRight = getConflictVersion(treeConflictDescription.getSourceRightVersion()); operation = getConflictDescriptorOperation(treeConflictDescription.getOperation()); } return new ConflictDescriptor( getFilePath(conflictDescription.getPath()), getConflictDescriptorKind(conflictDescription), getNodeKind(conflictDescription.getNodeKind()), conflictDescription.getPropertyName(), conflictDescription.getMergeFiles().isBinary(), conflictDescription.getMergeFiles().getMimeType(), getConflictDescriptorAction(conflictDescription.getConflictAction()), getConflictDescriptorReason(conflictDescription.getConflictReason()), operation, getFilePath(conflictDescription.getMergeFiles().getBaseFile()), getFilePath(conflictDescription.getMergeFiles().getRepositoryFile()), getFilePath(conflictDescription.getMergeFiles().getLocalFile()), getFilePath(conflictDescription.getMergeFiles().getResultFile()), srcLeft, srcRight ); }