Merge branch 'develop' into feature/lookup_api

This commit is contained in:
Eduard Heimbuch
2020-11-10 08:39:48 +01:00
222 changed files with 19893 additions and 3482 deletions

View File

@@ -198,7 +198,7 @@ public final class SvnUtil
Person.toPerson(entry.getAuthor()),
entry.getMessage());
if (revision > 0)
if (revision > 1)
{
changeset.getParents().add(String.valueOf(revision - 1));
}
@@ -232,6 +232,7 @@ public final class SvnUtil
*
* @return
*/
@SuppressWarnings("java:S1149") // we can not use StringBuild SVNXMLUtil requires StringBuffer
public static String createErrorBody(SVNErrorCode errorCode)
{
StringBuffer xmlBuffer = new StringBuffer();

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import de.regnis.q.sequence.line.diff.QDiffGenerator;
@@ -56,6 +56,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.util.ArrayList;
@@ -344,16 +345,17 @@ public class SCMSvnDiffGenerator implements ISvnDiffGenerator {
String label1 = getLabel(newTargetString1, revision1);
String label2 = getLabel(newTargetString2, revision2);
boolean shouldStopDisplaying = displayHeader(outputStream, displayPath, false, fallbackToAbsolutePath, SvnDiffCallback.OperationKind.Modified);
visitedPaths.add(displayPath);
if (useGitFormat) {
displayGitDiffHeader(outputStream, SvnDiffCallback.OperationKind.Modified,
getRelativeToRootPath(target, originalTarget1),
getRelativeToRootPath(target, originalTarget2),
null);
}
if (shouldStopDisplaying) {
return;
} else {
boolean shouldStopDisplaying = displayHeader(outputStream, displayPath, false, fallbackToAbsolutePath, SvnDiffCallback.OperationKind.Modified);
if (shouldStopDisplaying) {
return;
}
}
// if (useGitFormat) {
@@ -374,9 +376,74 @@ public class SCMSvnDiffGenerator implements ISvnDiffGenerator {
}
}
displayPropertyChangesOn(useGitFormat ? getRelativeToRootPath(target, originalTarget1) : displayPath, outputStream);
if (useGitFormat) {
displayGitPropDiffValues(outputStream, propChanges, originalProps);
} else {
displayPropertyChangesOn(displayPath, outputStream);
displayPropDiffValues(outputStream, propChanges, originalProps);
}
}
private void displayGitPropDiffValues(OutputStream outputStream, SVNProperties diff, SVNProperties baseProps) throws SVNException {
for (Iterator changedPropNames = diff.nameSet().iterator(); changedPropNames.hasNext(); ) {
String name = (String) changedPropNames.next();
SVNPropertyValue originalValue = baseProps != null ? baseProps.getSVNPropertyValue(name) : null;
SVNPropertyValue newValue = diff.getSVNPropertyValue(name);
try {
byte[] originalValueBytes = getPropertyAsBytes(originalValue, getEncoding(), true);
byte[] newValueBytes = getPropertyAsBytes(newValue, getEncoding(), true);
if (originalValueBytes == null) {
originalValueBytes = new byte[0];
} else {
originalValueBytes = maybeAppendEOL(originalValueBytes);
}
boolean newValueHadEol = newValueBytes != null && newValueBytes.length > 0 &&
(newValueBytes[newValueBytes.length - 1] == SVNProperty.EOL_CR_BYTES[0] ||
newValueBytes[newValueBytes.length - 1] == SVNProperty.EOL_LF_BYTES[0]);
if (newValueBytes == null) {
newValueBytes = new byte[0];
} else {
newValueBytes = maybeAppendEOL(newValueBytes);
}
QDiffUniGenerator.setup();
Map properties = new SVNHashMap();
properties.put(QDiffGeneratorFactory.IGNORE_EOL_PROPERTY, Boolean.valueOf(getDiffOptions().isIgnoreEOLStyle()));
properties.put(QDiffGeneratorFactory.EOL_PROPERTY, new String(getEOL()));
properties.put(QDiffGeneratorFactory.HUNK_DELIMITER, "@@");
if (getDiffOptions().isIgnoreAllWhitespace()) {
properties.put(QDiffGeneratorFactory.IGNORE_SPACE_PROPERTY, QDiffGeneratorFactory.IGNORE_ALL_SPACE);
} else if (getDiffOptions().isIgnoreAmountOfWhitespace()) {
properties.put(QDiffGeneratorFactory.IGNORE_SPACE_PROPERTY, QDiffGeneratorFactory.IGNORE_SPACE_CHANGE);
}
QDiffGenerator generator = new QDiffUniGenerator(properties, "");
StringWriter writer = new StringWriter();
QDiffManager.generateTextDiff(new ByteArrayInputStream(originalValueBytes), new ByteArrayInputStream(newValueBytes),
null, writer, generator);
writer.flush();
String lines[] = writer.toString().split("\\r?\\n");
displayString(outputStream, lines[0] + "\n");
displayString(outputStream, " # property " + name + " has changed\n");
for (int i=1; i< lines.length; i++) {
displayString(outputStream, lines[i] + "\n");
}
if (!newValueHadEol) {
displayString(outputStream, "\\ No newline at end of property");
displayEOL(outputStream);
}
} catch (IOException e) {
wrapException(e);
}
}
displayPropDiffValues(outputStream, propChanges, originalProps);
}
private void throwBadRelativePathException(String displayPath, String relativeToPath) throws SVNException {
@@ -1123,6 +1190,10 @@ public class SCMSvnDiffGenerator implements ISvnDiffGenerator {
}
private byte[] getPropertyAsBytes(SVNPropertyValue value, String encoding) {
return getPropertyAsBytes(value, encoding, false);
}
private byte[] getPropertyAsBytes(SVNPropertyValue value, String encoding, boolean replaceBinary) {
if (value == null) {
return null;
}
@@ -1133,7 +1204,11 @@ public class SCMSvnDiffGenerator implements ISvnDiffGenerator {
return value.getString().getBytes();
}
}
return value.getBytes();
if (replaceBinary) {
return String.format("Binary value (%s bytes)", value.getBytes().length).getBytes();
} else {
return value.getBytes();
}
}
private void displayMergeInfoDiff(OutputStream outputStream, String oldValue, String newValue) throws SVNException, IOException {

View File

@@ -26,6 +26,7 @@ package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import org.slf4j.Logger;
@@ -76,6 +77,7 @@ public class SvnLogCommand extends AbstractSvnCommand implements LogCommand
try
{
long revisioNumber = parseRevision(revision, repository);
Preconditions.checkArgument(revisioNumber > 0, "revision must be greater than zero: %d", revisioNumber);
SVNRepository repo = open();
Collection<SVNLogEntry> entries = repo.log(null, null, revisioNumber,
revisioNumber, true, true);

View File

@@ -49,13 +49,13 @@ public final class SvnUserAgentProvider implements UserAgentProvider
/** TortoiseSVN */
@VisibleForTesting
static final UserAgent TORTOISE_SVN =
UserAgent.builder("TortoiseSVN").browser(false)
UserAgent.scmClient("TortoiseSVN")
.basicAuthenticationCharset(Charsets.UTF_8).build();
/** Subversion cli client */
@VisibleForTesting
static final UserAgent SVN =
UserAgent.builder("Subversion").browser(false)
UserAgent.scmClient("Subversion")
.basicAuthenticationCharset(Charsets.UTF_8).build();
//~--- methods --------------------------------------------------------------