Mercurial > hg4j
annotate src/org/tmatesoft/hg/repo/HgTags.java @ 713:661e77dc88ba tip
Mac support: respect Mac alternatives of command-line arguments for common unix tools
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Sun, 03 Aug 2014 18:09:00 +0200 |
parents | 6526d8adbc0f |
children |
rev | line source |
---|---|
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
535
d9c07e1432c4
Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
2 * Copyright (c) 2011-2013 TMate Software Ltd |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
3 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
7 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
11 * GNU General Public License for more details. |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
12 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
13 * For information on how to redistribute this software under |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
102
a3a2e5deb320
Updated contact address to support@hg4j.com
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
17 package org.tmatesoft.hg.repo; |
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
19 import static org.tmatesoft.hg.repo.HgRepositoryFiles.HgLocalTags; |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
20 import static org.tmatesoft.hg.repo.HgRepositoryFiles.HgTags; |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
21 import static org.tmatesoft.hg.util.LogFacility.Severity.*; |
535
d9c07e1432c4
Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
22 import static org.tmatesoft.hg.util.LogFacility.Severity.Error; |
456
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
23 import static org.tmatesoft.hg.util.LogFacility.Severity.Warn; |
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
24 |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
25 import java.io.BufferedReader; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
26 import java.io.File; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
27 import java.io.FileReader; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
28 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
|
29 import java.io.Reader; |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
30 import java.io.StringReader; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
31 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
|
32 import java.util.Collections; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
33 import java.util.HashMap; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
34 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
|
35 import java.util.List; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
36 import java.util.Map; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
37 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
|
38 |
535
d9c07e1432c4
Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
39 import org.tmatesoft.hg.core.HgBadNodeidFormatException; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
40 import org.tmatesoft.hg.core.Nodeid; |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
41 import org.tmatesoft.hg.internal.ByteArrayChannel; |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
42 import org.tmatesoft.hg.internal.ChangelogMonitor; |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
43 import org.tmatesoft.hg.internal.FileChangeMonitor; |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
44 import org.tmatesoft.hg.internal.Internals; |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
45 import org.tmatesoft.hg.util.CancelledException; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
46 |
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 /** |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
48 * @see http://mercurial.selenic.com/wiki/TagDesign |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
49 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
50 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
50
diff
changeset
|
51 * @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
|
52 */ |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
53 public class HgTags { |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
54 // global tags come from ".hgtags" |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
55 // local come from ".hg/localtags" |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
56 |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
57 private final Internals repo; |
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
|
58 |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
59 private final Map<Nodeid, List<String>> globalToName; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
60 private final Map<Nodeid, List<String>> localToName; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
61 private final Map<String, List<Nodeid>> globalFromName; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
62 private final Map<String, List<Nodeid>> localFromName; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
63 |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
64 private FileChangeMonitor globalTagsFileMonitor, localTagsFileMonitor; |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
65 private ChangelogMonitor repoChangeMonitor; |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
66 |
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
|
67 private Map<String, TagInfo> tags; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
68 |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
69 /*package-local*/ HgTags(Internals internalRepo) { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
70 repo = internalRepo; |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
71 globalToName = new HashMap<Nodeid, List<String>>(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
72 localToName = new HashMap<Nodeid, List<String>>(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
73 globalFromName = new TreeMap<String, List<Nodeid>>(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
74 localFromName = new TreeMap<String, List<Nodeid>>(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
75 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
76 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
610
diff
changeset
|
77 /*package-local*/ void read() throws HgRuntimeException { |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
78 readTagsFromHistory(); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
79 readGlobal(); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
80 readLocal(); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
81 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
82 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
610
diff
changeset
|
83 private void readTagsFromHistory() throws HgRuntimeException { |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
84 HgDataFile hgTags = repo.getRepo().getFileNode(HgTags.getPath()); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
85 if (hgTags.exists()) { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
86 for (int i = 0; i <= hgTags.getLastRevision(); i++) { // TODO post-1.0 in fact, would be handy to have walk(start,end) |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
87 // method for data files as well, though it looks odd. |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
88 try { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
89 ByteArrayChannel sink = new ByteArrayChannel(); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
90 hgTags.content(i, sink); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
91 final String content = new String(sink.toArray(), "UTF8"); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
92 readGlobal(new StringReader(content)); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
93 } catch (CancelledException ex) { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
94 // IGNORE, can't happen, we did not configure cancellation |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
95 repo.getLog().dump(getClass(), Debug, ex, null); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
96 } catch (IOException ex) { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
97 // UnsupportedEncodingException can't happen (UTF8) |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
98 // only from readGlobal. Need to reconsider exceptions thrown from there: |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
99 // BufferedReader wraps String and unlikely to throw IOException, perhaps, log is enough? |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
100 repo.getLog().dump(getClass(), Error, ex, null); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
101 // XXX need to decide what to do this. failure to read single revision shall not break complete cycle |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
102 } |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
103 } |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
104 } |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
105 if (repoChangeMonitor == null) { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
106 repoChangeMonitor = new ChangelogMonitor(repo.getRepo()); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
107 } |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
108 repoChangeMonitor.touch(); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
109 } |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
110 |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
111 private void readLocal() throws HgInvalidControlFileException { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
112 File localTags = repo.getRepositoryFile(HgLocalTags); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
113 if (localTags.canRead() && localTags.isFile()) { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
114 read(localTags, localToName, localFromName); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
115 } |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
116 if (localTagsFileMonitor == null) { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
117 localTagsFileMonitor = new FileChangeMonitor(localTags); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
118 } |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
119 localTagsFileMonitor.touch(this); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
120 } |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
121 |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
122 private void readGlobal() throws HgInvalidControlFileException { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
123 File globalTags = repo.getRepositoryFile(HgTags); // XXX replace with HgDataFile.workingCopy |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
124 if (globalTags.canRead() && globalTags.isFile()) { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
125 read(globalTags, globalToName, globalFromName); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
126 } |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
127 if (globalTagsFileMonitor == null) { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
128 globalTagsFileMonitor = new FileChangeMonitor(globalTags); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
129 } |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
130 globalTagsFileMonitor.touch(this); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
131 } |
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
|
132 |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
133 private void readGlobal(Reader globalTags) throws 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
|
134 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
|
135 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
|
136 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
|
137 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
|
138 } 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
|
139 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
|
140 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
|
141 } |
b2cfbe46f9b6
HgTags got TagInfo to 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 } |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
143 } |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
144 |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
145 private void read(File f, Map<Nodeid,List<String>> nid2name, Map<String, List<Nodeid>> name2nid) throws HgInvalidControlFileException { |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
146 if (!f.canRead()) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
147 return; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
148 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
149 BufferedReader r = null; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
150 try { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
151 r = new BufferedReader(new FileReader(f)); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
152 read(r, nid2name, name2nid); |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
153 } catch (IOException ex) { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
154 repo.getLog().dump(getClass(), Error, ex, null); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
155 throw new HgInvalidControlFileException("Failed to read tags", ex, f); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
156 } finally { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
157 if (r != null) { |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
158 try { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
159 r.close(); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
160 } catch (IOException ex) { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
161 // since it's read operation, do not treat close failure as error, but let user know, anyway |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
162 repo.getLog().dump(getClass(), Warn, ex, null); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
163 } |
104
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 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
166 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
167 |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
168 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
|
169 String line; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
170 while ((line = reader.readLine()) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
171 line = line.trim(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
172 if (line.length() == 0) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
173 continue; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
174 } |
535
d9c07e1432c4
Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
175 final int spacePos = line.indexOf(' '); |
d9c07e1432c4
Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
176 if (line.length() < 40+2 /*nodeid, space and at least single-char tagname*/ || spacePos != 40) { |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
177 repo.getLog().dump(getClass(), Warn, "Bad tags line: %s", line); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
178 continue; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
179 } |
535
d9c07e1432c4
Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
180 try { |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
181 assert spacePos == 40; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
182 final byte[] nodeidBytes = line.substring(0, spacePos).getBytes(); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
183 Nodeid nid = Nodeid.fromAscii(nodeidBytes, 0, nodeidBytes.length); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
184 String tagName = line.substring(spacePos+1); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
185 List<Nodeid> nids = name2nid.get(tagName); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
186 if (nids == null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
187 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
|
188 nids.add(nid); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
189 // 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
|
190 // 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
|
191 tagName = new String(tagName); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
192 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
|
193 } 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
|
194 // 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
|
195 // 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
|
196 // 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
|
197 // 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
|
198 // 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
|
199 // 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
|
200 // 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
|
201 // 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
|
202 // 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
|
203 // 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
|
204 // 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
|
205 // 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
|
206 ((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
|
207 // XXX repo.getNodeidCache().nodeid(nid); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
208 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
209 List<String> revTags = nid2name.get(nid); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
210 if (revTags == null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
211 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
|
212 revTags.add(tagName); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
213 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
|
214 } 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
|
215 // !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
|
216 revTags.add(tagName); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
217 } |
535
d9c07e1432c4
Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
218 } catch (HgBadNodeidFormatException ex) { |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
219 repo.getLog().dump(getClass(), Error, "Bad revision '%s' in line '%s':%s", line.substring(0, spacePos), line, ex.getMessage()); |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
220 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
221 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
222 } |
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
223 |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
224 public List<String> tags(Nodeid nid) { |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
225 ArrayList<String> rv = new ArrayList<String>(5); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
226 List<String> l; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
227 if ((l = localToName.get(nid)) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
228 rv.addAll(l); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
229 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
230 if ((l = globalToName.get(nid)) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
231 rv.addAll(l); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
232 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
233 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
|
234 } |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
235 |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
236 public boolean isTagged(Nodeid nid) { |
104
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
237 return localToName.containsKey(nid) || globalToName.containsKey(nid); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
238 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
239 |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
240 public List<Nodeid> tagged(String tagName) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
241 ArrayList<Nodeid> rv = new ArrayList<Nodeid>(5); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
242 List<Nodeid> l; |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
243 if ((l = localFromName.get(tagName)) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
244 rv.addAll(l); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
245 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
246 if ((l = globalFromName.get(tagName)) != null) { |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
247 rv.addAll(l); |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
248 } |
54562de502f7
Preliminary tags implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
249 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
|
250 } |
344
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
251 |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
252 /** |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
253 * 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
|
254 */ |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
255 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
|
256 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
|
257 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
|
258 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
|
259 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
|
260 } |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
261 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
|
262 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
|
263 } |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
264 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
|
265 } |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
266 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
|
267 } |
344
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
268 |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
269 /** |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
270 * 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
|
271 */ |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
272 public Map<String, TagInfo> getActiveTags() { |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
273 TreeMap<String, TagInfo> rv = new TreeMap<String, TagInfo>(); |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
274 for (Map.Entry<String, TagInfo> e : getAllTags().entrySet()) { |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
275 if (!e.getValue().isRemoved()) { |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
276 rv.put(e.getKey(), e.getValue()); |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
277 } |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
278 } |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
279 return rv; |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
280 } |
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
|
281 |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
282 // can be called only after instance has been initialized (#read() invoked) |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
610
diff
changeset
|
283 /*package-local*/void reloadIfChanged() throws HgRuntimeException { |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
284 assert repoChangeMonitor != null; |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
285 assert localTagsFileMonitor != null; |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
286 assert globalTagsFileMonitor != null; |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
287 if (repoChangeMonitor.isChanged() || globalTagsFileMonitor.changed(this)) { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
288 globalFromName.clear(); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
289 globalToName.clear(); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
290 readTagsFromHistory(); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
291 readGlobal(); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
292 tags = null; |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
293 } |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
294 if (localTagsFileMonitor.changed(this)) { |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
295 readLocal(); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
296 tags = null; |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
297 } |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
298 } |
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
|
299 |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
300 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
|
301 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
|
302 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
|
303 |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
304 TagInfo(String tagName) { |
344
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
305 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
|
306 } |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
307 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
|
308 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
|
309 } |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
310 |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
311 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
|
312 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
|
313 } |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
314 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
610
diff
changeset
|
315 /** |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
610
diff
changeset
|
316 * @return name of the branch this tag belongs to, never <code>null</code> |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
610
diff
changeset
|
317 * @throws HgInvalidRevisionException if revision of the tag is not a valid changeset revision. <em>Runtime exception</em> |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
610
diff
changeset
|
318 * @throws HgInvalidControlFileException if failed to access revlog index/data entry. <em>Runtime exception</em> |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
610
diff
changeset
|
319 * @throws HgRuntimeException subclass thereof to indicate other issues with the library. <em>Runtime exception</em> |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
610
diff
changeset
|
320 */ |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
610
diff
changeset
|
321 public String branch() throws HgRuntimeException { |
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
|
322 if (branch == null) { |
610
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
323 int x = repo.getRepo().getChangelog().getRevisionIndex(revision()); |
5c68567b3645
Refresh tags, branches, bookmarks and ignore when their files (or csets in the repo) are changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
535
diff
changeset
|
324 branch = repo.getRepo().getChangelog().range(x, x).get(0).branch(); |
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
|
325 } |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
326 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
|
327 } |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
328 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
|
329 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
|
330 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
|
331 } |
b2cfbe46f9b6
HgTags got TagInfo to access tags. Tags are read from all branches/revisions now, not only working copy
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
104
diff
changeset
|
332 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
|
333 } |
344
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
334 |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
335 /** |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
336 * @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
|
337 */ |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
338 public boolean isRemoved() { |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
339 return revision().isNull(); |
168f1994de7e
Distinguish active from removed tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
340 } |
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
|
341 } |
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
342 } |