comparison src/org/tmatesoft/hg/repo/HgTags.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 5c68567b3645
children
comparison
equal deleted inserted replaced
627:5153eb73b18d 628:6526d8adbc0f
72 localToName = new HashMap<Nodeid, List<String>>(); 72 localToName = new HashMap<Nodeid, List<String>>();
73 globalFromName = new TreeMap<String, List<Nodeid>>(); 73 globalFromName = new TreeMap<String, List<Nodeid>>();
74 localFromName = new TreeMap<String, List<Nodeid>>(); 74 localFromName = new TreeMap<String, List<Nodeid>>();
75 } 75 }
76 76
77 /*package-local*/ void read() throws HgInvalidControlFileException { 77 /*package-local*/ void read() throws HgRuntimeException {
78 readTagsFromHistory(); 78 readTagsFromHistory();
79 readGlobal(); 79 readGlobal();
80 readLocal(); 80 readLocal();
81 } 81 }
82 82
83 private void readTagsFromHistory() throws HgInvalidControlFileException { 83 private void readTagsFromHistory() throws HgRuntimeException {
84 HgDataFile hgTags = repo.getRepo().getFileNode(HgTags.getPath()); 84 HgDataFile hgTags = repo.getRepo().getFileNode(HgTags.getPath());
85 if (hgTags.exists()) { 85 if (hgTags.exists()) {
86 for (int i = 0; i <= hgTags.getLastRevision(); i++) { // TODO post-1.0 in fact, would be handy to have walk(start,end) 86 for (int i = 0; i <= hgTags.getLastRevision(); i++) { // TODO post-1.0 in fact, would be handy to have walk(start,end)
87 // method for data files as well, though it looks odd. 87 // method for data files as well, though it looks odd.
88 try { 88 try {
278 } 278 }
279 return rv; 279 return rv;
280 } 280 }
281 281
282 // can be called only after instance has been initialized (#read() invoked) 282 // can be called only after instance has been initialized (#read() invoked)
283 /*package-local*/void reloadIfChanged() throws HgInvalidControlFileException { 283 /*package-local*/void reloadIfChanged() throws HgRuntimeException {
284 assert repoChangeMonitor != null; 284 assert repoChangeMonitor != null;
285 assert localTagsFileMonitor != null; 285 assert localTagsFileMonitor != null;
286 assert globalTagsFileMonitor != null; 286 assert globalTagsFileMonitor != null;
287 if (repoChangeMonitor.isChanged() || globalTagsFileMonitor.changed(this)) { 287 if (repoChangeMonitor.isChanged() || globalTagsFileMonitor.changed(this)) {
288 globalFromName.clear(); 288 globalFromName.clear();
310 310
311 public boolean isLocal() { 311 public boolean isLocal() {
312 return localFromName.containsKey(name); 312 return localFromName.containsKey(name);
313 } 313 }
314 314
315 public String branch() throws HgInvalidControlFileException { 315 /**
316 * @return name of the branch this tag belongs to, never <code>null</code>
317 * @throws HgInvalidRevisionException if revision of the tag is not a valid changeset revision. <em>Runtime exception</em>
318 * @throws HgInvalidControlFileException if failed to access revlog index/data entry. <em>Runtime exception</em>
319 * @throws HgRuntimeException subclass thereof to indicate other issues with the library. <em>Runtime exception</em>
320 */
321 public String branch() throws HgRuntimeException {
316 if (branch == null) { 322 if (branch == null) {
317 int x = repo.getRepo().getChangelog().getRevisionIndex(revision()); 323 int x = repo.getRepo().getChangelog().getRevisionIndex(revision());
318 branch = repo.getRepo().getChangelog().range(x, x).get(0).branch(); 324 branch = repo.getRepo().getChangelog().range(x, x).get(0).branch();
319 } 325 }
320 return branch; 326 return branch;