Discussion:
ISVNEditor applyTextDelta Committing Unchanged Files
cgswtsu78
2014-03-03 18:43:37 UTC
Permalink
Hello,

My implementation of the SVNKit library ISVNEditor.applyTextDelta API is
committing file updates for files that are unchanged. I was under the
impression that SVN would ignore the commit if I commit the same exact file.
When I use native SVN through the command line, it does ignore the unchanged
file commit. Anyone see an issue with my implementation?

Public class SVNKit{

public void addFiles(Map<String, ByteArrayOutputStream> inputDataMap) throws
Exception {
ISVNEditor editor = null;
SVNRepository repo = null;
Set<String> filesToAdd = new TreeSet<String>();
Set<String> filesToUpdate = new TreeSet<String>();
repo = openSession();
Map<String, ByteArrayOutputStream> filesWithDirPath = new
HashMap<String, ByteArrayOutputStream>();
Iterator<Map.Entry&lt;String, ByteArrayOutputStream>> filesIterator =
inputDataMap.entrySet().iterator();

// add new files
for (String file : filesToAdd) {
editor.addFile(file, null, -1);
handleFile(editor, file, filesWithDirPath);
}

// update existing files
for (String file : filesToUpdate) {
editor.openFile(file, -1);
handleFile(editor, file, filesWithDirPathInLowerCase);
}
editor.closeEdit();

while (filesIterator.hasNext()) {
if (nodeKind == SVNNodeKind.FILE) {
filesToUpdate.add(lowerCaseFilePath);
} else if (nodeKind == SVNNodeKind.NONE) {
filesToAdd.add(lowerCaseFilePath);
} else {
throw new Exception("Unsupported SVN Node Kind: " + nodeKind);
}

}

private void handleFile(ISVNEditor editor, String file, Map<String,
ByteArrayOutputStream> data) throws SVNException {
editor.applyTextDelta(file, null);
SVNDeltaGenerator gen = new SVNDeltaGenerator();
String checksum = gen.sendDelta(file, new
ByteArrayInputStream(data.get(file).toByteArray()), editor, true);
editor.closeFile(file, checksum);
}
}



--
View this message in context: http://subversion.1072662.n5.nabble.com/ISVNEditor-applyTextDelta-Committing-Unchanged-Files-tp187500.html
Sent from the SVNKit - Users mailing list archive at Nabble.com.
Alexander Kitaev
2014-03-03 18:57:14 UTC
Permalink
Hello,

Behavior you see is expected - Subversion server does not compare received
file with the previous version, this should be done on the client side.

Native client (or SVNKit command line client) just doesn't send deltas for
unchanged files, as it keeps and uses so called pristine copy of the file
to figure out whether file in the working copy is changed.

Alexander Kitaev,
TMate Software,
http://subgit.com/ - Svn to Git Migration!
http://svnkit.com/ - Java [Sub]Versioning Library!
http://hg4j.com/ - Java Mercurial Library!
http://sqljet.com/ - Java SQLite Library!
Post by cgswtsu78
Hello,
My implementation of the SVNKit library ISVNEditor.applyTextDelta API is
committing file updates for files that are unchanged. I was under the
impression that SVN would ignore the commit if I commit the same exact file.
When I use native SVN through the command line, it does ignore the unchanged
file commit. Anyone see an issue with my implementation?
Public class SVNKit{
public void addFiles(Map<String, ByteArrayOutputStream> inputDataMap) throws
Exception {
ISVNEditor editor = null;
SVNRepository repo = null;
Set<String> filesToAdd = new TreeSet<String>();
Set<String> filesToUpdate = new TreeSet<String>();
repo = openSession();
Map<String, ByteArrayOutputStream> filesWithDirPath = new
HashMap<String, ByteArrayOutputStream>();
Iterator<Map.Entry&lt;String, ByteArrayOutputStream>> filesIterator =
inputDataMap.entrySet().iterator();
// add new files
for (String file : filesToAdd) {
editor.addFile(file, null, -1);
handleFile(editor, file, filesWithDirPath);
}
// update existing files
for (String file : filesToUpdate) {
editor.openFile(file, -1);
handleFile(editor, file, filesWithDirPathInLowerCase);
}
editor.closeEdit();
while (filesIterator.hasNext()) {
if (nodeKind == SVNNodeKind.FILE) {
filesToUpdate.add(lowerCaseFilePath);
} else if (nodeKind == SVNNodeKind.NONE) {
filesToAdd.add(lowerCaseFilePath);
} else {
throw new Exception("Unsupported SVN Node Kind: " + nodeKind);
}
}
private void handleFile(ISVNEditor editor, String file, Map<String,
ByteArrayOutputStream> data) throws SVNException {
editor.applyTextDelta(file, null);
SVNDeltaGenerator gen = new SVNDeltaGenerator();
String checksum = gen.sendDelta(file, new
ByteArrayInputStream(data.get(file).toByteArray()), editor, true);
editor.closeFile(file, checksum);
}
}
--
http://subversion.1072662.n5.nabble.com/ISVNEditor-applyTextDelta-Committing-Unchanged-Files-tp187500.html
Sent from the SVNKit - Users mailing list archive at Nabble.com.
Loading...