protected SVNMergeResult handleChooseBase(SVNMergeFileSet files) throws SVNException { SVNLog log = files.getLog(); if (log != null) { SVNProperties command = new SVNProperties(); command.put(SVNLog.NAME_ATTR, files.getBasePath()); command.put(SVNLog.DEST_ATTR, files.getWCPath()); log.addCommand(SVNLog.COPY_AND_TRANSLATE, command, false); command.clear(); } return SVNMergeResult.createMergeResult(SVNStatusType.MERGED, null); }
protected SVNMergeResult handleChooseRepository(SVNMergeFileSet files) throws SVNException { SVNLog log = files.getLog(); if (log != null) { SVNProperties command = new SVNProperties(); command.put(SVNLog.NAME_ATTR, files.getRepositoryPath()); command.put(SVNLog.DEST_ATTR, files.getWCPath()); log.addCommand(SVNLog.COPY_AND_TRANSLATE, command, false); command.clear(); } return SVNMergeResult.createMergeResult(SVNStatusType.MERGED, null); }
protected void postMergeCleanup(SVNMergeFileSet files) throws SVNException { SVNProperties command = new SVNProperties(); SVNLog log = files.getLog(); if (!files.getLocalPath().equals(files.getWCPath())) { command.put(SVNLog.NAME_ATTR, files.getLocalPath()); log.addCommand(SVNLog.DELETE, command, false); command.clear(); } command.put(SVNLog.NAME_ATTR, files.getWCPath()); log.addCommand(SVNLog.MAYBE_EXECUTABLE, command, false); command.clear(); command.put(SVNLog.NAME_ATTR, files.getWCPath()); log.addCommand(SVNLog.MAYBE_READONLY, command, false); command.clear(); command.put(SVNLog.NAME_ATTR, files.getResultPath()); log.addCommand(SVNLog.DELETE, command, false); command.clear(); }
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); }
protected SVNMergeResult handleMarkTextConflicted(SVNMergeFileSet files) throws SVNException { SVNProperties command = new SVNProperties(); File root = files.getAdminArea().getRoot(); SVNLog log = files.getLog(); if (files.getCopyFromFile() != null) { String copyFromPath = files.getCopyFromPath(); String detranslatedPath = files.getWCPath(); if (log != null) { command.put(SVNLog.NAME_ATTR, copyFromPath); File mineFile = SVNFileUtil.createUniqueFile(root, files.getWCPath(), files.getLocalLabel(), false); File oldFile = SVNFileUtil.createUniqueFile(root, files.getWCPath(), files.getBaseLabel(), false); File newFile = SVNFileUtil.createUniqueFile(root, files.getWCPath(), files.getRepositoryLabel(), false); String basePath = files.getBasePath(); String latestPath = files.getRepositoryPath(); File tmpTargetCopy = SVNTranslator.getTranslatedFile(files.getAdminArea(), files.getWCPath(), files.getWCFile(), false, false, false, true); String tmpTargetCopyPath = SVNFileUtil.getBasePath(tmpTargetCopy); command.put(SVNLog.NAME_ATTR, basePath); command.put(SVNLog.DEST_ATTR, oldPath); command.put(SVNLog.ATTR2, files.getWCPath()); log.addCommand(SVNLog.COPY_AND_TRANSLATE, command, false); command.clear(); command.put(SVNLog.ATTR2, files.getWCPath()); log.addCommand(SVNLog.COPY_AND_TRANSLATE, command, false); command.clear();
return new SVNConflictResult(SVNConflictChoice.THEIRS_FULL, null); } else if (myAccept == SVNConflictAcceptPolicy.EDIT) { if (files.getResultFile() != null) { if (myIsExternalFailed) { return new SVNConflictResult(SVNConflictChoice.POSTPONE, null); files.getResultFile().getAbsolutePath()); } catch (SVNException svne) { if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.CL_NO_EXTERNAL_EDITOR) { if (files.getBaseFile() != null && files.getLocalFile() != null && files.getRepositoryFile() != null && files.getResultFile() != null) { if (myIsExternalFailed) { return new SVNConflictResult(SVNConflictChoice.POSTPONE, null); SVNCommandUtil.mergeFileExternally(mySVNEnvironment, files.getBaseFile().getAbsolutePath(), files.getRepositoryFile().getAbsolutePath(), files.getLocalFile().getAbsolutePath(), files.getResultFile().getAbsolutePath(), files.getWCPath(), remainsInConflict); } catch (SVNException svne) { if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.CL_NO_EXTERNAL_MERGE_TOOL) { boolean diffAllowed = false; boolean knowsSmth = false; String path = mySVNEnvironment.getRelativePath(files.getWCFile()); path = SVNCommandUtil.getLocalPath(path); if ((files.getLocalFile() == null && files.getRepositoryFile() != null) || (files.getLocalFile() != null && files.getRepositoryFile() == null)) { if (files.getLocalFile() != null) {
String repositoryPath = null; try { basePath = mergeFiles.getBasePath(); repositoryPath = mergeFiles.getRepositoryPath(); } catch (SVNException e) { return new ConflictDescriptor(mergeFiles.getWCPath(), getConflictKind(conflictDescription.isPropertyConflict()), getNodeKind(conflictDescription.getNodeKind()), conflictDescription.getPropertyName(), mergeFiles.isBinary(), mergeFiles.getMimeType(), getConflictAction(conflictDescription.getConflictAction()), getConflictReason(conflictDescription.getConflictReason()), basePath, repositoryPath, mergeFiles.getWCPath(), mergeFiles.getResultPath(), left, right
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 (cdf.getBaseFile() != null) { final File path = SVNFileUtil.isAbsolute(cdf.getBaseFile()) ? cdf.getBaseFile() : SVNFileUtil.createFilePath(dir_path, cdf.getBaseFile()); final SVNNodeKind kind = SVNFileType.getNodeKind(SVNFileType.getType(path)); if (kind == SVNNodeKind.FILE) { 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 (cdf.getLocalFile() != null) { final File path = SVNFileUtil.isAbsolute(cdf.getLocalFile()) ? cdf.getLocalFile() : SVNFileUtil.createFilePath(dir_path, cdf.getLocalFile()); 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) {
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 ); }
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); }
protected SVNMergeResult handleChooseMerged(SVNMergeFileSet files, SVNMergeResult mergeResult) throws SVNException { SVNProperties command = new SVNProperties(); SVNLog log = files.getLog(); if (mergeResult.getMergeStatus() != SVNStatusType.CONFLICTED) { // do normal merge. if (mergeResult.getMergeStatus() != SVNStatusType.UNCHANGED) { command.put(SVNLog.NAME_ATTR, files.getResultPath()); command.put(SVNLog.DEST_ATTR, files.getWCPath()); log.addCommand(SVNLog.COPY_AND_TRANSLATE, command, false); command.clear(); } return mergeResult; } else if (files.isBinary()) { // this action is not applicable for binary conflited files. return handleMarkConflicted(files); } else { // for text file we could use merged version in case of conflict. command.put(SVNLog.NAME_ATTR, files.getResultPath()); command.put(SVNLog.DEST_ATTR, files.getWCPath()); log.addCommand(SVNLog.COPY_AND_TRANSLATE, command, false); command.clear(); return SVNMergeResult.createMergeResult(SVNStatusType.MERGED, null); } }
protected SVNMergeResult handleChooseConflicted(boolean chooseMine, SVNMergeFileSet files) throws SVNException { File tmpFile = SVNAdminUtil.createTmpFile(files.getAdminArea()); String separator = new String(getConflictSeparatorMarker()); String mineMarker = new String(getConflictStartMarker()); boolean skip = false; try { reader = new BufferedReader(new InputStreamReader(SVNFileUtil.openFileForReading(files.getResultFile()))); tmpOS = SVNFileUtil.openFileForWriting(tmpFile); String line = null; SVNLog log = files.getLog(); 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();
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); } }
protected void makeBinaryConflictEntry(SVNMergeFileSet files, String newFilePath, String oldFilePath) throws SVNException { SVNProperties command = new SVNProperties(); SVNLog log = files.getLog(); command.put(SVNProperty.shortPropertyName(SVNProperty.CONFLICT_NEW), newFilePath); command.put(SVNProperty.shortPropertyName(SVNProperty.CONFLICT_OLD), oldFilePath); log.logChangedEntryProperties(files.getWCPath(), command); command.clear(); files.getAdminArea().saveEntries(false); }
protected void makeTextConflictEntry(SVNMergeFileSet files, String mineFilePath, String newFilePath, String oldFilePath) throws SVNException { SVNLog log = files.getLog(); if (log != null) { SVNProperties command = new SVNProperties(); command.put(SVNProperty.shortPropertyName(SVNProperty.CONFLICT_WRK), mineFilePath); command.put(SVNProperty.shortPropertyName(SVNProperty.CONFLICT_NEW), newFilePath); command.put(SVNProperty.shortPropertyName(SVNProperty.CONFLICT_OLD), oldFilePath); log.logChangedEntryProperties(files.getWCPath(), command); command.clear(); } }
protected SVNMergeResult handleMarkConflicted(SVNMergeFileSet files) throws SVNException { if (files.isBinary()) { return handleMarkBinaryConflicted(files); } return handleMarkTextConflicted(files); }
File mergedFile = result.getMergedFile() != null ? result.getMergedFile() : files.getResultFile(); File mergeTarget = files.getWCFile(); File editedMergedFile = SVNFileUtil.createUniqueFile(mergeTarget.getParentFile(), mergeTarget.getName(), ".edited", false); SVNLog log = files.getLog(); SVNProperties command = new SVNProperties(); command.put(SVNLog.NAME_ATTR, SVNFileUtil.getBasePath(mergedFile));
/** * Returns the wc file. * @return detranslated wc file * @since 1.3 */ public File getPath() { return getMergeFiles().getLocalFile(); }
File getPrejfileAbspath(File localAbspath) throws SVNException { List<SVNConflictDescription> conflicts = db.readConflicts(localAbspath); for (SVNConflictDescription cd : conflicts) { if (cd.isPropertyConflict()) { if (cd.getMergeFiles().getRepositoryPath().equals(THIS_DIR_PREJ + PROP_REJ_EXT)) { return SVNFileUtil.createFilePath(localAbspath, THIS_DIR_PREJ + PROP_REJ_EXT); } return SVNFileUtil.createFilePath(cd.getMergeFiles().getRepositoryPath()); } } return null; }