# HG changeset patch # User Artem Tikhomirov # Date 1321927034 -3600 # Node ID 168f1994de7e23c358266d21ba623061ce54f244 # Parent 58016b1b8554c5301883a69b3ea4a1aac729f5a8 Distinguish active from removed tags diff -r 58016b1b8554 -r 168f1994de7e src/org/tmatesoft/hg/repo/HgTags.java --- a/src/org/tmatesoft/hg/repo/HgTags.java Sat Nov 19 01:07:27 2011 +0100 +++ b/src/org/tmatesoft/hg/repo/HgTags.java Tue Nov 22 02:57:14 2011 +0100 @@ -184,7 +184,18 @@ return rv; } + /** + * @deprecated use {@link #getAllTags()} instead + */ + @Deprecated public Map getTags() { + return getAllTags(); + } + + /** + * All tag entries from the repository, for both active and removed tags + */ + public Map getAllTags() { if (tags == null) { tags = new TreeMap(); for (String t : globalFromName.keySet()) { @@ -197,6 +208,19 @@ } return tags; } + + /** + * Tags that are in use in the repository, unlike {@link #getAllTags()} doesn't list removed tags. + */ + public Map getActiveTags() { + TreeMap rv = new TreeMap(); + for (Map.Entry e : getAllTags().entrySet()) { + if (!e.getValue().isRemoved()) { + rv.put(e.getKey(), e.getValue()); + } + } + return rv; + } public final class TagInfo { @@ -204,7 +228,7 @@ private String branch; TagInfo(String tagName) { - this.name = tagName; + name = tagName; } public String name() { return name; @@ -227,5 +251,12 @@ } return globalFromName.get(name).get(0); } + + /** + * @return true if this tag entry describes tag removal + */ + public boolean isRemoved() { + return revision().isNull(); + } } }