comparison cmdline/org/tmatesoft/hg/console/Main.java @ 157:d5268ca7715b

Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 09 Mar 2011 05:22:17 +0100
parents b9700740553a
children b413b16d10a5
comparison
equal deleted inserted replaced
156:643ddec3be36 157:d5268ca7715b
24 import java.util.Map; 24 import java.util.Map;
25 25
26 import org.tmatesoft.hg.core.HgLogCommand.FileRevision; 26 import org.tmatesoft.hg.core.HgLogCommand.FileRevision;
27 import org.tmatesoft.hg.core.HgManifestCommand; 27 import org.tmatesoft.hg.core.HgManifestCommand;
28 import org.tmatesoft.hg.core.Nodeid; 28 import org.tmatesoft.hg.core.Nodeid;
29 import org.tmatesoft.hg.internal.ByteArrayChannel;
29 import org.tmatesoft.hg.internal.DigestHelper; 30 import org.tmatesoft.hg.internal.DigestHelper;
30 import org.tmatesoft.hg.repo.HgDataFile; 31 import org.tmatesoft.hg.repo.HgDataFile;
31 import org.tmatesoft.hg.repo.HgInternals; 32 import org.tmatesoft.hg.repo.HgInternals;
32 import org.tmatesoft.hg.repo.HgManifest; 33 import org.tmatesoft.hg.repo.HgManifest;
33 import org.tmatesoft.hg.repo.HgRepository; 34 import org.tmatesoft.hg.repo.HgRepository;
57 System.out.println("REPO:" + hgRepo.getLocation()); 58 System.out.println("REPO:" + hgRepo.getLocation());
58 } 59 }
59 60
60 public static void main(String[] args) throws Exception { 61 public static void main(String[] args) throws Exception {
61 Main m = new Main(args); 62 Main m = new Main(args);
62 m.dumpIgnored(); 63 m.inflaterLengthException();
63 m.dumpDirstate(); 64 // m.dumpIgnored();
64 m.testStatusInternals(); 65 // m.dumpDirstate();
65 m.catCompleteHistory(); 66 // m.testStatusInternals();
66 m.dumpCompleteManifestLow(); 67 // m.catCompleteHistory();
67 m.dumpCompleteManifestHigh(); 68 // m.dumpCompleteManifestLow();
68 m.bunchOfTests(); 69 // m.dumpCompleteManifestHigh();
70 // m.bunchOfTests();
71 }
72
73 private void inflaterLengthException() throws Exception {
74 HgDataFile f1 = hgRepo.getFileNode("src/com/tmate/hgkit/console/Bundle.java");
75 HgDataFile f2 = hgRepo.getFileNode("test-repos.jar");
76 System.out.println(f1.isCopy());
77 System.out.println(f2.isCopy());
78 ByteArrayChannel bac = new ByteArrayChannel();
79 f1.content(0, bac);
80 System.out.println(bac.toArray().length);
69 } 81 }
70 82
71 private void dumpIgnored() { 83 private void dumpIgnored() {
72 HgInternals debug = new HgInternals(hgRepo); 84 HgInternals debug = new HgInternals(hgRepo);
73 String[] toCheck = new String[] {"design.txt", "src/com/tmate/hgkit/ll/Changelog.java", "src/Extras.java", "bin/com/tmate/hgkit/ll/Changelog.class"}; 85 String[] toCheck = new String[] {"design.txt", "src/com/tmate/hgkit/ll/Changelog.java", "src/Extras.java", "bin/com/tmate/hgkit/ll/Changelog.class"};
80 private void dumpDirstate() { 92 private void dumpDirstate() {
81 new HgInternals(hgRepo).dumpDirstate(); 93 new HgInternals(hgRepo).dumpDirstate();
82 } 94 }
83 95
84 96
85 private void catCompleteHistory() { 97 private void catCompleteHistory() throws Exception {
86 DigestHelper dh = new DigestHelper(); 98 DigestHelper dh = new DigestHelper();
87 for (String fname : cmdLineOpts.getList("")) { 99 for (String fname : cmdLineOpts.getList("")) {
88 System.out.println(fname); 100 System.out.println(fname);
89 HgDataFile fn = hgRepo.getFileNode(fname); 101 HgDataFile fn = hgRepo.getFileNode(fname);
90 if (fn.exists()) { 102 if (fn.exists()) {
91 int total = fn.getRevisionCount(); 103 int total = fn.getRevisionCount();
92 System.out.printf("Total revisions: %d\n", total); 104 System.out.printf("Total revisions: %d\n", total);
93 for (int i = 0; i < total; i++) { 105 for (int i = 0; i < total; i++) {
94 byte[] content = fn.content(i); 106 ByteArrayChannel sink = new ByteArrayChannel();
107 fn.content(i, sink);
95 System.out.println("==========>"); 108 System.out.println("==========>");
109 byte[] content = sink.toArray();
96 System.out.println(new String(content)); 110 System.out.println(new String(content));
97 int[] parentRevisions = new int[2]; 111 int[] parentRevisions = new int[2];
98 byte[] parent1 = new byte[20]; 112 byte[] parent1 = new byte[20];
99 byte[] parent2 = new byte[20]; 113 byte[] parent2 = new byte[20];
100 fn.parents(i, parentRevisions, parent1, parent2); 114 fn.parents(i, parentRevisions, parent1, parent2);