Mercurial > hg4j
comparison cmdline/org/tmatesoft/hg/console/Manifest.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/Manifest.java@19e9e220bf68 |
| 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 static com.tmate.hgkit.ll.HgRepository.TIP; | |
| 20 | |
| 21 import org.tmatesoft.hg.core.Path; | |
| 22 import org.tmatesoft.hg.core.RepositoryTreeWalker; | |
| 23 import org.tmatesoft.hg.core.LogCommand.FileRevision; | |
| 24 | |
| 25 import com.tmate.hgkit.fs.RepositoryLookup; | |
| 26 import com.tmate.hgkit.ll.HgManifest; | |
| 27 import com.tmate.hgkit.ll.HgRepository; | |
| 28 import com.tmate.hgkit.ll.Nodeid; | |
| 29 | |
| 30 /** | |
| 31 * | |
| 32 * @author Artem Tikhomirov | |
| 33 * @author TMate Software Ltd. | |
| 34 */ | |
| 35 public class Manifest { | |
| 36 | |
| 37 public static void main(String[] args) throws Exception { | |
| 38 RepositoryLookup repoLookup = new RepositoryLookup(); | |
| 39 RepositoryLookup.Options cmdLineOpts = RepositoryLookup.Options.parse(args); | |
| 40 HgRepository hgRepo = repoLookup.detect(cmdLineOpts); | |
| 41 if (hgRepo.isInvalid()) { | |
| 42 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); | |
| 43 return; | |
| 44 } | |
| 45 System.out.println(hgRepo.getLocation()); | |
| 46 hgRepo.getManifest().walk(0, TIP, new Dump()); | |
| 47 // | |
| 48 new RepositoryTreeWalker(hgRepo).dirs(true).walk(new RepositoryTreeWalker.Handler() { | |
| 49 | |
| 50 public void begin(Nodeid manifestRevision) { | |
| 51 System.out.println(">> " + manifestRevision); | |
| 52 } | |
| 53 public void dir(Path p) { | |
| 54 System.out.println(p); | |
| 55 } | |
| 56 public void file(FileRevision fileRevision) { | |
| 57 System.out.print(fileRevision.getRevision());; | |
| 58 System.out.print(" "); | |
| 59 System.out.println(fileRevision.getPath()); | |
| 60 } | |
| 61 | |
| 62 public void end(Nodeid manifestRevision) { | |
| 63 System.out.println(); | |
| 64 } | |
| 65 }); | |
| 66 } | |
| 67 | |
| 68 public static final class Dump implements HgManifest.Inspector { | |
| 69 public boolean begin(int revision, Nodeid nid) { | |
| 70 System.out.printf("%d : %s\n", revision, nid); | |
| 71 return true; | |
| 72 } | |
| 73 | |
| 74 public boolean next(Nodeid nid, String fname, String flags) { | |
| 75 System.out.println(nid + "\t" + fname + "\t\t" + flags); | |
| 76 return true; | |
| 77 } | |
| 78 | |
| 79 public boolean end(int revision) { | |
| 80 System.out.println(); | |
| 81 return true; | |
| 82 } | |
| 83 } | |
| 84 } |
