Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/HgTags.java @ 344:168f1994de7e
Distinguish active from removed tags
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 22 Nov 2011 02:57:14 +0100 |
parents | 981f9f50bb6c |
children | 5f9073eabf06 |
comparison
equal
deleted
inserted
replaced
343:58016b1b8554 | 344:168f1994de7e |
---|---|
182 rv.addAll(l); | 182 rv.addAll(l); |
183 } | 183 } |
184 return rv; | 184 return rv; |
185 } | 185 } |
186 | 186 |
187 /** | |
188 * @deprecated use {@link #getAllTags()} instead | |
189 */ | |
190 @Deprecated | |
187 public Map<String, TagInfo> getTags() { | 191 public Map<String, TagInfo> getTags() { |
192 return getAllTags(); | |
193 } | |
194 | |
195 /** | |
196 * All tag entries from the repository, for both active and removed tags | |
197 */ | |
198 public Map<String, TagInfo> getAllTags() { | |
188 if (tags == null) { | 199 if (tags == null) { |
189 tags = new TreeMap<String, TagInfo>(); | 200 tags = new TreeMap<String, TagInfo>(); |
190 for (String t : globalFromName.keySet()) { | 201 for (String t : globalFromName.keySet()) { |
191 tags.put(t, new TagInfo(t)); | 202 tags.put(t, new TagInfo(t)); |
192 } | 203 } |
195 } | 206 } |
196 tags = Collections.unmodifiableMap(tags); | 207 tags = Collections.unmodifiableMap(tags); |
197 } | 208 } |
198 return tags; | 209 return tags; |
199 } | 210 } |
211 | |
212 /** | |
213 * Tags that are in use in the repository, unlike {@link #getAllTags()} doesn't list removed tags. | |
214 */ | |
215 public Map<String, TagInfo> getActiveTags() { | |
216 TreeMap<String, TagInfo> rv = new TreeMap<String, TagInfo>(); | |
217 for (Map.Entry<String, TagInfo> e : getAllTags().entrySet()) { | |
218 if (!e.getValue().isRemoved()) { | |
219 rv.put(e.getKey(), e.getValue()); | |
220 } | |
221 } | |
222 return rv; | |
223 } | |
200 | 224 |
201 | 225 |
202 public final class TagInfo { | 226 public final class TagInfo { |
203 private final String name; | 227 private final String name; |
204 private String branch; | 228 private String branch; |
205 | 229 |
206 TagInfo(String tagName) { | 230 TagInfo(String tagName) { |
207 this.name = tagName; | 231 name = tagName; |
208 } | 232 } |
209 public String name() { | 233 public String name() { |
210 return name; | 234 return name; |
211 } | 235 } |
212 | 236 |
225 if (isLocal()) { | 249 if (isLocal()) { |
226 return localFromName.get(name).get(0); | 250 return localFromName.get(name).get(0); |
227 } | 251 } |
228 return globalFromName.get(name).get(0); | 252 return globalFromName.get(name).get(0); |
229 } | 253 } |
254 | |
255 /** | |
256 * @return <code>true</code> if this tag entry describes tag removal | |
257 */ | |
258 public boolean isRemoved() { | |
259 return revision().isNull(); | |
260 } | |
230 } | 261 } |
231 } | 262 } |