Mercurial > hg4j
annotate src/org/tmatesoft/hg/repo/HgTags.java @ 420:6c22bdc0bdfd
Respect long offsets in revlogs
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 22 Mar 2012 22:56:01 +0100 |
parents | 2fadf8695f8a |
children | 9c9c442b5f2e |
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 /* |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
2 * Copyright (c) 2011 TMate Software Ltd |
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 |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
19 import java.io.BufferedReader; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
20 import java.io.File; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
21 import java.io.FileReader; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
22 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
|
23 import java.io.Reader; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
24 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
|
25 import java.util.Collections; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
26 import java.util.HashMap; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
27 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
|
28 import java.util.List; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
29 import java.util.Map; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
30 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
|
31 |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
344
diff
changeset
|
32 import org.tmatesoft.hg.core.HgInvalidControlFileException; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
33 import org.tmatesoft.hg.core.Nodeid; |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
34 |
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 /** |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
36 * @see http://mercurial.selenic.com/wiki/TagDesign |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
37 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
38 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
39 * @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
|
40 */ |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
41 public class HgTags { |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
42 // global tags come from ".hgtags" |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
43 // local come from ".hg/localtags" |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
44 |
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
|
45 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
|
46 |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
47 private final Map<Nodeid, List<String>> globalToName; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
48 private final Map<Nodeid, List<String>> localToName; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
49 private final Map<String, List<Nodeid>> globalFromName; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
50 private final Map<String, List<Nodeid>> localFromName; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
51 |
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
|
52 private Map<String, TagInfo> tags; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
53 |
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
|
54 /*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
|
55 repo = hgRepo; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
56 globalToName = new HashMap<Nodeid, List<String>>(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
57 localToName = new HashMap<Nodeid, List<String>>(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
58 globalFromName = new TreeMap<String, List<Nodeid>>(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
59 localFromName = new TreeMap<String, List<Nodeid>>(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
60 } |
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 /*package-local*/ void readLocal(File localTags) throws IOException { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
63 if (localTags == null || localTags.isDirectory()) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
64 throw new IllegalArgumentException(String.valueOf(localTags)); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
65 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
66 read(localTags, localToName, localFromName); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
67 } |
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 /*package-local*/ void readGlobal(File globalTags) throws IOException { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
70 if (globalTags == null || globalTags.isDirectory()) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
71 throw new IllegalArgumentException(String.valueOf(globalTags)); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
72 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
73 read(globalTags, globalToName, globalFromName); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
74 } |
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
|
75 |
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 /*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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 } 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
|
82 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
|
83 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
|
84 } |
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 } |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
87 |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
88 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
|
89 if (!f.canRead()) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
90 return; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
91 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
92 BufferedReader r = null; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
93 try { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
94 r = new BufferedReader(new FileReader(f)); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
95 read(r, nid2name, name2nid); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
96 } finally { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
97 if (r != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
98 r.close(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
99 } |
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 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
|
104 String line; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
105 while ((line = reader.readLine()) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
106 line = line.trim(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
107 if (line.length() == 0) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
108 continue; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
109 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
110 if (line.length() < 40+2 /*nodeid, space and at least single-char tagname*/) { |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
234
diff
changeset
|
111 repo.getContext().getLog().warn(getClass(), "Bad tags line: %s", line); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
112 continue; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
113 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
114 int spacePos = line.indexOf(' '); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
115 if (spacePos != -1) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
116 assert spacePos == 40; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
117 final byte[] nodeidBytes = line.substring(0, spacePos).getBytes(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
118 Nodeid nid = Nodeid.fromAscii(nodeidBytes, 0, nodeidBytes.length); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
119 String tagName = line.substring(spacePos+1); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
120 List<Nodeid> nids = name2nid.get(tagName); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
121 if (nids == null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
122 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
|
123 nids.add(nid); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
124 // 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
|
125 // 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
|
126 tagName = new String(tagName); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
127 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
|
128 } 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
|
129 // 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
|
130 // 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
|
131 // 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
|
132 // 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
|
133 // 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
|
134 // 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
|
135 // 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
|
136 // 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
|
137 // 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
|
138 // 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
|
139 // 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
|
140 // 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
|
141 ((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
|
142 // XXX repo.getNodeidCache().nodeid(nid); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
143 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
144 List<String> revTags = nid2name.get(nid); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
145 if (revTags == null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
146 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
|
147 revTags.add(tagName); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
148 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
|
149 } 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
|
150 // !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
|
151 revTags.add(tagName); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
152 } |
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
|
153 |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
154 } else { |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
234
diff
changeset
|
155 repo.getContext().getLog().warn(getClass(), "Bad tags line: %s", line); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
156 } |
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 } |
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
159 |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
160 public List<String> tags(Nodeid nid) { |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
161 ArrayList<String> rv = new ArrayList<String>(5); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
162 List<String> l; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
163 if ((l = localToName.get(nid)) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
164 rv.addAll(l); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
165 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
166 if ((l = globalToName.get(nid)) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
167 rv.addAll(l); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
168 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
169 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
|
170 } |
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 public boolean isTagged(Nodeid nid) { |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
173 return localToName.containsKey(nid) || globalToName.containsKey(nid); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
174 } |
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 public List<Nodeid> tagged(String tagName) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
177 ArrayList<Nodeid> rv = new ArrayList<Nodeid>(5); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
178 List<Nodeid> l; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
179 if ((l = localFromName.get(tagName)) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
180 rv.addAll(l); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
181 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
182 if ((l = globalFromName.get(tagName)) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
183 rv.addAll(l); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
184 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
185 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
|
186 } |
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
|
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 * @deprecated use {@link #getAllTags()} instead |
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 @Deprecated |
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
|
192 public Map<String, TagInfo> getTags() { |
344
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
193 return getAllTags(); |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
194 } |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
195 |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
196 /** |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
197 * 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
|
198 */ |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
199 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
|
200 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
|
201 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
|
202 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
|
203 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
|
204 } |
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 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
|
206 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
|
207 } |
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
|
208 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
|
209 } |
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
|
210 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
|
211 } |
344
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
212 |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
213 /** |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
214 * 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
|
215 */ |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
216 public Map<String, TagInfo> getActiveTags() { |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
217 TreeMap<String, TagInfo> rv = new TreeMap<String, TagInfo>(); |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
218 for (Map.Entry<String, TagInfo> e : getAllTags().entrySet()) { |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
219 if (!e.getValue().isRemoved()) { |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
220 rv.put(e.getKey(), e.getValue()); |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
221 } |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
222 } |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
223 return rv; |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
224 } |
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
|
225 |
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 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
|
228 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
|
229 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
|
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 TagInfo(String tagName) { |
344
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
232 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
|
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 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
|
235 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
|
236 } |
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 |
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 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
|
239 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
|
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 |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
344
diff
changeset
|
242 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
|
243 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
|
244 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
|
245 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
|
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 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
|
248 } |
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
|
249 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
|
250 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
|
251 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
|
252 } |
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
|
253 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
|
254 } |
344
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
255 |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
256 /** |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
257 * @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
|
258 */ |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
259 public boolean isRemoved() { |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
260 return revision().isNull(); |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
261 } |
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
|
262 } |
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
263 } |