Hello Hyrum,
Am Dienstag, den 23.08.2011, 09:23 -0500 schrieb Hyrum K Wright:
> Martin,
> After discussion with some other devs on IRC (#svn-dev on Freenode,
> come and join us!),
unfortunately no way, got only browser access to the internet during
working hours
> I committed r1160705 which should expose the post
> commit error as part of the CommitInfo class in JavaHL. I've
> nominated r1160705 for 1.7.x.
Sounds great.
> Could you test it if you get the chance?
Seems to be working. A patch containing a new test with a failing
post-commit script is attached (apply with -p0 in the bindings/javahl/
dir).
Should work (at least) on win and un*xoids - I'm not sure how to create
a reliably failing cross-platform post-commit script (at least not one
with some sensible output to test against).
> -Hyrum
Thanks for the really quick fix,
Martin
--- tests/org/apache/subversion/javahl/BasicTests.java.orig 2011-08-24 19:02:28.000000000 +0200
+++ tests/org/apache/subversion/javahl/BasicTests.java 2011-08-25 21:56:09.000000000 +0200
@@ -659,6 +659,47 @@
}
/**
+ * Test handling of post-commit error messages on commit
+ * @throws Throwable
+ */
+ public void testBasicCommitWithPostCommitError() throws Throwable
+ {
+ // build the test setup
+ OneTest thisTest = new OneTest();
+
+ String postCommitErrorMessage = thisTest.createFailingPostCommit();
+
+ // modify file A/mu
+ File mu = new File(thisTest.getWorkingCopy(), "A/mu");
+ PrintWriter muWriter = new PrintWriter(new FileOutputStream(mu, true));
+ muWriter.print("appended mu text");
+ muWriter.close();
+ thisTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
+ thisTest.getWc().setItemContent("A/mu",
+ thisTest.getWc().getItemContent("A/mu") + "appended mu text");
+ addExpectedCommitItem(thisTest.getWCPath(),
+ thisTest.getUrl().toString(), "A/mu",NodeKind.file,
+ CommitItemStateFlags.TextMods);
+
+ MyCommitCallback callback = new MyCommitCallback();
+
+ client.commit(thisTest.getWCPathSet(), Depth.infinity,
+ false, false, null, null,
+ new ConstMsg("log msg"), callback);
+
+ System.out.println(callback.info.postCommitError);
+
+ assertNotNull(callback.info.postCommitError);
+ // contains (potentially localized) "(exit code 1)"
+ assertTrue(callback.info.postCommitError.contains("1)"));
+ // the message prolog may be localized, and there's a extra newline appended
+ assertTrue(callback.info.postCommitError.endsWith(postCommitErrorMessage + "\n"));
+
+ // check the status of the working copy
+ thisTest.checkStatus();
+ }
+
+ /**
* Test the basic property setting/getting functionality.
* @throws Throwable
*/
--- tests/org/apache/subversion/javahl/SVNTests.java.orig 2011-08-24 19:02:28.000000000 +0200
+++ tests/org/apache/subversion/javahl/SVNTests.java 2011-08-25 21:55:38.000000000 +0200
@@ -29,6 +29,7 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.PrintWriter;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Set;
@@ -784,6 +785,42 @@
{
return this.testName;
}
+
+ /**
+ * Create failing post-commit scripts in the current repository
+ * @return The content of the scripts' STDERR output for testing against
+ */
+ public String createFailingPostCommit() {
+ String error = "PostCommit Error";
+
+ try {
+ String path = this.repository.getAbsolutePath() + "/hooks/post-commit";
+ File postCommit = new File(path);
+ postCommit.createNewFile();
+ postCommit.setExecutable(true);
+ PrintWriter out = new PrintWriter(postCommit);
+ out.println("#!/bin/sh");
+ out.print("echo \"");
+ out.print(error);
+ out.println("\" 1>&2");
+ out.println("exit 1");
+ out.close();
+
+ String winPath = this.repository.getAbsolutePath() + "/hooks/post-commit.bat";
+ File winPostCommit = new File(winPath);
+ winPostCommit.setExecutable(true);
+ winPostCommit.createNewFile();
+ PrintWriter winOut = new PrintWriter(winPostCommit);
+ winOut.print("echo \"");
+ winOut.print(error);
+ winOut.println("\" 1>&2");
+ winOut.println("exit 1");
+ winOut.close();
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot create post-commit hook");
+ }
+ return error;
+ }
}
/**