comparison cmdline/org/tmatesoft/hg/console/Main.java @ 239:df9d2854d3d6

Initial access to subrepositories
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 16 Jun 2011 04:23:51 +0200
parents 6e1373b54e9b
children ad6a046943be
comparison
equal deleted inserted replaced
238:4817d4ccc50e 239:df9d2854d3d6
39 import org.tmatesoft.hg.repo.HgManifest; 39 import org.tmatesoft.hg.repo.HgManifest;
40 import org.tmatesoft.hg.repo.HgMergeState; 40 import org.tmatesoft.hg.repo.HgMergeState;
41 import org.tmatesoft.hg.repo.HgRepository; 41 import org.tmatesoft.hg.repo.HgRepository;
42 import org.tmatesoft.hg.repo.HgStatusCollector; 42 import org.tmatesoft.hg.repo.HgStatusCollector;
43 import org.tmatesoft.hg.repo.HgStatusInspector; 43 import org.tmatesoft.hg.repo.HgStatusInspector;
44 import org.tmatesoft.hg.repo.HgSubrepoLocation;
45 import org.tmatesoft.hg.repo.HgSubrepoLocation.Kind;
44 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector; 46 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector;
45 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; 47 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
46 import org.tmatesoft.hg.util.Pair; 48 import org.tmatesoft.hg.util.Pair;
47 import org.tmatesoft.hg.util.Path; 49 import org.tmatesoft.hg.util.Path;
48 import org.tmatesoft.hg.util.ProgressSupport; 50 import org.tmatesoft.hg.util.ProgressSupport;
68 System.out.println("REPO:" + hgRepo.getLocation()); 70 System.out.println("REPO:" + hgRepo.getLocation());
69 } 71 }
70 72
71 public static void main(String[] args) throws Exception { 73 public static void main(String[] args) throws Exception {
72 Main m = new Main(args); 74 Main m = new Main(args);
73 m.testReadWorkingCopy(); 75 m.testSubrepos();
76 // m.testReadWorkingCopy();
74 // m.testParents(); 77 // m.testParents();
75 // m.testEffectiveFileLog(); 78 // m.testEffectiveFileLog();
76 // m.testCatAtCsetRevision(); 79 // m.testCatAtCsetRevision();
77 // m.testMergeState(); 80 // m.testMergeState();
78 // m.testFileStatus(); 81 // m.testFileStatus();
84 // m.catCompleteHistory(); 87 // m.catCompleteHistory();
85 // m.dumpCompleteManifestLow(); 88 // m.dumpCompleteManifestLow();
86 // m.dumpCompleteManifestHigh(); 89 // m.dumpCompleteManifestHigh();
87 // m.bunchOfTests(); 90 // m.bunchOfTests();
88 } 91 }
89 92
93 private void testSubrepos() throws Exception {
94 for (HgSubrepoLocation l : hgRepo.getSubrepositories()) {
95 System.out.println(l.getLocation());
96 System.out.println(l.getSource());
97 System.out.println(l.getType());
98 System.out.println(l.isCommitted() ? l.getRevision() : "not yet committed");
99 if (l.getType() == Kind.Hg) {
100 HgRepository r = l.getRepo();
101 System.out.printf("%s has %d revisions\n", l.getLocation(), r.getChangelog().getLastRevision() + 1);
102 if (r.getChangelog().getLastRevision() >= 0) {
103 final RawChangeset c = r.getChangelog().range(TIP, TIP).get(0);
104 System.out.printf("TIP: %s %s %s\n", c.user(), c.dateString(), c.comment());
105 }
106 }
107 }
108 }
109
90 private void testReadWorkingCopy() throws Exception { 110 private void testReadWorkingCopy() throws Exception {
91 for (String fname : cmdLineOpts.getList("")) { 111 for (String fname : cmdLineOpts.getList("")) {
92 HgDataFile fn = hgRepo.getFileNode(fname); 112 HgDataFile fn = hgRepo.getFileNode(fname);
93 ByteArrayChannel sink = new ByteArrayChannel(); 113 ByteArrayChannel sink = new ByteArrayChannel();
94 fn.workingCopy(sink); 114 fn.workingCopy(sink);