Permalink
Browse files

Added "list" option in DeltaZipCLI's usage message; misc. test printing.

  • Loading branch information...
1 parent 65c5291 commit a830d0e9e207988d9954e72fb77d251de06a6104 @esstrifork esstrifork committed Jul 8, 2011
@@ -185,8 +185,10 @@ protected void goto_previous_position_and_compute_current_version() throws IOExc
// Verify checksum:
int actual_adler32 = DZUtil.computeAdler32(version);
- if (actual_adler32 != adler32)
+ if (actual_adler32 != adler32) {
+ dump("checksumming failed: "+actual_adler32+" rather than "+adler32, version);
throw new IOException("Data error - checksum mismatch @ "+start_pos+": stored is "+adler32+" but computed is "+actual_adler32);
+ }
// Commit:
this.current_pos = start_pos;
@@ -196,6 +198,15 @@ protected void goto_previous_position_and_compute_current_version() throws IOExc
this.exposed_current_version = ByteBuffer.wrap(current_version).asReadOnlyBuffer();
this.current_checksum = actual_adler32;
}
+ public static void dump(String s, byte[] buf) {
+ System.err.print(s);
+ System.err.print("<<");
+ for (int i=0; i<buf.length; i++) {
+ if (i>0) System.err.print(",");
+ System.err.print(buf[i] & 0xff);
+ }
+ System.err.println(">>");
+ }
protected byte[] compute_current_version(int method, ByteBuffer data_buf, long pos) throws IOException {
CompressionMethod cm = COMPRESSION_METHODS[method];
@@ -30,6 +30,7 @@ public static void usage() {
System.err.println(" get [dzfile] Print the last version");
System.err.println(" get @n [dzfile] Print the nth-last version");
System.err.println(" count [dzfile] Count the number of versions");
+ System.err.println(" list [dzfile] List versions and their statistics");
System.err.println(" add [dzfile] [version-files]");
}
@@ -45,7 +45,9 @@ public void test_read_known() throws Exception {
ByteBuffer exp_rev1 = ByteBuffer.wrap("Hello, World!".getBytes("ISO-8859-1"));
ByteBuffer exp_rev2 = ByteBuffer.wrap("Hello".getBytes("ISO-8859-1"));
+ System.err.println("two_revs 1...");
test_two_revs_with(two_revs1, exp_rev1, exp_rev2);
+ System.err.println("two_revs 2...");
test_two_revs_with(two_revs2, exp_rev1, exp_rev2);
}
@@ -66,6 +68,7 @@ public void test_two_revs_with(byte[] file, ByteBuffer exp_rev1, ByteBuffer exp_
@Test
public void test_add_get() throws Exception {
+ System.err.println("test_add_get...");
ByteBuffer rev1 = ByteBuffer.wrap("Hello".getBytes("ISO-8859-1"));
ByteBuffer rev1a = ByteBuffer.wrap("World!".getBytes("ISO-8859-1"));
ByteBuffer rev1b = ByteBuffer.wrap("Held!".getBytes("ISO-8859-1"));

0 comments on commit a830d0e

Please sign in to comment.