comparison cmdline/org/tmatesoft/hg/console/Main.java @ 295:981f9f50bb6c

Issue 11: Error log facility. SessionContext to share common facilities
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 16 Sep 2011 05:35:32 +0200
parents 8faad08c709b
children 45dc79e545f5
comparison
equal deleted inserted replaced
294:32890bab7209 295:981f9f50bb6c
24 import java.util.List; 24 import java.util.List;
25 import java.util.Map; 25 import java.util.Map;
26 26
27 import org.junit.Assert; 27 import org.junit.Assert;
28 import org.tmatesoft.hg.core.HgBadStateException; 28 import org.tmatesoft.hg.core.HgBadStateException;
29 import org.tmatesoft.hg.core.HgCatCommand;
29 import org.tmatesoft.hg.core.HgDataStreamException; 30 import org.tmatesoft.hg.core.HgDataStreamException;
30 import org.tmatesoft.hg.core.HgLogCommand;
31 import org.tmatesoft.hg.core.HgCatCommand;
32 import org.tmatesoft.hg.core.HgFileInformer; 31 import org.tmatesoft.hg.core.HgFileInformer;
33 import org.tmatesoft.hg.core.HgFileRevision; 32 import org.tmatesoft.hg.core.HgFileRevision;
33 import org.tmatesoft.hg.core.HgLogCommand;
34 import org.tmatesoft.hg.core.HgManifestCommand; 34 import org.tmatesoft.hg.core.HgManifestCommand;
35 import org.tmatesoft.hg.core.Nodeid; 35 import org.tmatesoft.hg.core.Nodeid;
36 import org.tmatesoft.hg.internal.ByteArrayChannel; 36 import org.tmatesoft.hg.internal.ByteArrayChannel;
37 import org.tmatesoft.hg.internal.DigestHelper; 37 import org.tmatesoft.hg.internal.DigestHelper;
38 import org.tmatesoft.hg.internal.PathGlobMatcher; 38 import org.tmatesoft.hg.internal.PathGlobMatcher;
39 import org.tmatesoft.hg.internal.RelativePathRewrite; 39 import org.tmatesoft.hg.internal.RelativePathRewrite;
40 import org.tmatesoft.hg.internal.StreamLogFacility;
40 import org.tmatesoft.hg.repo.HgBranches; 41 import org.tmatesoft.hg.repo.HgBranches;
41 import org.tmatesoft.hg.repo.HgChangelog; 42 import org.tmatesoft.hg.repo.HgChangelog;
43 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
42 import org.tmatesoft.hg.repo.HgDataFile; 44 import org.tmatesoft.hg.repo.HgDataFile;
43 import org.tmatesoft.hg.repo.HgDirstate; 45 import org.tmatesoft.hg.repo.HgDirstate;
46 import org.tmatesoft.hg.repo.HgDirstate.EntryKind;
47 import org.tmatesoft.hg.repo.HgDirstate.Record;
44 import org.tmatesoft.hg.repo.HgInternals; 48 import org.tmatesoft.hg.repo.HgInternals;
45 import org.tmatesoft.hg.repo.HgManifest; 49 import org.tmatesoft.hg.repo.HgManifest;
50 import org.tmatesoft.hg.repo.HgManifest.Flags;
46 import org.tmatesoft.hg.repo.HgMergeState; 51 import org.tmatesoft.hg.repo.HgMergeState;
47 import org.tmatesoft.hg.repo.HgRepository; 52 import org.tmatesoft.hg.repo.HgRepository;
48 import org.tmatesoft.hg.repo.HgStatusCollector; 53 import org.tmatesoft.hg.repo.HgStatusCollector;
49 import org.tmatesoft.hg.repo.HgStatusInspector; 54 import org.tmatesoft.hg.repo.HgStatusInspector;
50 import org.tmatesoft.hg.repo.HgSubrepoLocation; 55 import org.tmatesoft.hg.repo.HgSubrepoLocation;
51 import org.tmatesoft.hg.repo.HgManifest.Flags;
52 import org.tmatesoft.hg.repo.HgSubrepoLocation.Kind; 56 import org.tmatesoft.hg.repo.HgSubrepoLocation.Kind;
53 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector; 57 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector;
54 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
55 import org.tmatesoft.hg.repo.HgDirstate.EntryKind;
56 import org.tmatesoft.hg.repo.HgDirstate.Record;
57 import org.tmatesoft.hg.util.FileWalker; 58 import org.tmatesoft.hg.util.FileWalker;
59 import org.tmatesoft.hg.util.LogFacility;
58 import org.tmatesoft.hg.util.Pair; 60 import org.tmatesoft.hg.util.Pair;
59 import org.tmatesoft.hg.util.Path; 61 import org.tmatesoft.hg.util.Path;
60 import org.tmatesoft.hg.util.PathRewrite; 62 import org.tmatesoft.hg.util.PathRewrite;
61 63
62 /** 64 /**
63 * Various debug dumps. 65 * Various debug dumps.
64 * 66 *
65 * @author Artem Tikhomirov 67 * @author Artem Tikhomirov
66 * @author TMate Software Ltd. 68 * @author TMate Software Ltd.
67 */ 69 */
70 @SuppressWarnings("unused")
68 public class Main { 71 public class Main {
69 72
70 private Options cmdLineOpts; 73 private Options cmdLineOpts;
71 private HgRepository hgRepo; 74 private HgRepository hgRepo;
72 75
80 System.out.println("REPO:" + hgRepo.getLocation()); 83 System.out.println("REPO:" + hgRepo.getLocation());
81 } 84 }
82 85
83 public static void main(String[] args) throws Exception { 86 public static void main(String[] args) throws Exception {
84 Main m = new Main(args); 87 Main m = new Main(args);
88 m.testConsoleLog();
85 // m.testTreeTraversal(); 89 // m.testTreeTraversal();
86 // m.testRevisionMap(); 90 // m.testRevisionMap();
87 // m.testSubrepos(); 91 // m.testSubrepos();
88 // m.testReadWorkingCopy(); 92 // m.testReadWorkingCopy();
89 // m.testParents(); 93 // m.testParents();
92 // m.testMergeState(); 96 // m.testMergeState();
93 // m.testFileStatus(); 97 // m.testFileStatus();
94 // m.dumpBranches(); 98 // m.dumpBranches();
95 // m.inflaterLengthException(); 99 // m.inflaterLengthException();
96 // m.dumpIgnored(); 100 // m.dumpIgnored();
97 m.dumpDirstate(); 101 // m.dumpDirstate();
98 // m.testStatusInternals(); 102 // m.testStatusInternals();
99 // m.catCompleteHistory(); 103 // m.catCompleteHistory();
100 // m.dumpCompleteManifestLow(); 104 // m.dumpCompleteManifestLow();
101 // m.dumpCompleteManifestHigh(); 105 // m.dumpCompleteManifestHigh();
102 // m.bunchOfTests(); 106 // m.bunchOfTests();
107 }
108
109 private void testConsoleLog() {
110 LogFacility fc = new StreamLogFacility(true, true, true, System.out);
111 System.out.printf("isDebug: %s, isInfo:%s\n", fc.isDebug(), fc.isInfo());
112 fc.debug(getClass(), "%d", 1);
113 fc.info(getClass(), "%d\n", 2);
114 fc.warn(getClass(), "%d\n", 3);
115 fc.error(getClass(), "%d", 4);
116 Exception ex = new Exception();
117 fc.debug(getClass(), ex, "message");
118 fc.info(getClass(), ex, null);
119 fc.warn(getClass(), ex, null);
120 fc.error(getClass(), ex, "message");
103 } 121 }
104 122
105 private void testTreeTraversal() throws Exception { 123 private void testTreeTraversal() throws Exception {
106 File repoRoot = hgRepo.getWorkingDir(); 124 File repoRoot = hgRepo.getWorkingDir();
107 Path.Source pathSrc = new Path.SimpleSource(new PathRewrite.Composite(new RelativePathRewrite(repoRoot), hgRepo.getToRepoPathHelper())); 125 Path.Source pathSrc = new Path.SimpleSource(new PathRewrite.Composite(new RelativePathRewrite(repoRoot), hgRepo.getToRepoPathHelper()));