Mercurial > jhg
comparison src/com/tmate/hgkit/console/Cat.java @ 17:571e1b2cc3f7
Query file for its parents. Demo of recently added ignore and digest support from within cat cmd
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 27 Dec 2010 01:43:08 +0100 |
parents | fc265ddeab26 |
children | 92c3d0920d58 |
comparison
equal
deleted
inserted
replaced
16:254078595653 | 17:571e1b2cc3f7 |
---|---|
1 /** | 1 /* |
2 * Copyright (c) 2010 Artem Tikhomirov | 2 * Copyright (c) 2010 Artem Tikhomirov |
3 */ | 3 */ |
4 package com.tmate.hgkit.console; | 4 package com.tmate.hgkit.console; |
5 | 5 |
6 import com.tmate.hgkit.fs.RepositoryLookup; | 6 import com.tmate.hgkit.fs.RepositoryLookup; |
7 import com.tmate.hgkit.ll.DigestHelper; | |
7 import com.tmate.hgkit.ll.HgDataFile; | 8 import com.tmate.hgkit.ll.HgDataFile; |
9 import com.tmate.hgkit.ll.HgIgnore; | |
8 import com.tmate.hgkit.ll.HgRepository; | 10 import com.tmate.hgkit.ll.HgRepository; |
11 import com.tmate.hgkit.ll.LocalHgRepo; | |
9 | 12 |
10 /** | 13 /** |
11 * @author artem | 14 * @author artem |
12 * | 15 * |
13 */ | 16 */ |
19 HgRepository hgRepo = repoLookup.detect(cmdLineOpts); | 22 HgRepository hgRepo = repoLookup.detect(cmdLineOpts); |
20 if (hgRepo.isInvalid()) { | 23 if (hgRepo.isInvalid()) { |
21 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); | 24 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); |
22 return; | 25 return; |
23 } | 26 } |
27 HgIgnore ignore = ((LocalHgRepo) hgRepo).loadIgnore(); | |
28 for (String s : new String[] {"design.txt", "src/com/tmate/hgkit/ll/Changelog.java", "src/Extras.java", "bin/com/tmate/hgkit/ll/Changelog.class"} ) { | |
29 System.out.println("Ignored " + s + ": " + ignore.isIgnored(s)); | |
30 } | |
31 DigestHelper dh = new DigestHelper(); | |
24 for (String fname : cmdLineOpts.files) { | 32 for (String fname : cmdLineOpts.files) { |
25 System.out.println(fname); | 33 System.out.println(fname); |
26 HgDataFile fn = hgRepo.getFileNode(fname); | 34 HgDataFile fn = hgRepo.getFileNode(fname); |
27 if (fn.exists()) { | 35 if (fn.exists()) { |
28 int total = fn.getRevisionCount(); | 36 int total = fn.getRevisionCount(); |
29 System.out.printf("Total revisions: %d\n", total); | 37 System.out.printf("Total revisions: %d\n", total); |
30 for (int i = 0; i < total; i++) { | 38 for (int i = 0; i < total; i++) { |
31 byte[] content = fn.content(i); | 39 byte[] content = fn.content(i); |
32 System.out.println("==========>"); | 40 System.out.println("==========>"); |
33 System.out.println(new String(content)); | 41 System.out.println(new String(content)); |
42 int[] parentRevisions = new int[2]; | |
43 byte[] parent1 = new byte[20]; | |
44 byte[] parent2 = new byte[20]; | |
45 fn.parents(i, parentRevisions, parent1, parent2); | |
46 System.out.println(dh.sha1(parent1, parent2, content)); | |
34 } | 47 } |
35 } else { | 48 } else { |
36 System.out.println(">>>Not found!"); | 49 System.out.println(">>>Not found!"); |
37 } | 50 } |
38 } | 51 } |