comparison cmdline/org/tmatesoft/hg/console/Cat.java @ 72:9a03a80a0f2f

Command-line frontend moved to separate source root with new package statement
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sun, 23 Jan 2011 03:46:59 +0100
parents src/com/tmate/hgkit/console/Cat.java@b771e94a4f7c
children 6f1b88693d48
comparison
equal deleted inserted replaced
71:ce6d23673f2d 72:9a03a80a0f2f
1 /*
2 * Copyright (c) 2010-2011 TMate Software Ltd
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * For information on how to redistribute this software under
14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@svnkit.com
16 */
17 package org.tmatesoft.hg.console;
18
19 import com.tmate.hgkit.fs.RepositoryLookup;
20 import com.tmate.hgkit.ll.DigestHelper;
21 import com.tmate.hgkit.ll.HgDataFile;
22 import com.tmate.hgkit.ll.HgRepository;
23 import com.tmate.hgkit.ll.Internals;
24
25 /**
26 * @author Artem Tikhomirov
27 * @author TMate Software Ltd.
28 */
29 public class Cat {
30
31 public static void main(String[] args) throws Exception {
32 RepositoryLookup repoLookup = new RepositoryLookup();
33 RepositoryLookup.Options cmdLineOpts = RepositoryLookup.Options.parse(args);
34 HgRepository hgRepo = repoLookup.detect(cmdLineOpts);
35 if (hgRepo.isInvalid()) {
36 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation());
37 return;
38 }
39 Internals debug = new Internals(hgRepo);
40 String[] toCheck = new String[] {"design.txt", "src/com/tmate/hgkit/ll/Changelog.java", "src/Extras.java", "bin/com/tmate/hgkit/ll/Changelog.class"};
41 boolean[] checkResult = debug.checkIgnored(toCheck);
42 for (int i = 0; i < toCheck.length; i++) {
43 System.out.println("Ignored " + toCheck[i] + ": " + checkResult[i]);
44 }
45 DigestHelper dh = new DigestHelper();
46 for (String fname : cmdLineOpts.files) {
47 System.out.println(fname);
48 HgDataFile fn = hgRepo.getFileNode(fname);
49 if (fn.exists()) {
50 int total = fn.getRevisionCount();
51 System.out.printf("Total revisions: %d\n", total);
52 for (int i = 0; i < total; i++) {
53 byte[] content = fn.content(i);
54 System.out.println("==========>");
55 System.out.println(new String(content));
56 int[] parentRevisions = new int[2];
57 byte[] parent1 = new byte[20];
58 byte[] parent2 = new byte[20];
59 fn.parents(i, parentRevisions, parent1, parent2);
60 System.out.println(dh.sha1(parent1, parent2, content).asHexString());
61 }
62 } else {
63 System.out.println(">>>Not found!");
64 }
65 }
66 }
67 }