Mercurial > hg4j
annotate src/org/tmatesoft/hg/repo/HgTags.java @ 603:707b5c7c6fa4
Refactor HgBlameFacility: relevant action methods moved to proper home (HgDataFile), as facility doesn't provide anything but packaging of relevant methods/interfaces
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 06 May 2013 18:29:57 +0200 |
parents | d9c07e1432c4 |
children | 5c68567b3645 |
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 /* |
535
d9c07e1432c4
Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
2 * Copyright (c) 2011-2013 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 |
535
d9c07e1432c4
Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
19 import static org.tmatesoft.hg.util.LogFacility.Severity.Error; |
456
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
20 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
|
21 |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
22 import java.io.BufferedReader; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
23 import java.io.File; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
24 import java.io.FileReader; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
25 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
|
26 import java.io.Reader; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
27 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
|
28 import java.util.Collections; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
29 import java.util.HashMap; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
30 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
|
31 import java.util.List; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
32 import java.util.Map; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
33 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
|
34 |
535
d9c07e1432c4
Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
35 import org.tmatesoft.hg.core.HgBadNodeidFormatException; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
36 import org.tmatesoft.hg.core.Nodeid; |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
37 |
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 /** |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
39 * @see http://mercurial.selenic.com/wiki/TagDesign |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
40 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
41 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
42 * @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
|
43 */ |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 public class HgTags { |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
45 // global tags come from ".hgtags" |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
46 // local come from ".hg/localtags" |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
47 |
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
|
48 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
|
49 |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
50 private final Map<Nodeid, List<String>> globalToName; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
51 private final Map<Nodeid, List<String>> localToName; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
52 private final Map<String, List<Nodeid>> globalFromName; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
53 private final Map<String, List<Nodeid>> localFromName; |
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 private Map<String, TagInfo> tags; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
56 |
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
|
57 /*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
|
58 repo = hgRepo; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
59 globalToName = new HashMap<Nodeid, List<String>>(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
60 localToName = new HashMap<Nodeid, List<String>>(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
61 globalFromName = new TreeMap<String, List<Nodeid>>(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
62 localFromName = new TreeMap<String, List<Nodeid>>(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
63 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
64 |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
65 /*package-local*/ void readLocal(File localTags) throws IOException { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
66 if (localTags == null || localTags.isDirectory()) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
67 throw new IllegalArgumentException(String.valueOf(localTags)); |
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 read(localTags, localToName, localFromName); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
70 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
71 |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
72 /*package-local*/ void readGlobal(File globalTags) throws IOException { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
73 if (globalTags == null || globalTags.isDirectory()) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
74 throw new IllegalArgumentException(String.valueOf(globalTags)); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
75 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
76 read(globalTags, globalToName, globalFromName); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
77 } |
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
|
78 |
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 /*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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 } 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
|
85 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
|
86 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
|
87 } |
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
|
88 } |
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
|
89 } |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
90 |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
91 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
|
92 if (!f.canRead()) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
93 return; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
94 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
95 BufferedReader r = null; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
96 try { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
97 r = new BufferedReader(new FileReader(f)); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
98 read(r, nid2name, name2nid); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
99 } finally { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
100 if (r != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
101 r.close(); |
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 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
105 |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
106 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
|
107 String line; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
108 while ((line = reader.readLine()) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
109 line = line.trim(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
110 if (line.length() == 0) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
111 continue; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
112 } |
535
d9c07e1432c4
Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
113 final int spacePos = line.indexOf(' '); |
d9c07e1432c4
Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
114 if (line.length() < 40+2 /*nodeid, space and at least single-char tagname*/ || spacePos != 40) { |
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
|
115 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
|
116 continue; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
117 } |
535
d9c07e1432c4
Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
118 try { |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
119 assert spacePos == 40; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
120 final byte[] nodeidBytes = line.substring(0, spacePos).getBytes(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
121 Nodeid nid = Nodeid.fromAscii(nodeidBytes, 0, nodeidBytes.length); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
122 String tagName = line.substring(spacePos+1); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
123 List<Nodeid> nids = name2nid.get(tagName); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
124 if (nids == null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
125 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
|
126 nids.add(nid); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
127 // 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
|
128 // 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
|
129 tagName = new String(tagName); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
130 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
|
131 } 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
|
132 // 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
|
133 // 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
|
134 // 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
|
135 // 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
|
136 // 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
|
137 // 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
|
138 // 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
|
139 // 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
|
140 // 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
|
141 // 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
|
142 // 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
|
143 // 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
|
144 ((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
|
145 // XXX repo.getNodeidCache().nodeid(nid); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
146 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
147 List<String> revTags = nid2name.get(nid); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
148 if (revTags == null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
149 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
|
150 revTags.add(tagName); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
151 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
|
152 } 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
|
153 // !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
|
154 revTags.add(tagName); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
155 } |
535
d9c07e1432c4
Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
156 } catch (HgBadNodeidFormatException ex) { |
d9c07e1432c4
Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
157 repo.getSessionContext().getLog().dump(getClass(), Error, "Bad revision '%s' in line '%s':%s", line.substring(0, spacePos), line, ex.getMessage()); |
104
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 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
160 } |
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
161 |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
162 public List<String> tags(Nodeid nid) { |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
163 ArrayList<String> rv = new ArrayList<String>(5); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
164 List<String> l; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
165 if ((l = localToName.get(nid)) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
166 rv.addAll(l); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
167 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
168 if ((l = globalToName.get(nid)) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
169 rv.addAll(l); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
170 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
171 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
|
172 } |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
173 |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
174 public boolean isTagged(Nodeid nid) { |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
175 return localToName.containsKey(nid) || globalToName.containsKey(nid); |
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 |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
178 public List<Nodeid> tagged(String tagName) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
179 ArrayList<Nodeid> rv = new ArrayList<Nodeid>(5); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
180 List<Nodeid> l; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
181 if ((l = localFromName.get(tagName)) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
182 rv.addAll(l); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
183 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
184 if ((l = globalFromName.get(tagName)) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
185 rv.addAll(l); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
186 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
187 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
|
188 } |
344
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 /** |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
191 * 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
|
192 */ |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
193 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
|
194 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
|
195 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
|
196 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
|
197 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
|
198 } |
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 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
|
200 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
|
201 } |
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 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
|
203 } |
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 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
|
205 } |
344
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 /** |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
208 * 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
|
209 */ |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
210 public Map<String, TagInfo> getActiveTags() { |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
211 TreeMap<String, TagInfo> rv = new TreeMap<String, TagInfo>(); |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
212 for (Map.Entry<String, TagInfo> e : getAllTags().entrySet()) { |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
213 if (!e.getValue().isRemoved()) { |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
214 rv.put(e.getKey(), e.getValue()); |
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 } |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
217 return rv; |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
218 } |
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
|
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 |
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 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
|
222 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
|
223 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
|
224 |
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
|
225 TagInfo(String tagName) { |
344
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
226 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
|
227 } |
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 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
|
229 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
|
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 |
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 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
|
233 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
|
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
|
235 |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
344
diff
changeset
|
236 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
|
237 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
|
238 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
|
239 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
|
240 } |
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 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
|
242 } |
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 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
|
244 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
|
245 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
|
246 } |
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 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
|
248 } |
344
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 /** |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
251 * @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
|
252 */ |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
253 public boolean isRemoved() { |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
254 return revision().isNull(); |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
255 } |
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
|
256 } |
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
257 } |