annotate src/org/tmatesoft/hg/repo/HgTags.java @ 490:b3c16d1aede0

Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 16 Aug 2012 17:08:34 +0200
parents 909306e412e2
children d9c07e1432c4
rev   line source
50
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
456
909306e412e2 Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 424
diff changeset
2 * Copyright (c) 2011-2012 TMate Software Ltd
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
3 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
4 * This program is free software; you can redistribute it and/or modify
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
5 * it under the terms of the GNU General Public License as published by
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
6 * the Free Software Foundation; version 2 of the License.
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
7 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
8 * This program is distributed in the hope that it will be useful,
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
11 * GNU General Public License for more details.
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
12 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
13 * For information on how to redistribute this software under
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
14 * the terms of a license other than GNU General Public License
102
a3a2e5deb320 Updated contact address to support@hg4j.com
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
15 * contact TMate Software at support@hg4j.com
50
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
17 package org.tmatesoft.hg.repo;
50
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
456
909306e412e2 Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 424
diff changeset
19 import static org.tmatesoft.hg.util.LogFacility.Severity.Warn;
909306e412e2 Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 424
diff changeset
20
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
21 import java.io.BufferedReader;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
22 import java.io.File;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
23 import java.io.FileReader;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
24 import java.io.IOException;
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
25 import java.io.Reader;
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
26 import java.util.ArrayList;
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
27 import java.util.Collections;
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
28 import java.util.HashMap;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
29 import java.util.LinkedList;
50
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
30 import java.util.List;
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
31 import java.util.Map;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
32 import java.util.TreeMap;
50
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
33
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
34 import org.tmatesoft.hg.core.Nodeid;
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
35
50
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
36 /**
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
37 * @see http://mercurial.selenic.com/wiki/TagDesign
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
38 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
39 * @author Artem Tikhomirov
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 50
diff changeset
40 * @author TMate Software Ltd.
50
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
41 */
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
42 public class HgTags {
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
43 // global tags come from ".hgtags"
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
44 // local come from ".hg/localtags"
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
45
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
46 private final HgRepository repo;
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
47
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
48 private final Map<Nodeid, List<String>> globalToName;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
49 private final Map<Nodeid, List<String>> localToName;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
50 private final Map<String, List<Nodeid>> globalFromName;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
51 private final Map<String, List<Nodeid>> localFromName;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
52
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
53 private Map<String, TagInfo> tags;
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
54
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
55 /*package-local*/ HgTags(HgRepository hgRepo) {
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
56 repo = hgRepo;
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
57 globalToName = new HashMap<Nodeid, List<String>>();
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
58 localToName = new HashMap<Nodeid, List<String>>();
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
59 globalFromName = new TreeMap<String, List<Nodeid>>();
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
60 localFromName = new TreeMap<String, List<Nodeid>>();
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
61 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
62
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
63 /*package-local*/ void readLocal(File localTags) throws IOException {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
64 if (localTags == null || localTags.isDirectory()) {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
65 throw new IllegalArgumentException(String.valueOf(localTags));
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
66 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
67 read(localTags, localToName, localFromName);
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
68 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
69
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
70 /*package-local*/ void readGlobal(File globalTags) throws IOException {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
71 if (globalTags == null || globalTags.isDirectory()) {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
72 throw new IllegalArgumentException(String.valueOf(globalTags));
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
73 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
74 read(globalTags, globalToName, globalFromName);
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
75 }
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
76
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
77 /*package-local*/ void readGlobal(Reader globalTags) throws IOException {
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
78 BufferedReader r = null;
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
79 try {
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
80 r = new BufferedReader(globalTags);
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
81 read(r, globalToName, globalFromName);
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
82 } finally {
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
83 if (r != null) {
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
84 r.close();
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
85 }
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
86 }
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
87 }
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
88
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
89 private void read(File f, Map<Nodeid,List<String>> nid2name, Map<String, List<Nodeid>> name2nid) throws IOException {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
90 if (!f.canRead()) {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
91 return;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
92 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
93 BufferedReader r = null;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
94 try {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
95 r = new BufferedReader(new FileReader(f));
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
96 read(r, nid2name, name2nid);
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
97 } finally {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
98 if (r != null) {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
99 r.close();
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
100 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
101 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
102 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
103
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
104 private void read(BufferedReader reader, Map<Nodeid,List<String>> nid2name, Map<String, List<Nodeid>> name2nid) throws IOException {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
105 String line;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
106 while ((line = reader.readLine()) != null) {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
107 line = line.trim();
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
108 if (line.length() == 0) {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
109 continue;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
110 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
111 if (line.length() < 40+2 /*nodeid, space and at least single-char tagname*/) {
490
b3c16d1aede0 Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 456
diff changeset
112 repo.getSessionContext().getLog().dump(getClass(), Warn, "Bad tags line: %s", line);
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
113 continue;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
114 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
115 int spacePos = line.indexOf(' ');
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
116 if (spacePos != -1) {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
117 assert spacePos == 40;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
118 final byte[] nodeidBytes = line.substring(0, spacePos).getBytes();
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
119 Nodeid nid = Nodeid.fromAscii(nodeidBytes, 0, nodeidBytes.length);
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
120 String tagName = line.substring(spacePos+1);
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
121 List<Nodeid> nids = name2nid.get(tagName);
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
122 if (nids == null) {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
123 nids = new LinkedList<Nodeid>();
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
124 nids.add(nid);
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
125 // tagName is substring of full line, thus need a copy to let the line be GC'ed
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
126 // new String(tagName.toCharArray()) is more expressive, but results in 1 extra arraycopy
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
127 tagName = new String(tagName);
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
128 name2nid.put(tagName, nids);
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
129 } else if (!nid.equals(nids.get(0))) {
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
130 // Alternatively, !nids.contains(nid) might have come to mind.
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
131 // However, I guess that 'tag history' means we need to record each change of revision
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
132 // associated with the tag, i.e. imagine project evolution:
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
133 // tag1=r1, tag1=r2, tag1=r1. If we choose !contains, list top of tag1 would point to r2
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
134 // while we need it to point to r1.
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
135 // In fact, there are still possible odd patterns in name2nid list, e.g.
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
136 // when tag was removed and added back(initially rev1 tag1, on removal *added* nullrev tag1),
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
137 // then added back (rev2 tag1).
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
138 // name2nid would list (rev2 nullrev rev1) as many times, as there were revisions of the .hgtags file
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
139 // See cpython "v2.4.3c1" revision for example.
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
140 // It doesn't seem to hurt (unless there are clients that care about tag history and depend on
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
141 // unique revisions there), XXX but better to be fixed (not sure how, though)
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
142 ((LinkedList<Nodeid>) nids).addFirst(nid);
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
143 // XXX repo.getNodeidCache().nodeid(nid);
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
144 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
145 List<String> revTags = nid2name.get(nid);
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
146 if (revTags == null) {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
147 revTags = new LinkedList<String>();
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
148 revTags.add(tagName);
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
149 nid2name.put(nid, revTags);
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
150 } else if (!revTags.contains(tagName)) {
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
151 // !contains because we don't care about order of the tags per revision
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
152 revTags.add(tagName);
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
153 }
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
154
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
155 } else {
490
b3c16d1aede0 Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 456
diff changeset
156 repo.getSessionContext().getLog().dump(getClass(), Warn, "Bad tags line: %s", line);
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
157 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
158 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
159 }
50
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
160
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
161 public List<String> tags(Nodeid nid) {
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
162 ArrayList<String> rv = new ArrayList<String>(5);
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
163 List<String> l;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
164 if ((l = localToName.get(nid)) != null) {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
165 rv.addAll(l);
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
166 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
167 if ((l = globalToName.get(nid)) != null) {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
168 rv.addAll(l);
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
169 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
170 return rv;
50
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
171 }
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
172
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
173 public boolean isTagged(Nodeid nid) {
104
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
174 return localToName.containsKey(nid) || globalToName.containsKey(nid);
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
175 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
176
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
177 public List<Nodeid> tagged(String tagName) {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
178 ArrayList<Nodeid> rv = new ArrayList<Nodeid>(5);
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
179 List<Nodeid> l;
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
180 if ((l = localFromName.get(tagName)) != null) {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
181 rv.addAll(l);
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
182 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
183 if ((l = globalFromName.get(tagName)) != null) {
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
184 rv.addAll(l);
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
185 }
54562de502f7 Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
186 return rv;
50
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
187 }
344
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
188
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
189 /**
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
190 * All tag entries from the repository, for both active and removed tags
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
191 */
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
192 public Map<String, TagInfo> getAllTags() {
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
193 if (tags == null) {
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
194 tags = new TreeMap<String, TagInfo>();
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
195 for (String t : globalFromName.keySet()) {
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
196 tags.put(t, new TagInfo(t));
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
197 }
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
198 for (String t : localFromName.keySet()) {
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
199 tags.put(t, new TagInfo(t));
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
200 }
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
201 tags = Collections.unmodifiableMap(tags);
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
202 }
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
203 return tags;
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
204 }
344
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
205
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
206 /**
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
207 * Tags that are in use in the repository, unlike {@link #getAllTags()} doesn't list removed tags.
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
208 */
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
209 public Map<String, TagInfo> getActiveTags() {
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
210 TreeMap<String, TagInfo> rv = new TreeMap<String, TagInfo>();
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
211 for (Map.Entry<String, TagInfo> e : getAllTags().entrySet()) {
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
212 if (!e.getValue().isRemoved()) {
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
213 rv.put(e.getKey(), e.getValue());
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
214 }
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
215 }
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
216 return rv;
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
217 }
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
218
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
219
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
220 public final class TagInfo {
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
221 private final String name;
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
222 private String branch;
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
223
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
224 TagInfo(String tagName) {
344
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
225 name = tagName;
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
226 }
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
227 public String name() {
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
228 return name;
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
229 }
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
230
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
231 public boolean isLocal() {
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
232 return localFromName.containsKey(name);
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
233 }
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
234
354
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 344
diff changeset
235 public String branch() throws HgInvalidControlFileException {
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
236 if (branch == null) {
367
2fadf8695f8a Use 'revision index' instead of the vague 'local revision number' concept in the API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
237 int x = repo.getChangelog().getRevisionIndex(revision());
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
238 branch = repo.getChangelog().range(x, x).get(0).branch();
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
239 }
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
240 return branch;
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
241 }
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
242 public Nodeid revision() {
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
243 if (isLocal()) {
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
244 return localFromName.get(name).get(0);
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
245 }
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
246 return globalFromName.get(name).get(0);
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
247 }
344
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
248
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
249 /**
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
250 * @return <code>true</code> if this tag entry describes tag removal
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
251 */
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
252 public boolean isRemoved() {
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
253 return revision().isNull();
168f1994de7e Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
254 }
234
b2cfbe46f9b6 HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 104
diff changeset
255 }
50
f1db8610da62 Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
256 }