Mercurial > hg4j
comparison src/com/tmate/hgkit/console/Cat.java @ 5:fc265ddeab26
File content and non-effective, although working, patch application
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Tue, 21 Dec 2010 05:11:06 +0100 |
| parents | 24bb4f365164 |
| children | 571e1b2cc3f7 |
comparison
equal
deleted
inserted
replaced
| 4:aa1912c70b36 | 5:fc265ddeab26 |
|---|---|
| 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.HgDataFile; | |
| 7 import com.tmate.hgkit.ll.HgRepository; | 8 import com.tmate.hgkit.ll.HgRepository; |
| 8 | 9 |
| 9 /** | 10 /** |
| 10 * @author artem | 11 * @author artem |
| 11 * | 12 * |
| 12 */ | 13 */ |
| 13 public class Cat { | 14 public class Cat { |
| 14 | 15 |
| 15 public static void main(String[] args) throws Exception { | 16 public static void main(String[] args) throws Exception { |
| 16 RepositoryLookup repoLookup = new RepositoryLookup(); | 17 RepositoryLookup repoLookup = new RepositoryLookup(); |
| 17 HgRepository hgRepo = repoLookup.detect(args); | 18 RepositoryLookup.Options cmdLineOpts = RepositoryLookup.Options.parse(args); |
| 19 HgRepository hgRepo = repoLookup.detect(cmdLineOpts); | |
| 18 if (hgRepo.isInvalid()) { | 20 if (hgRepo.isInvalid()) { |
| 19 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); | 21 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); |
| 20 return; | 22 return; |
| 21 } | 23 } |
| 22 byte[] tipContent = hgRepo.getFileNode("hello.c").content(); | 24 for (String fname : cmdLineOpts.files) { |
| 23 System.out.println(new String(tipContent)); | 25 System.out.println(fname); |
| 26 HgDataFile fn = hgRepo.getFileNode(fname); | |
| 27 if (fn.exists()) { | |
| 28 int total = fn.getRevisionCount(); | |
| 29 System.out.printf("Total revisions: %d\n", total); | |
| 30 for (int i = 0; i < total; i++) { | |
| 31 byte[] content = fn.content(i); | |
| 32 System.out.println("==========>"); | |
| 33 System.out.println(new String(content)); | |
| 34 } | |
| 35 } else { | |
| 36 System.out.println(">>>Not found!"); | |
| 37 } | |
| 38 } | |
| 24 } | 39 } |
| 25 } | 40 } |
