comparison src/org/tmatesoft/hg/repo/HgRepository.java @ 234:b2cfbe46f9b6

HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 07 Jun 2011 04:28:32 +0200
parents 1792b37650f2
children fd845a53f53d
comparison
equal deleted inserted replaced
233:1d389c0cb0a5 234:b2cfbe46f9b6
16 */ 16 */
17 package org.tmatesoft.hg.repo; 17 package org.tmatesoft.hg.repo;
18 18
19 import java.io.File; 19 import java.io.File;
20 import java.io.IOException; 20 import java.io.IOException;
21 import java.io.StringReader;
21 import java.lang.ref.SoftReference; 22 import java.lang.ref.SoftReference;
23 import java.nio.charset.Charset;
22 import java.util.ArrayList; 24 import java.util.ArrayList;
23 import java.util.Collections; 25 import java.util.Collections;
24 import java.util.HashMap; 26 import java.util.HashMap;
25 import java.util.List; 27 import java.util.List;
26 28
29 import org.tmatesoft.hg.core.HgDataStreamException;
30 import org.tmatesoft.hg.internal.ByteArrayChannel;
27 import org.tmatesoft.hg.internal.ConfigFile; 31 import org.tmatesoft.hg.internal.ConfigFile;
28 import org.tmatesoft.hg.internal.DataAccessProvider; 32 import org.tmatesoft.hg.internal.DataAccessProvider;
29 import org.tmatesoft.hg.internal.Experimental; 33 import org.tmatesoft.hg.internal.Experimental;
30 import org.tmatesoft.hg.internal.Filter; 34 import org.tmatesoft.hg.internal.Filter;
31 import org.tmatesoft.hg.internal.RequiresFile; 35 import org.tmatesoft.hg.internal.RequiresFile;
32 import org.tmatesoft.hg.internal.RevlogStream; 36 import org.tmatesoft.hg.internal.RevlogStream;
37 import org.tmatesoft.hg.util.CancelledException;
33 import org.tmatesoft.hg.util.Path; 38 import org.tmatesoft.hg.util.Path;
34 import org.tmatesoft.hg.util.PathRewrite; 39 import org.tmatesoft.hg.util.PathRewrite;
35 import org.tmatesoft.hg.util.ProgressSupport; 40 import org.tmatesoft.hg.util.ProgressSupport;
36 41
37 42
140 return this.manifest; 145 return this.manifest;
141 } 146 }
142 147
143 public HgTags getTags() { 148 public HgTags getTags() {
144 if (tags == null) { 149 if (tags == null) {
145 tags = new HgTags(); 150 tags = new HgTags(this);
146 try { 151 try {
147 tags.readGlobal(new File(repoDir.getParentFile(), ".hgtags")); 152 HgDataFile hgTags = getFileNode(".hgtags");
153 if (hgTags.exists()) {
154 for (int i = 0; i <= hgTags.getLastRevision(); i++) { // FIXME in fact, would be handy to have walk(start,end)
155 // method for data files as well, though it looks odd.
156 try {
157 ByteArrayChannel sink = new ByteArrayChannel();
158 hgTags.content(i, sink);
159 final String content = new String(sink.toArray(), "UTF8");
160 tags.readGlobal(new StringReader(content));
161 } catch (CancelledException ex) {
162 ex.printStackTrace(); // IGNORE, can't happen, we did not configure cancellation
163 } catch (HgDataStreamException ex) {
164 ex.printStackTrace(); // FIXME need to react
165 } catch (IOException ex) {
166 // UnsupportedEncodingException can't happen (UTF8)
167 // only from readGlobal. Need to reconsider exceptions thrown from there
168 ex.printStackTrace(); // XXX need to decide what to do this. failure to read single revision shall not break complete cycle
169 }
170 }
171 }
172 tags.readGlobal(new File(repoDir.getParentFile(), ".hgtags")); // XXX replace with HgDataFile.workingCopy
148 tags.readLocal(new File(repoDir, "localtags")); 173 tags.readLocal(new File(repoDir, "localtags"));
149 } catch (IOException ex) { 174 } catch (IOException ex) {
150 ex.printStackTrace(); // FIXME log or othewise report 175 ex.printStackTrace(); // FIXME log or othewise report
151 } 176 }
152 } 177 }