Mercurial > jhg
comparison cmdline/org/tmatesoft/hg/console/ChangesetDumpHandler.java @ 628:6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 22 May 2013 15:52:31 +0200 |
parents | 37d97854c6ad |
children |
comparison
equal
deleted
inserted
replaced
627:5153eb73b18d | 628:6526d8adbc0f |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011-2012 TMate Software Ltd | 2 * Copyright (c) 2011-2013 TMate Software Ltd |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or modify | 4 * This program is free software; you can redistribute it and/or modify |
5 * it under the terms of the GNU General Public License as published by | 5 * it under the terms of the GNU General Public License as published by |
6 * the Free Software Foundation; version 2 of the License. | 6 * the Free Software Foundation; version 2 of the License. |
7 * | 7 * |
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.HgException; |
26 import org.tmatesoft.hg.core.HgFileRevision; | 26 import org.tmatesoft.hg.core.HgFileRevision; |
27 import org.tmatesoft.hg.core.Nodeid; | 27 import org.tmatesoft.hg.core.Nodeid; |
28 import org.tmatesoft.hg.repo.HgRepository; | 28 import org.tmatesoft.hg.repo.HgRepository; |
29 import org.tmatesoft.hg.repo.HgRuntimeException; | |
29 import org.tmatesoft.hg.util.Path; | 30 import org.tmatesoft.hg.util.Path; |
30 | 31 |
31 /** | 32 /** |
32 * | 33 * |
33 * @author Artem Tikhomirov | 34 * @author Artem Tikhomirov |
41 // own | 42 // own |
42 private LinkedList<String> l = new LinkedList<String>(); | 43 private LinkedList<String> l = new LinkedList<String>(); |
43 private final HgRepository repo; | 44 private final HgRepository repo; |
44 private final int tip; | 45 private final int tip; |
45 | 46 |
46 public ChangesetDumpHandler(HgRepository hgRepo) { | 47 public ChangesetDumpHandler(HgRepository hgRepo) throws HgRuntimeException { |
47 repo = hgRepo; | 48 repo = hgRepo; |
48 tip = hgRepo.getChangelog().getLastRevision(); | 49 tip = hgRepo.getChangelog().getLastRevision(); |
49 } | 50 } |
50 | 51 |
51 public ChangesetDumpHandler complete(boolean b) { | 52 public ChangesetDumpHandler complete(boolean b) { |
61 public ChangesetDumpHandler verbose(boolean b) { | 62 public ChangesetDumpHandler verbose(boolean b) { |
62 verbose = b; | 63 verbose = b; |
63 return this; | 64 return this; |
64 } | 65 } |
65 | 66 |
66 public void cset(HgChangeset changeset) { | 67 public void cset(HgChangeset changeset) throws HgRuntimeException { |
67 try { | 68 try { |
68 final String s = print(changeset); | 69 final String s = print(changeset); |
69 if (reverseOrder) { | 70 if (reverseOrder) { |
70 // XXX in fact, need to insert s into l according to changeset.getRevision() | 71 // XXX in fact, need to insert s into l according to changeset.getRevision() |
71 // because when file history is being followed, revisions of the original file (with smaller revNumber) | 72 // because when file history is being followed, revisions of the original file (with smaller revNumber) |
87 System.out.print(s); | 88 System.out.print(s); |
88 } | 89 } |
89 l.clear(); | 90 l.clear(); |
90 } | 91 } |
91 | 92 |
92 private String print(HgChangeset cset) throws HgException { | 93 private String print(HgChangeset cset) throws HgException, HgRuntimeException { |
93 StringBuilder sb = new StringBuilder(); | 94 StringBuilder sb = new StringBuilder(); |
94 Formatter f = new Formatter(sb); | 95 Formatter f = new Formatter(sb); |
95 final Nodeid csetNodeid = cset.getNodeid(); | 96 final Nodeid csetNodeid = cset.getNodeid(); |
96 f.format("changeset: %d:%s\n", cset.getRevisionIndex(), complete ? csetNodeid : csetNodeid.shortNotation()); | 97 f.format("changeset: %d:%s\n", cset.getRevisionIndex(), complete ? csetNodeid : csetNodeid.shortNotation()); |
97 if (cset.getRevisionIndex() == tip || repo.getTags().isTagged(csetNodeid)) { | 98 if (cset.getRevisionIndex() == tip || repo.getTags().isTagged(csetNodeid)) { |