Mercurial > hg4j
annotate src/org/tmatesoft/hg/repo/HgTags.java @ 443:072b5f3ed0c8
Path to tell immediate parent-child relationship; more powerful scope impl; tests for both
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 04 May 2012 17:59:22 +0200 |
parents | 6437d261048a |
children | 909306e412e2 |
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 |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
32 import org.tmatesoft.hg.core.Nodeid; |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
33 |
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 /** |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
35 * @see http://mercurial.selenic.com/wiki/TagDesign |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
36 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
37 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
38 * @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
|
39 */ |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 public class HgTags { |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
41 // global tags come from ".hgtags" |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
42 // local come from ".hg/localtags" |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
43 |
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
|
44 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
|
45 |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
46 private final Map<Nodeid, List<String>> globalToName; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
47 private final Map<Nodeid, List<String>> localToName; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
48 private final Map<String, List<Nodeid>> globalFromName; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
49 private final Map<String, List<Nodeid>> localFromName; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
50 |
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
|
51 private Map<String, TagInfo> tags; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
52 |
234
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
53 /*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
|
54 repo = hgRepo; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
55 globalToName = new HashMap<Nodeid, List<String>>(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
56 localToName = new HashMap<Nodeid, List<String>>(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
57 globalFromName = new TreeMap<String, List<Nodeid>>(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
58 localFromName = new TreeMap<String, List<Nodeid>>(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
59 } |
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 /*package-local*/ void readLocal(File localTags) throws IOException { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
62 if (localTags == null || localTags.isDirectory()) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
63 throw new IllegalArgumentException(String.valueOf(localTags)); |
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 read(localTags, localToName, localFromName); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
66 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
67 |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
68 /*package-local*/ void readGlobal(File globalTags) throws IOException { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
69 if (globalTags == null || globalTags.isDirectory()) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
70 throw new IllegalArgumentException(String.valueOf(globalTags)); |
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 read(globalTags, globalToName, globalFromName); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
73 } |
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
|
74 |
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 /*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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 } 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
|
81 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
|
82 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
|
83 } |
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 } |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
86 |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
87 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
|
88 if (!f.canRead()) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
89 return; |
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 BufferedReader r = null; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
92 try { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
93 r = new BufferedReader(new FileReader(f)); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
94 read(r, nid2name, name2nid); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
95 } finally { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
96 if (r != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
97 r.close(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
98 } |
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 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
|
103 String line; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
104 while ((line = reader.readLine()) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
105 line = line.trim(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
106 if (line.length() == 0) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
107 continue; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
108 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
109 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
|
110 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
|
111 continue; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
112 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
113 int spacePos = line.indexOf(' '); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
114 if (spacePos != -1) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
115 assert spacePos == 40; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
116 final byte[] nodeidBytes = line.substring(0, spacePos).getBytes(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
117 Nodeid nid = Nodeid.fromAscii(nodeidBytes, 0, nodeidBytes.length); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
118 String tagName = line.substring(spacePos+1); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
119 List<Nodeid> nids = name2nid.get(tagName); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
120 if (nids == null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
121 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
|
122 nids.add(nid); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
123 // 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
|
124 // 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
|
125 tagName = new String(tagName); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
126 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
|
127 } 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
|
128 // 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
|
129 // 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
|
130 // 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
|
131 // 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
|
132 // 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
|
133 // 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
|
134 // 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
|
135 // 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
|
136 // 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
|
137 // 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
|
138 // 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
|
139 // 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
|
140 ((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
|
141 // XXX repo.getNodeidCache().nodeid(nid); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
142 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
143 List<String> revTags = nid2name.get(nid); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
144 if (revTags == null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
145 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
|
146 revTags.add(tagName); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
147 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
|
148 } 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
|
149 // !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
|
150 revTags.add(tagName); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
151 } |
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 |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
153 } else { |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
234
diff
changeset
|
154 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
|
155 } |
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 } |
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
158 |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
159 public List<String> tags(Nodeid nid) { |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
160 ArrayList<String> rv = new ArrayList<String>(5); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
161 List<String> l; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
162 if ((l = localToName.get(nid)) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
163 rv.addAll(l); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
164 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
165 if ((l = globalToName.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 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
|
169 } |
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 public boolean isTagged(Nodeid nid) { |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
172 return localToName.containsKey(nid) || globalToName.containsKey(nid); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
173 } |
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 public List<Nodeid> tagged(String tagName) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
176 ArrayList<Nodeid> rv = new ArrayList<Nodeid>(5); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
177 List<Nodeid> l; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
178 if ((l = localFromName.get(tagName)) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
179 rv.addAll(l); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
180 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
181 if ((l = globalFromName.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 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
|
185 } |
344
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
186 |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
187 /** |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
188 * 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
|
189 */ |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
190 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
|
191 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
|
192 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
|
193 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
|
194 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
|
195 } |
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 : 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
|
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 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
|
200 } |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
201 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
|
202 } |
344
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
203 |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
204 /** |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
205 * 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
|
206 */ |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
207 public Map<String, TagInfo> getActiveTags() { |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
208 TreeMap<String, TagInfo> rv = new TreeMap<String, TagInfo>(); |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
209 for (Map.Entry<String, TagInfo> e : getAllTags().entrySet()) { |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
210 if (!e.getValue().isRemoved()) { |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
211 rv.put(e.getKey(), e.getValue()); |
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 return rv; |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
215 } |
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
|
216 |
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
|
217 |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
218 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
|
219 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
|
220 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
|
221 |
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 TagInfo(String tagName) { |
344
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
223 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
|
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 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
|
226 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
|
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 |
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 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
|
230 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
|
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 |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
344
diff
changeset
|
233 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
|
234 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
|
235 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
|
236 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
|
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 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
|
239 } |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
240 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
|
241 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
|
242 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
|
243 } |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
244 return 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
|
245 } |
344
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
246 |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
247 /** |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
248 * @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
|
249 */ |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
250 public boolean isRemoved() { |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
251 return revision().isNull(); |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
252 } |
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
|
253 } |
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
254 } |