Mercurial > jhg
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 230:0dd9da7489dc | 231:1792b37650f2 |
|---|---|
| 22 import java.util.Collections; | 22 import java.util.Collections; |
| 23 import java.util.List; | 23 import java.util.List; |
| 24 import java.util.Map; | 24 import java.util.Map; |
| 25 | 25 |
| 26 import org.tmatesoft.hg.core.HgLogCommand.FileRevision; | 26 import org.tmatesoft.hg.core.HgLogCommand.FileRevision; |
| 27 import org.tmatesoft.hg.core.HgFileRevision; | |
| 27 import org.tmatesoft.hg.core.HgManifestCommand; | 28 import org.tmatesoft.hg.core.HgManifestCommand; |
| 28 import org.tmatesoft.hg.core.Nodeid; | 29 import org.tmatesoft.hg.core.Nodeid; |
| 29 import org.tmatesoft.hg.internal.ByteArrayChannel; | 30 import org.tmatesoft.hg.internal.ByteArrayChannel; |
| 30 import org.tmatesoft.hg.internal.DigestHelper; | 31 import org.tmatesoft.hg.internal.DigestHelper; |
| 31 import org.tmatesoft.hg.internal.PathGlobMatcher; | 32 import org.tmatesoft.hg.internal.PathGlobMatcher; |
| 32 import org.tmatesoft.hg.repo.HgBranches; | 33 import org.tmatesoft.hg.repo.HgBranches; |
| 33 import org.tmatesoft.hg.repo.HgDataFile; | 34 import org.tmatesoft.hg.repo.HgDataFile; |
| 34 import org.tmatesoft.hg.repo.HgInternals; | 35 import org.tmatesoft.hg.repo.HgInternals; |
| 35 import org.tmatesoft.hg.repo.HgManifest; | 36 import org.tmatesoft.hg.repo.HgManifest; |
| 37 import org.tmatesoft.hg.repo.HgMergeState; | |
| 36 import org.tmatesoft.hg.repo.HgRepository; | 38 import org.tmatesoft.hg.repo.HgRepository; |
| 37 import org.tmatesoft.hg.repo.HgStatusCollector; | 39 import org.tmatesoft.hg.repo.HgStatusCollector; |
| 38 import org.tmatesoft.hg.repo.HgStatusInspector; | 40 import org.tmatesoft.hg.repo.HgStatusInspector; |
| 39 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector; | 41 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector; |
| 40 import org.tmatesoft.hg.util.Path; | 42 import org.tmatesoft.hg.util.Path; |
| 60 System.out.println("REPO:" + hgRepo.getLocation()); | 62 System.out.println("REPO:" + hgRepo.getLocation()); |
| 61 } | 63 } |
| 62 | 64 |
| 63 public static void main(String[] args) throws Exception { | 65 public static void main(String[] args) throws Exception { |
| 64 Main m = new Main(args); | 66 Main m = new Main(args); |
| 65 m.testFileStatus(); | 67 m.testMergeState(); |
| 68 // m.testFileStatus(); | |
| 66 // m.dumpBranches(); | 69 // m.dumpBranches(); |
| 67 // m.inflaterLengthException(); | 70 // m.inflaterLengthException(); |
| 68 // m.dumpIgnored(); | 71 // m.dumpIgnored(); |
| 69 // m.dumpDirstate(); | 72 // m.dumpDirstate(); |
| 70 // m.testStatusInternals(); | 73 // m.testStatusInternals(); |
| 72 // m.dumpCompleteManifestLow(); | 75 // m.dumpCompleteManifestLow(); |
| 73 // m.dumpCompleteManifestHigh(); | 76 // m.dumpCompleteManifestHigh(); |
| 74 // m.bunchOfTests(); | 77 // m.bunchOfTests(); |
| 75 } | 78 } |
| 76 | 79 |
| 80 private void testMergeState() throws Exception { | |
| 81 final HgMergeState mergeState = hgRepo.getMergeState(); | |
| 82 mergeState.refresh(); | |
| 83 for (HgMergeState.Entry e : mergeState.getConflicts()) { | |
| 84 System.out.println(e.getState() + " " + e.getActualFile()); | |
| 85 System.out.println("p1: " + formatFileRevision(e.getFirstParent())); | |
| 86 System.out.println("p2: " + formatFileRevision(e.getSecondParent())); | |
| 87 System.out.println("ancestor: " + formatFileRevision(e.getCommonAncestor())); | |
| 88 System.out.println(); | |
| 89 } | |
| 90 } | |
| 91 | |
| 92 private static String formatFileRevision(HgFileRevision r) throws Exception { | |
| 93 final ByteArrayChannel sink = new ByteArrayChannel(); | |
| 94 r.putContentTo(sink); | |
| 95 return String.format("%s %s (%d bytes)", r.getPath(), r.getRevision(), sink.toArray().length); | |
| 96 } | |
| 97 | |
| 77 private void testFileStatus() { | 98 private void testFileStatus() { |
| 78 // final Path path = Path.create("src/org/tmatesoft/hg/util/"); | 99 // final Path path = Path.create("src/org/tmatesoft/hg/util/"); |
| 79 // final Path path = Path.create("src/org/tmatesoft/hg/internal/Experimental.java"); | 100 // final Path path = Path.create("src/org/tmatesoft/hg/internal/Experimental.java"); |
| 80 // final Path path = Path.create("dir/file3"); | 101 // final Path path = Path.create("missing-dir/"); |
| 81 // HgWorkingCopyStatusCollector wcsc = HgWorkingCopyStatusCollector.create(hgRepo, path); | 102 // HgWorkingCopyStatusCollector wcsc = HgWorkingCopyStatusCollector.create(hgRepo, path); |
| 82 HgWorkingCopyStatusCollector wcsc = HgWorkingCopyStatusCollector.create(hgRepo, new PathGlobMatcher("*")); | 103 HgWorkingCopyStatusCollector wcsc = HgWorkingCopyStatusCollector.create(hgRepo, new PathGlobMatcher("missing-dir/**/*")); |
| 83 wcsc.walk(TIP, new StatusDump()); | 104 wcsc.walk(TIP, new StatusDump()); |
| 84 new HgManifestCommand(hgRepo).dirs(true).revision(TIP).execute(new HgManifestCommand.Handler() { | |
| 85 | |
| 86 public void file(FileRevision fileRevision) { | |
| 87 } | |
| 88 | |
| 89 public void end(Nodeid manifestRevision) { | |
| 90 } | |
| 91 | |
| 92 public void dir(Path p) { | |
| 93 System.out.println(p); | |
| 94 } | |
| 95 | |
| 96 public void begin(Nodeid manifestRevision) { | |
| 97 } | |
| 98 }); | |
| 99 } | 105 } |
| 100 | 106 |
| 101 private void dumpBranches() { | 107 private void dumpBranches() { |
| 102 HgBranches b = hgRepo.getBranches(); | 108 HgBranches b = hgRepo.getBranches(); |
| 103 for (HgBranches.BranchInfo bi : b.getAllBranches()) { | 109 for (HgBranches.BranchInfo bi : b.getAllBranches()) { |
