# HG changeset patch # User Artem Tikhomirov # Date 1292815252 -3600 # Node ID aa1912c70b36fa4b46f990f798415d532c736bb7 # Parent 24bb4f365164e89ef2319d1bd344299a1f616a23 Fix offset issue for inline revlogs. Commandline processing. diff -r 24bb4f365164 -r aa1912c70b36 design.txt --- a/design.txt Mon Dec 20 02:50:36 2010 +0100 +++ b/design.txt Mon Dec 20 04:20:52 2010 +0100 @@ -16,4 +16,12 @@ Revlog -What happens when big entry is added to a file - when it detects it can't longer fit into .i and needs .d? Inline flag and .i format changes? \ No newline at end of file +What happens when big entry is added to a file - when it detects it can't longer fit into .i and needs .d? Inline flag and .i format changes? + + +---------- +support patch from baseRev + few deltas ++ command-line samples (-R, filenames) (Log & Cat) to show on any repo + +input stream impl + lifecycle +delta merge diff -r 24bb4f365164 -r aa1912c70b36 src/com/tmate/hgkit/console/Log.java --- a/src/com/tmate/hgkit/console/Log.java Mon Dec 20 02:50:36 2010 +0100 +++ b/src/com/tmate/hgkit/console/Log.java Mon Dec 20 04:20:52 2010 +0100 @@ -15,7 +15,8 @@ public static void main(String[] args) throws Exception { RepositoryLookup repoLookup = new RepositoryLookup(); - HgRepository hgRepo = repoLookup.detect(args); + RepositoryLookup.Options cmdLineOpts = RepositoryLookup.Options.parse(args); + HgRepository hgRepo = repoLookup.detect(cmdLineOpts); if (hgRepo.isInvalid()) { System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); return; @@ -28,13 +29,15 @@ cset.dump(); } }; - HgDataFile f1 = hgRepo.getFileNode("hello.c"); - System.out.println("Complete of a file:"); - f1.history(callback); + for (String fname : cmdLineOpts.files) { + HgDataFile f1 = hgRepo.getFileNode(fname); + System.out.println("\nComplete of a 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:"); diff -r 24bb4f365164 -r aa1912c70b36 src/com/tmate/hgkit/console/Main.java --- a/src/com/tmate/hgkit/console/Main.java Mon Dec 20 02:50:36 2010 +0100 +++ b/src/com/tmate/hgkit/console/Main.java Mon Dec 20 04:20:52 2010 +0100 @@ -18,8 +18,9 @@ public class Main { public static void main(String[] args) throws Exception { - //String filename = "store/00changelog.i"; - String filename = "store/data/hello.c.i"; + String filename = "store/00changelog.i"; + //String filename = "store/data/hello.c.i"; +// String filename = "store/data/docs/readme.i"; LinkedList changelog = new LinkedList(); // DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(new File("/temp/hg/hello/.hg/" + filename)))); diff -r 24bb4f365164 -r aa1912c70b36 src/com/tmate/hgkit/fs/RepositoryLookup.java --- a/src/com/tmate/hgkit/fs/RepositoryLookup.java Mon Dec 20 02:50:36 2010 +0100 +++ b/src/com/tmate/hgkit/fs/RepositoryLookup.java Mon Dec 20 04:20:52 2010 +0100 @@ -4,6 +4,12 @@ package com.tmate.hgkit.fs; import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; import com.tmate.hgkit.ll.HgRepository; import com.tmate.hgkit.ll.LocalHgRepo; @@ -12,12 +18,16 @@ * @author artem */ public class RepositoryLookup { - + + public HgRepository detect(Options opts) throws Exception { + if (opts.repoLocation != null) { + return detect(opts.repoLocation); + } + return detectFromWorkingDir(); + } + public HgRepository detect(String[] commandLineArgs) throws Exception { - if (commandLineArgs.length == 0) { - return detectFromWorkingDir(); - } - return detect(commandLineArgs[0]); + return detect(Options.parse(commandLineArgs)); } public HgRepository detectFromWorkingDir() throws Exception { @@ -41,4 +51,43 @@ } return new LocalHgRepo(repository); } + + public static class Options { + + public String repoLocation; + public List files; + + public static Options parse(String[] commandLineArgs) { + Options rv = new Options(); + List args = Arrays.asList(commandLineArgs); + LinkedList files = new LinkedList(); + for (Iterator it = args.iterator(); it.hasNext(); ) { + String arg = it.next(); + if (arg.charAt(0) == '-') { + // option + if (arg.length() == 1) { + throw new IllegalArgumentException("Bad option: -"); + } + switch ((int) arg.charAt(1)) { + case (int) 'R' : { + if (! it.hasNext()) { + throw new IllegalArgumentException("Need repo location"); + } + rv.repoLocation = it.next(); + break; + } + } + } else { + // filename + files.add(arg); + } + } + if (!files.isEmpty()) { + rv.files = new ArrayList(files); + } else { + rv.files = Collections.emptyList(); + } + return rv; + } + } } diff -r 24bb4f365164 -r aa1912c70b36 src/com/tmate/hgkit/ll/RevlogStream.java --- a/src/com/tmate/hgkit/ll/RevlogStream.java Mon Dec 20 02:50:36 2010 +0100 +++ b/src/com/tmate/hgkit/ll/RevlogStream.java Mon Dec 20 04:20:52 2010 +0100 @@ -91,7 +91,7 @@ diData = getDataStream(); } try { - diIndex.skipBytes(inline ? (int) index.get(start).offset : start * 64); + int skipped = diIndex.skipBytes(inline ? (int) index.get(start).offset : start * 64); byte[] lastData = null; for (int i = start; i <= end; i++ ) { IndexEntry ie = index.get(i); @@ -203,10 +203,11 @@ // int parent1Revision = di.readInt(); // int parent2Revision = di.readInt(); // byte[] nodeid = new byte[32]; - res.add(new IndexEntry(offset, compressedLen)); if (inline) { + res.add(new IndexEntry(offset + 64*res.size(), compressedLen)); di.skipBytes(5*4 + 32 + compressedLen); // Check: 52 (skip) + 12 (read) = 64 (total RevlogNG record size) } else { + res.add(new IndexEntry(offset, compressedLen)); di.skipBytes(5*4 + 32); } long l = di.readLong(); @@ -241,7 +242,7 @@ // perhaps, package-local or protected, if anyone else from low-level needs them private static class IndexEntry { - public final long offset; + public final long offset; // for separate .i and .d - copy of index record entry, for inline index - actual offset of the record in the .i file (record entry + revision * record size)) public final int length; // data past fixed record (need to decide whether including header size or not), and whether length is of compressed data or not public IndexEntry(long o, int l) {