Mercurial > hg4j
diff cmdline/org/tmatesoft/hg/console/Main.java @ 231:1792b37650f2
Introduced access to conflict resolution information (merge state)
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 01 Jun 2011 05:44:25 +0200 |
parents | 1ec6b327a6ac |
children | b7347daa50e3 |
line wrap: on
line diff
--- a/cmdline/org/tmatesoft/hg/console/Main.java Tue May 31 05:33:16 2011 +0200 +++ b/cmdline/org/tmatesoft/hg/console/Main.java Wed Jun 01 05:44:25 2011 +0200 @@ -24,6 +24,7 @@ import java.util.Map; import org.tmatesoft.hg.core.HgLogCommand.FileRevision; +import org.tmatesoft.hg.core.HgFileRevision; import org.tmatesoft.hg.core.HgManifestCommand; import org.tmatesoft.hg.core.Nodeid; import org.tmatesoft.hg.internal.ByteArrayChannel; @@ -33,6 +34,7 @@ import org.tmatesoft.hg.repo.HgDataFile; import org.tmatesoft.hg.repo.HgInternals; import org.tmatesoft.hg.repo.HgManifest; +import org.tmatesoft.hg.repo.HgMergeState; import org.tmatesoft.hg.repo.HgRepository; import org.tmatesoft.hg.repo.HgStatusCollector; import org.tmatesoft.hg.repo.HgStatusInspector; @@ -62,7 +64,8 @@ public static void main(String[] args) throws Exception { Main m = new Main(args); - m.testFileStatus(); + m.testMergeState(); +// m.testFileStatus(); // m.dumpBranches(); // m.inflaterLengthException(); // m.dumpIgnored(); @@ -74,28 +77,31 @@ // m.bunchOfTests(); } + private void testMergeState() throws Exception { + final HgMergeState mergeState = hgRepo.getMergeState(); + mergeState.refresh(); + for (HgMergeState.Entry e : mergeState.getConflicts()) { + System.out.println(e.getState() + " " + e.getActualFile()); + System.out.println("p1: " + formatFileRevision(e.getFirstParent())); + System.out.println("p2: " + formatFileRevision(e.getSecondParent())); + System.out.println("ancestor: " + formatFileRevision(e.getCommonAncestor())); + System.out.println(); + } + } + + private static String formatFileRevision(HgFileRevision r) throws Exception { + final ByteArrayChannel sink = new ByteArrayChannel(); + r.putContentTo(sink); + return String.format("%s %s (%d bytes)", r.getPath(), r.getRevision(), sink.toArray().length); + } + private void testFileStatus() { // final Path path = Path.create("src/org/tmatesoft/hg/util/"); // final Path path = Path.create("src/org/tmatesoft/hg/internal/Experimental.java"); -// final Path path = Path.create("dir/file3"); +// final Path path = Path.create("missing-dir/"); // HgWorkingCopyStatusCollector wcsc = HgWorkingCopyStatusCollector.create(hgRepo, path); - HgWorkingCopyStatusCollector wcsc = HgWorkingCopyStatusCollector.create(hgRepo, new PathGlobMatcher("*")); + HgWorkingCopyStatusCollector wcsc = HgWorkingCopyStatusCollector.create(hgRepo, new PathGlobMatcher("missing-dir/**/*")); wcsc.walk(TIP, new StatusDump()); - new HgManifestCommand(hgRepo).dirs(true).revision(TIP).execute(new HgManifestCommand.Handler() { - - public void file(FileRevision fileRevision) { - } - - public void end(Nodeid manifestRevision) { - } - - public void dir(Path p) { - System.out.println(p); - } - - public void begin(Nodeid manifestRevision) { - } - }); } private void dumpBranches() {