comparison cmdline/org/tmatesoft/hg/console/ChangesetDumpHandler.java @ 319:fa4aea41746e

Dump exception to console
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 29 Sep 2011 04:37:52 +0200
parents 9fb50c04f03c
children 2fadf8695f8a
comparison
equal deleted inserted replaced
318:c3d2233ba842 319:fa4aea41746e
20 import java.util.LinkedList; 20 import java.util.LinkedList;
21 import java.util.List; 21 import java.util.List;
22 22
23 import org.tmatesoft.hg.core.HgChangeset; 23 import org.tmatesoft.hg.core.HgChangeset;
24 import org.tmatesoft.hg.core.HgChangesetHandler; 24 import org.tmatesoft.hg.core.HgChangesetHandler;
25 import org.tmatesoft.hg.core.HgException;
25 import org.tmatesoft.hg.core.HgFileRevision; 26 import org.tmatesoft.hg.core.HgFileRevision;
26 import org.tmatesoft.hg.core.Nodeid; 27 import org.tmatesoft.hg.core.Nodeid;
27 import org.tmatesoft.hg.repo.HgRepository; 28 import org.tmatesoft.hg.repo.HgRepository;
28 import org.tmatesoft.hg.util.Path; 29 import org.tmatesoft.hg.util.Path;
29 30
61 verbose = b; 62 verbose = b;
62 return this; 63 return this;
63 } 64 }
64 65
65 public void next(HgChangeset changeset) { 66 public void next(HgChangeset changeset) {
66 final String s = print(changeset); 67 try {
67 if (reverseOrder) { 68 final String s = print(changeset);
68 // XXX in fact, need to insert s into l according to changeset.getRevision() 69 if (reverseOrder) {
69 // because when file history is being followed, revisions of the original file (with smaller revNumber) 70 // XXX in fact, need to insert s into l according to changeset.getRevision()
70 // are reported *after* revisions of present file and with addFirst appear above them 71 // because when file history is being followed, revisions of the original file (with smaller revNumber)
71 l.addFirst(s); 72 // are reported *after* revisions of present file and with addFirst appear above them
72 } else { 73 l.addFirst(s);
73 System.out.print(s); 74 } else {
75 System.out.print(s);
76 }
77 } catch (HgException ex) {
78 ex.printStackTrace();
74 } 79 }
75 } 80 }
76 81
77 public void done() { 82 public void done() {
78 if (!reverseOrder) { 83 if (!reverseOrder) {
82 System.out.print(s); 87 System.out.print(s);
83 } 88 }
84 l.clear(); 89 l.clear();
85 } 90 }
86 91
87 private String print(HgChangeset cset) { 92 private String print(HgChangeset cset) throws HgException {
88 StringBuilder sb = new StringBuilder(); 93 StringBuilder sb = new StringBuilder();
89 Formatter f = new Formatter(sb); 94 Formatter f = new Formatter(sb);
90 final Nodeid csetNodeid = cset.getNodeid(); 95 final Nodeid csetNodeid = cset.getNodeid();
91 f.format("changeset: %d:%s\n", cset.getRevision(), complete ? csetNodeid : csetNodeid.shortNotation()); 96 f.format("changeset: %d:%s\n", cset.getRevision(), complete ? csetNodeid : csetNodeid.shortNotation());
92 if (cset.getRevision() == tip || repo.getTags().isTagged(csetNodeid)) { 97 if (cset.getRevision() == tip || repo.getTags().isTagged(csetNodeid)) {
93
94 sb.append("tag: "); 98 sb.append("tag: ");
95 for (String t : repo.getTags().tags(csetNodeid)) { 99 for (String t : repo.getTags().tags(csetNodeid)) {
96 sb.append(t); 100 sb.append(t);
97 sb.append(' '); 101 sb.append(' ');
98 } 102 }