tikhomirov@17: /* tikhomirov@72: * Copyright (c) 2010-2011 TMate Software Ltd tikhomirov@72: * tikhomirov@72: * This program is free software; you can redistribute it and/or modify tikhomirov@72: * it under the terms of the GNU General Public License as published by tikhomirov@72: * the Free Software Foundation; version 2 of the License. tikhomirov@72: * tikhomirov@72: * This program is distributed in the hope that it will be useful, tikhomirov@72: * but WITHOUT ANY WARRANTY; without even the implied warranty of tikhomirov@72: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the tikhomirov@72: * GNU General Public License for more details. tikhomirov@72: * tikhomirov@72: * For information on how to redistribute this software under tikhomirov@72: * the terms of a license other than GNU General Public License tikhomirov@72: * contact TMate Software at support@svnkit.com tikhomirov@1: */ tikhomirov@72: package org.tmatesoft.hg.console; tikhomirov@1: tikhomirov@74: import org.tmatesoft.hg.internal.DigestHelper; tikhomirov@74: import org.tmatesoft.hg.repo.HgDataFile; tikhomirov@74: import org.tmatesoft.hg.repo.HgRepository; tikhomirov@96: import org.tmatesoft.hg.repo.HgInternals; tikhomirov@74: tikhomirov@1: tikhomirov@1: /** tikhomirov@72: * @author Artem Tikhomirov tikhomirov@72: * @author TMate Software Ltd. tikhomirov@1: */ tikhomirov@1: public class Cat { tikhomirov@1: tikhomirov@1: public static void main(String[] args) throws Exception { tikhomirov@74: Options cmdLineOpts = Options.parse(args); tikhomirov@74: HgRepository hgRepo = cmdLineOpts.findRepository(); tikhomirov@1: if (hgRepo.isInvalid()) { tikhomirov@1: System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); tikhomirov@1: return; tikhomirov@1: } tikhomirov@96: HgInternals debug = new HgInternals(hgRepo); tikhomirov@59: String[] toCheck = new String[] {"design.txt", "src/com/tmate/hgkit/ll/Changelog.java", "src/Extras.java", "bin/com/tmate/hgkit/ll/Changelog.class"}; tikhomirov@59: boolean[] checkResult = debug.checkIgnored(toCheck); tikhomirov@59: for (int i = 0; i < toCheck.length; i++) { tikhomirov@59: System.out.println("Ignored " + toCheck[i] + ": " + checkResult[i]); tikhomirov@17: } tikhomirov@17: DigestHelper dh = new DigestHelper(); tikhomirov@5: for (String fname : cmdLineOpts.files) { tikhomirov@5: System.out.println(fname); tikhomirov@5: HgDataFile fn = hgRepo.getFileNode(fname); tikhomirov@5: if (fn.exists()) { tikhomirov@5: int total = fn.getRevisionCount(); tikhomirov@5: System.out.printf("Total revisions: %d\n", total); tikhomirov@5: for (int i = 0; i < total; i++) { tikhomirov@5: byte[] content = fn.content(i); tikhomirov@5: System.out.println("==========>"); tikhomirov@5: System.out.println(new String(content)); tikhomirov@17: int[] parentRevisions = new int[2]; tikhomirov@17: byte[] parent1 = new byte[20]; tikhomirov@17: byte[] parent2 = new byte[20]; tikhomirov@17: fn.parents(i, parentRevisions, parent1, parent2); tikhomirov@42: System.out.println(dh.sha1(parent1, parent2, content).asHexString()); tikhomirov@5: } tikhomirov@5: } else { tikhomirov@5: System.out.println(">>>Not found!"); tikhomirov@5: } tikhomirov@5: } tikhomirov@1: } tikhomirov@1: }