changeset 6:5abe5af181bd

Ant script to build commands and run sample
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 22 Dec 2010 03:33:37 +0100
parents fc265ddeab26
children 286d221f6c28
files .hgignore build.xml design.txt src/com/tmate/hgkit/console/Log.java src/com/tmate/hgkit/ll/RevlogStream.java
diffstat 5 files changed, 47 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Tue Dec 21 05:11:06 2010 +0100
+++ b/.hgignore	Wed Dec 22 03:33:37 2010 +0100
@@ -1,3 +1,4 @@
 syntax:glob
 bin
 src/Extras.java
+hgkit.jar
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build.xml	Wed Dec 22 03:33:37 2010 +0100
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="hgkit" default="samples">
+    <description>
+            description
+    </description>
+
+    <target name="samples" depends="build">
+    	
+    	<echo message="History of a specific file"/>
+    	<java classpath="hgkit.jar" classname="com.tmate.hgkit.console.Log">
+    		<arg line="design.txt"/>
+    	</java>
+    	
+    	<echo message="Whole repo log"/>
+    	<java classpath="hgkit.jar" classname="com.tmate.hgkit.console.Log"/>
+    	
+    	<echo message="Content of a file"/>
+    	<java classpath="hgkit.jar" classname="com.tmate.hgkit.console.Cat">
+    		<arg line="design.txt"/>
+    	</java>
+
+    </target>
+
+    <target name="build">
+    	<javac srcdir="src" destdir="bin"/>
+    	<jar destfile="hgkit.jar" basedir="bin"/>
+    </target>
+
+</project>
--- a/design.txt	Tue Dec 21 05:11:06 2010 +0100
+++ b/design.txt	Wed Dec 22 03:33:37 2010 +0100
@@ -20,9 +20,11 @@
 
 
 ----------
-support patch from baseRev + few deltas
++ support patch from baseRev + few deltas (although done in a way patches are applied one by one instead of accumulated)
 + command-line samples (-R, filenames) (Log & Cat) to show on any repo
++buildfile + run samples
 
 input stream impl + lifecycle
 delta merge
-Changeset to get index (local revision number)
\ No newline at end of file
+Changeset to get index (local revision number)
+
--- a/src/com/tmate/hgkit/console/Log.java	Tue Dec 21 05:11:06 2010 +0100
+++ b/src/com/tmate/hgkit/console/Log.java	Wed Dec 22 03:33:37 2010 +0100
@@ -29,20 +29,21 @@
 				cset.dump();
 			}
 		};
-		for (String fname : cmdLineOpts.files) {
-			HgDataFile f1 = hgRepo.getFileNode(fname);
-			System.out.println("\nComplete of a file: " + fname);
-			f1.history(callback);
+		if (cmdLineOpts.files.isEmpty()) {
+			System.out.println("Complete history of the repo:");
+			hgRepo.getChangelog().all(callback);
+		} else {
+			for (String fname : cmdLineOpts.files) {
+				HgDataFile f1 = hgRepo.getFileNode(fname);
+				System.out.println("History of the file: " + fname);
+				f1.history(callback);
+			}
+		}
 		//
 //		System.out.println("\n\n=========================");
 //		System.out.println("Range 1-3:");
 //		f1.history(1,3, callback);
-		}
 		//
-		System.out.println("\n\n=========================");
-		System.out.println("Complete of a repo:");
-		hgRepo.getChangelog().all(callback);
 		//new ChangelogWalker().setFile("hello.c").setRevisionRange(1, 4).accept(new Visitor);
 	}
-
 }
--- a/src/com/tmate/hgkit/ll/RevlogStream.java	Tue Dec 21 05:11:06 2010 +0100
+++ b/src/com/tmate/hgkit/ll/RevlogStream.java	Wed Dec 22 03:33:37 2010 +0100
@@ -165,7 +165,7 @@
 						} while (patchElementIndex < data.length);
 						//
 						byte[] baseRevContent = lastData;
-						data = apply(baseRevContent, patches);
+						data = apply(baseRevContent, actualLen, patches);
 					}
 				} else {
 					if (inline) {
@@ -261,8 +261,8 @@
 
 	// mpatch.c : apply()
 	// FIXME need to implement patch merge (fold, combine, gather and discard from aforementioned mpatch.[c|py]), also see Revlog and Mercurial PDF
-	private static byte[] apply(byte[] baseRevisionContent, List<PatchRecord> patch) {
-		byte[] tempBuf = new byte[512]; // XXX
+	private static byte[] apply(byte[] baseRevisionContent, int outcomeLen, List<PatchRecord> patch) {
+		byte[] tempBuf = new byte[outcomeLen]; // XXX
 		int last = 0, destIndex = 0;
 		for (PatchRecord pr : patch) {
 			System.arraycopy(baseRevisionContent, last, tempBuf, destIndex, pr.start-last);