/** * Returns the diff driver being in use. * * <p> * If no specific diff driver was previously provided, a default one * will be returned (see {@link DefaultSVNDiffGenerator}). * * @return the diff driver being in use * @see #setDiffGenerator(ISVNDiffGenerator) */ public ISVNDiffGenerator getDiffGenerator() { if (myDiffGenerator == null) { myDiffGenerator = new DefaultSVNDiffGenerator(); } return myDiffGenerator; }
protected void displayHeaderFields(OutputStream os, String label1, String label2) throws IOException { os.write("--- ".getBytes(getEncoding())); os.write(label1.getBytes(getEncoding())); os.write(getEOL()); os.write("+++ ".getBytes(getEncoding())); os.write(label2.getBytes(getEncoding())); os.write(getEOL()); }
protected boolean displayHeader(OutputStream os, String path, boolean deleted) throws IOException { if (deleted && !isDiffDeleted()) { os.write("Index: ".getBytes(getEncoding())); os.write(path.getBytes(getEncoding())); os.write(" (deleted)".getBytes(getEncoding())); os.write(getEOL()); os.write(HEADER_SEPARATOR.getBytes(getEncoding())); os.write(getEOL()); return true; } os.write("Index: ".getBytes(getEncoding())); os.write(path.getBytes(getEncoding())); os.write(getEOL()); os.write(HEADER_SEPARATOR.getBytes(getEncoding())); os.write(getEOL()); return false; }
public SvnNewDiffGenerator(ISvnDiffGenerator generator) { this.generator = generator; if (generator instanceof DefaultSVNDiffGenerator) { DefaultSVNDiffGenerator defaultGenerator = (DefaultSVNDiffGenerator) generator; this.diffAdded = defaultGenerator.isDiffAdded(); this.diffDeleted = defaultGenerator.isDiffDeleted(); this.diffCopied = defaultGenerator.isDiffCopied(); this.diffUnversioned = defaultGenerator.isDiffUnversioned(); } else { this.diffAdded = true; this.diffDeleted = true; this.diffCopied = false; this.diffUnversioned = false; } }
path = getDisplayPath(path); String label1 = getLabel(p1, rev1); String label2 = getLabel(p2, rev2); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { if (displayHeader(bos, path, file2 == null)) { bos.close(); bos.writeTo(result); return; if (isHeaderForced(file1, file2)) { bos.writeTo(result); bos.reset(); if (!isForcedBinaryDiff() && (SVNProperty.isBinaryMimeType(mimeType1) || SVNProperty.isBinaryMimeType(mimeType2))) { try { displayBinary(bos, mimeType1, mimeType2); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage()); final String diffCommand = getExternalDiffCommand(); if (diffCommand != null) { try { args.addAll(myRawDiffOptions); } else { Collection diffOptions = getDiffOptions().toOptionsCollection(); args.addAll(diffOptions);
path = getDisplayPath(path); ByteArrayOutputStream bos = new ByteArrayOutputStream(); diff = new SVNProperties(diff); try { bos.write(getEOL()); bos.write(("Property changes on: " + (useLocalFileSeparatorChar() ? path.replace('/', File.separatorChar) : path)).getBytes(getEncoding())); bos.write(getEOL()); bos.write(PROPERTIES_SEPARATOR.getBytes(getEncoding())); bos.write(getEOL()); for (Iterator changedPropNames = diff.nameSet().iterator(); changedPropNames.hasNext();) { String name = (String) changedPropNames.next(); bos.write((headerFormat + name).getBytes(getEncoding())); bos.write(getEOL()); if (SVNProperty.MERGE_INFO.equals(name)) { displayMergeInfoDiff(bos, originalValue == null ? null : originalValue.getString(), newValue == null ? null : newValue.getString()); continue; bos.write(" - ".getBytes(getEncoding())); bos.write(getPropertyAsBytes(originalValue, getEncoding())); bos.write(getEOL()); bos.write(" + ".getBytes(getEncoding())); bos.write(getPropertyAsBytes(newValue, getEncoding())); bos.write(getEOL()); bos.write(getEOL()); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage());
public void displayFileDiff(String path, File file1, File file2, String rev1, String rev2, String mimeType1, String mimeType2, OutputStream result) throws SVNException { path = getDisplayPath(path); int i = 0; for(; i < myAnchorPath1.length() && i < myAnchorPath2.length() && ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { if (file2 == null && !isDiffDeleted()) { bos.write("Index: ".getBytes(getEncoding())); bos.write(path.getBytes(getEncoding())); bos.write(" (deleted)".getBytes(getEncoding())); bos.write(EOL); bos.write(HEADER_SEPARATOR); bos.write("Index: ".getBytes(getEncoding())); bos.write(path.getBytes(getEncoding())); bos.write(EOL); bos.write(HEADER_SEPARATOR); if (!isForcedBinaryDiff() && (SVNProperty.isBinaryMimeType(mimeType1) || SVNProperty.isBinaryMimeType(mimeType2))) { try { bos.write("Cannot display: file marked as binary type.".getBytes(getEncoding())); bos.write(EOL); if (SVNProperty.isBinaryMimeType(mimeType1) && !SVNProperty.isBinaryMimeType(mimeType2)) { bos.write("svn:mime-type = ".getBytes(getEncoding())); bos.write(mimeType1.getBytes(getEncoding())); bos.write(EOL); } else if (!SVNProperty.isBinaryMimeType(mimeType1)
/** * Returns the diff driver being in use. * * <p> * If no specific diff driver was previously provided, a default one * will be returned (see {@link DefaultSVNDiffGenerator}). * * @return the diff driver being in use * @see #setDiffGenerator(ISVNDiffGenerator) */ public ISVNDiffGenerator getDiffGenerator() { if (myDiffGenerator == null) { DefaultSVNDiffGenerator defaultDiffGenerator = new DefaultSVNDiffGenerator(); defaultDiffGenerator.setOptions(getOptions()); myDiffGenerator = defaultDiffGenerator; } return myDiffGenerator; }
return; path = getDisplayPath(path); ByteArrayOutputStream bos = new ByteArrayOutputStream(); diff = new TreeMap(diff); try { bos.write(EOL); bos.write(("Property changes on: " + path.replace('/', File.separatorChar)).getBytes(getEncoding())); bos.write(EOL); bos.write(PROPERTIES_SEPARATOR); String originalValue = baseProps != null ? (String) baseProps.get(name) : null; String newValue = (String) diff.get(name); bos.write(("Name: " + name).getBytes(getEncoding())); bos.write(EOL); if (originalValue != null) { bos.write(" - ".getBytes(getEncoding())); bos.write(originalValue.getBytes(getEncoding())); bos.write(EOL); bos.write(" + ".getBytes(getEncoding())); bos.write(newValue.getBytes(getEncoding())); bos.write(EOL);
private ISVNDiffGenerator getDiffGenerator() { ISvnDiffGenerator diffGenerator = getOperation().getDiffGenerator(); if (diffGenerator != null) { if (getOperation().getRelativeToDirectory() != null) { if (diffGenerator instanceof SvnDiffGenerator) { ((SvnDiffGenerator) diffGenerator).setRelativeToTarget(SvnTarget.fromFile(getOperation().getRelativeToDirectory())); } else { diffGenerator.setBaseTarget(SvnTarget.fromFile(getOperation().getRelativeToDirectory())); } } return new SvnNewDiffGenerator(diffGenerator); } else { DefaultSVNDiffGenerator defaultSVNDiffGenerator = new DefaultSVNDiffGenerator(); if (getOperation().getRelativeToDirectory() != null) { defaultSVNDiffGenerator.setBasePath(getOperation().getRelativeToDirectory()); } return defaultSVNDiffGenerator; } } }
private String getCharset(String charset, DefaultSVNDiffGenerator generator, boolean allowNative) { if (charset == null) { return null; } if (allowNative && SVNProperty.NATIVE.equals(charset)) { return generator.getEncoding(); } if (Charset.isSupported(charset)) { return charset; } return null; }
public void displayFileDiff(String path, File file1, File file2, String rev1, String rev2, String mimeType1, String mimeType2, OutputStream result) throws SVNException { CountingOutputStream counitngStream = new CountingOutputStream(result, 0); super.displayFileDiff(path, file1, file2, rev1, rev2, mimeType1, mimeType2, counitngStream); if (counitngStream.getPosition() > 0) { try { result.write(getEOL()); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage()); SVNErrorManager.error(err, e, SVNLogType.DEFAULT); } } setDiffWritten(counitngStream.getPosition() > 0); }
protected String getDisplayPath(String path) throws SVNException { if (myBasePath == null) { return path; } if (path == null) { path = ""; } if (SVNPathUtil.isURL(path)) { return path; } // treat as file path. String basePath = myBasePath.getAbsolutePath().replace(File.separatorChar, '/'); path = new File(path).getAbsolutePath().replace(File.separatorChar, '/'); if (path.equals(basePath)) { return "."; } String relativePath = SVNPathUtil.getPathAsChild(basePath, path); if (relativePath == null) { if (myIsUseAbsolutePaths) { return path; } createBadRelativePathError(path); } if (relativePath.startsWith("./")) { relativePath = relativePath.substring("./".length()); } return relativePath; }
path = getDisplayPath(path); String label1 = getLabel(p1, rev1); String label2 = getLabel(p2, rev2); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { if (displayHeader(bos, path, file2 == null)) { bos.close(); bos.writeTo(result); return; if (isHeaderForced(file1, file2)) { bos.writeTo(result); bos.reset(); if (!isForcedBinaryDiff() && (SVNProperty.isBinaryMimeType(mimeType1) || SVNProperty.isBinaryMimeType(mimeType2))) { try { displayBinary(bos, mimeType1, mimeType2); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage()); final String diffCommand = getExternalDiffCommand(); if (diffCommand != null) { try { args.addAll(myRawDiffOptions); } else { Collection diffOptions = getDiffOptions().toOptionsCollection(); args.addAll(diffOptions);
path = getDisplayPath(path); ByteArrayOutputStream bos = new ByteArrayOutputStream(); diff = new SVNProperties(diff); try { bos.write(getEOL()); bos.write(("Property changes on: " + (useLocalFileSeparatorChar() ? path.replace('/', File.separatorChar) : path)).getBytes(getEncoding())); bos.write(getEOL()); bos.write(PROPERTIES_SEPARATOR.getBytes(getEncoding())); bos.write(getEOL()); for (Iterator changedPropNames = diff.nameSet().iterator(); changedPropNames.hasNext();) { String name = (String) changedPropNames.next(); bos.write((headerFormat + name).getBytes(getEncoding())); bos.write(getEOL()); if (SVNProperty.MERGE_INFO.equals(name)) { displayMergeInfoDiff(bos, originalValue == null ? null : originalValue.getString(), newValue == null ? null : newValue.getString()); continue; bos.write(" - ".getBytes(getEncoding())); bos.write(getPropertyAsBytes(originalValue, getEncoding())); bos.write(getEOL()); bos.write(" + ".getBytes(getEncoding())); bos.write(getPropertyAsBytes(newValue, getEncoding())); bos.write(getEOL()); bos.write(getEOL()); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage());
/** * Returns the diff driver being in use. * * <p> * If no specific diff driver was previously provided, a default one * will be returned (see {@link DefaultSVNDiffGenerator}). * * @return the diff driver being in use * @see #setDiffGenerator(ISVNDiffGenerator) */ public ISVNDiffGenerator getDiffGenerator() { if (myDiffGenerator == null) { DefaultSVNDiffGenerator defaultDiffGenerator = new DefaultSVNDiffGenerator(); defaultDiffGenerator.setOptions(getOptions()); myDiffGenerator = defaultDiffGenerator; } return myDiffGenerator; }
private String getCharset(String charset, DefaultSVNDiffGenerator generator, boolean allowNative) { if (charset == null) { return null; } if (allowNative && SVNProperty.NATIVE.equals(charset)) { return generator.getEncoding(); } if (Charset.isSupported(charset)) { return charset; } return null; }
public void displayFileDiff(String path, File file1, File file2, String rev1, String rev2, String mimeType1, String mimeType2, OutputStream result) throws SVNException { CountingOutputStream counitngStream = new CountingOutputStream(result, 0); super.displayFileDiff(path, file1, file2, rev1, rev2, mimeType1, mimeType2, counitngStream); if (counitngStream.getPosition() > 0) { try { result.write(getEOL()); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage()); SVNErrorManager.error(err, e, SVNLogType.DEFAULT); } } setDiffWritten(counitngStream.getPosition() > 0); }
protected String getDisplayPath(String path) throws SVNException { if (myBasePath == null) { return path; } if (path == null) { path = ""; } if (SVNPathUtil.isURL(path)) { return path; } // treat as file path. String basePath = myBasePath.getAbsolutePath().replace(File.separatorChar, '/'); path = new File(path).getAbsolutePath().replace(File.separatorChar, '/'); if (path.equals(basePath)) { return "."; } String relativePath = SVNPathUtil.getPathAsChild(basePath, path); if (relativePath == null) { if (myIsUseAbsolutePaths) { return path; } createBadRelativePathError(path); } if (relativePath.startsWith("./")) { relativePath = relativePath.substring("./".length()); } return relativePath; }
path = getDisplayPath(path); String label1 = getLabel(p1, rev1); String label2 = getLabel(p2, rev2); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { if (displayHeader(bos, path, file2 == null)) { bos.close(); bos.writeTo(result); return; if (isHeaderForced(file1, file2)) { bos.writeTo(result); bos.reset(); if (!isForcedBinaryDiff() && (SVNProperty.isBinaryMimeType(mimeType1) || SVNProperty.isBinaryMimeType(mimeType2))) { try { displayBinary(bos, mimeType1, mimeType2); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage()); final String diffCommand = getExternalDiffCommand(); if (diffCommand != null) { try { args.addAll(myRawDiffOptions); } else { Collection diffOptions = getDiffOptions().toOptionsCollection(); args.addAll(diffOptions);