annotate src/org/tmatesoft/hg/repo/HgBranches.java @ 238:4817d4ccc50e

Clean IOException reference
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 15 Jun 2011 18:06:39 +0200
parents 883300108179
children 4b661efb9374
rev   line source
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2011 TMate Software Ltd
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
3 *
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
6 * the Free Software Foundation; version 2 of the License.
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
7 *
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
11 * GNU General Public License for more details.
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12 *
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
13 * For information on how to redistribute this software under
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
14 * the terms of a license other than GNU General Public License
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
15 * contact TMate Software at support@hg4j.com
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
17 package org.tmatesoft.hg.repo;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
236
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
19 import java.io.BufferedReader;
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
20 import java.io.File;
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
21 import java.io.FileReader;
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
22 import java.io.IOException;
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23 import java.util.ArrayList;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
24 import java.util.Arrays;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
25 import java.util.Collections;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
26 import java.util.HashMap;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
27 import java.util.HashSet;
236
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
28 import java.util.LinkedHashSet;
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
29 import java.util.LinkedList;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
30 import java.util.List;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
31 import java.util.Map;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
32 import java.util.TreeMap;
236
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
33 import java.util.regex.Pattern;
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
34
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
35 import org.tmatesoft.hg.core.Nodeid;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
36 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
37 import org.tmatesoft.hg.util.ProgressSupport;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
38
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
39 /**
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
40 *
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
41 * @author Artem Tikhomirov
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
42 * @author TMate Software Ltd.
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
43 */
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
44 public class HgBranches {
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
45
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
46 private final Map<String, BranchInfo> branches = new TreeMap<String, BranchInfo>();
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
47 private final HgRepository repo;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
48
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
49 HgBranches(HgRepository hgRepo) {
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
50 repo = hgRepo;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
51 }
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
52
236
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
53 private int readCache() {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
54 File branchheadsCache = new File(repo.getRepositoryRoot(), "branchheads.cache");
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
55 int lastInCache = -1;
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
56 if (!branchheadsCache.canRead()) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
57 return lastInCache;
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
58 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
59 BufferedReader br = null;
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
60 final Pattern spacePattern = Pattern.compile(" ");
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
61 try {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
62 br = new BufferedReader(new FileReader(branchheadsCache));
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
63 String line = br.readLine();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
64 if (line == null || line.trim().length() == 0) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
65 return lastInCache;
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
66 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
67 String[] cacheIdentity = spacePattern.split(line.trim());
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
68 lastInCache = Integer.parseInt(cacheIdentity[1]);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
69 // XXX may want to check if nodeid of cset from repo.getChangelog() of lastInCache index match cacheIdentity[0]
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
70 //
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
71 while ((line = br.readLine()) != null) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
72 String[] elements = line.trim().split(" ");
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
73 if (elements.length < 2) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
74 // bad entry
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
75 continue;
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
76 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
77 Nodeid[] branchHeads = new Nodeid[elements.length - 1];
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
78 for (int i = 0; i < elements.length - 1; i++) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
79 branchHeads[i] = Nodeid.fromAscii(elements[i]);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
80 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
81 // I assume split returns substrings of the original string, hence copy of a branch name
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
82 String branchName = new String(elements[elements.length-1]);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
83 BranchInfo bi = new BranchInfo(branchName, branchHeads);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
84 branches.put(branchName, bi);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
85 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
86 return lastInCache;
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
87 } catch (IOException ex) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
88 ex.printStackTrace(); // XXX log error, but otherwise do nothing
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
89 } finally {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
90 if (br != null) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
91 try {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
92 br.close();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
93 } catch (IOException ex) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
94 ex.printStackTrace(); // ignore
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
95 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
96 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
97 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
98 return -1; // deliberately not lastInCache, to avoid anything but -1 when 1st line was read and there's error is in lines 2..end
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
99 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
100
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
101 void collect(final ProgressSupport ps) {
236
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
102 branches.clear();
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
103 ps.start(1 + repo.getChangelog().getRevisionCount() * 2);
236
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
104 //
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
105 int lastCached = readCache();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
106 /*
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
107 * Next code was supposed to fill missing aspects of the BranchInfo, but is too slow
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
108 *
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
109 if (lastCached != -1 && lastCached <= repo.getChangelog().getLastRevision()) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
110 LinkedList<BranchInfo> incompleteBranches = new LinkedList<HgBranches.BranchInfo>(branches.values());
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
111 for (BranchInfo bi : incompleteBranches) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
112 LinkedList<Nodeid> closedHeads = new LinkedList<Nodeid>();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
113 for (Nodeid h : bi.getHeads()) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
114 if ("1".equals(repo.getChangelog().changeset(h).extras().get("close"))) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
115 closedHeads.add(h);
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
116 }
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
117 }
236
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
118 HashSet<Nodeid> earliest = new HashSet<Nodeid>(bi.getHeads());
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
119 HashSet<Nodeid> visited = new HashSet<Nodeid>();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
120 ArrayList<Nodeid> parents = new ArrayList<Nodeid>(2);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
121 HashSet<Nodeid> candidate = new HashSet<Nodeid>();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
122 do {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
123 candidate.clear();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
124 for (Nodeid e : earliest) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
125 parents.clear();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
126 if (pw.appendParentsOf(e, parents)) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
127 // at least one parent
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
128 Nodeid p1 = parents.get(0);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
129 if (p1 != null && !visited.contains(p1) && bi.getName().equals(repo.getChangelog().changeset(p1).branch())) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
130 visited.add(p1);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
131 candidate.add(p1);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
132 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
133 Nodeid p2 = parents.size() > 1 ? parents.get(1) : null;
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
134 if (p2 != null && !visited.contains(p2) && bi.getName().equals(repo.getChangelog().changeset(p2).branch())) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
135 visited.add(p2);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
136 candidate.add(p2);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
137 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
138 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
139 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
140 if (!candidate.isEmpty()) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
141 earliest.clear();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
142 earliest.addAll(candidate);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
143 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
144 } while (!candidate.isEmpty());
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
145 // earliest can't be empty, we've started with non-empty heads.
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
146 Nodeid first = null;
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
147 if (earliest.size() == 1) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
148 first = earliest.iterator().next();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
149 } else {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
150 int earliestRevNum = Integer.MAX_VALUE;
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
151 for (Nodeid e : earliest) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
152 int x = repo.getChangelog().getLocalRevision(e);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
153 if (x < earliestRevNum) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
154 earliestRevNum = x;
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
155 first = e;
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
156 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
157 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
158 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
159 assert first != null;
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
160 System.out.println("Updated branch " + bi.getName());
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
161 branches.put(bi.getName(), new BranchInfo(bi.getName(), first, bi.getHeads().toArray(new Nodeid[0]), closedHeads.size() == bi.getHeads().size()));
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
162 }
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
163 }
236
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
164 */
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
165 if (lastCached != repo.getChangelog().getLastRevision()) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
166 final HgChangelog.ParentWalker pw = repo.getChangelog().new ParentWalker();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
167 pw.init();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
168 ps.worked(repo.getChangelog().getRevisionCount());
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
169 final HashMap<String, Nodeid> branchStart = new HashMap<String, Nodeid>();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
170 final HashMap<String, Nodeid> branchLastSeen = new HashMap<String, Nodeid>();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
171 final HashMap<String, List<Nodeid>> branchHeads = new HashMap<String, List<Nodeid>>();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
172 final HashSet<String> closedBranches = new HashSet<String>();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
173 HgChangelog.Inspector insp = new HgChangelog.Inspector() {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
174
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
175 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
176 String branchName = cset.branch();
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
177 if (!branchStart.containsKey(branchName)) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
178 branchStart.put(branchName, nodeid);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
179 branchHeads.put(branchName, new LinkedList<Nodeid>());
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
180 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
181 branchLastSeen.remove(branchName);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
182 if ("1".equals(cset.extras().get("close"))) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
183 branchHeads.get(branchName).add(nodeid); // XXX what if it still has children?
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
184 closedBranches.add(branchName);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
185 } else {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
186 if (pw.hasChildren(nodeid)) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
187 // children may be in another branch
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
188 // and unless we later came across another element from this branch,
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
189 // we need to record all these as valid heads
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
190 // XXX what about next case: head1 with children in different branch, and head2 without children
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
191 // head1 would get lost
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
192 branchLastSeen.put(branchName, nodeid);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
193 } else {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
194 // no more children known for this node, it's (one of the) head of the branch
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
195 branchHeads.get(branchName).add(nodeid);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
196 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
197 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
198 ps.worked(1);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
199 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
200 };
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
201 repo.getChangelog().range(lastCached == -1 ? 0 : lastCached+1, HgRepository.TIP, insp);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
202 for (String bn : branchLastSeen.keySet()) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
203 branchHeads.get(bn).add(branchLastSeen.get(bn));
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
204 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
205 for (String bn : branchStart.keySet()) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
206 BranchInfo bi = branches.get(bn);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
207 if (bi != null) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
208 // although heads from cache shall not intersect with heads after lastCached,
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
209 // use of LHS doesn't hurt (and makes sense e.g. if cache is not completely correct in my tests)
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
210 LinkedHashSet<Nodeid> heads = new LinkedHashSet<Nodeid>(bi.getHeads());
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
211 for (Nodeid oldHead : bi.getHeads()) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
212 // XXX perhaps, need pw.canReach(Nodeid from, Collection<Nodeid> to)
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
213 List<Nodeid> newChildren = pw.childrenOf(Collections.singletonList(oldHead));
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
214 if (!newChildren.isEmpty()) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
215 // likely not a head any longer,
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
216 // check if any new head can be reached from old one, and, if yes,
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
217 // do not consider that old head as head.
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
218 for (Nodeid newHead : branchHeads.get(bn)) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
219 if (newChildren.contains(newHead)) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
220 heads.remove(oldHead);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
221 break;
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
222 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
223 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
224 } // else - oldHead still head for the branch
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
225 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
226 heads.addAll(branchHeads.get(bn));
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
227 bi = new BranchInfo(bn, bi.getStart(), heads.toArray(new Nodeid[0]), bi.isClosed() && closedBranches.contains(bn));
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
228 } else {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
229 Nodeid[] heads = branchHeads.get(bn).toArray(new Nodeid[0]);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
230 bi = new BranchInfo(bn, branchStart.get(bn), heads, closedBranches.contains(bn));
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
231 }
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
232 branches.put(bn, bi);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
233 }
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
234 }
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
235 ps.done();
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
236 }
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
237
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
238 public List<BranchInfo> getAllBranches() {
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
239 return new LinkedList<BranchInfo>(branches.values());
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
240
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
241 }
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
242
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
243 public BranchInfo getBranch(String name) {
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
244 return branches.get(name);
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
245 }
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
246
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
247 public static class BranchInfo {
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
248 private final String name;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
249 private final List<Nodeid> heads;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
250 private final boolean closed;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
251 private final Nodeid start;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
252
236
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
253 // XXX in fact, few but not all branchHeads might be closed, and isClosed for whole branch is not
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
254 // possible to determine.
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
255 BranchInfo(String branchName, Nodeid first, Nodeid[] branchHeads, boolean isClosed) {
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
256 name = branchName;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
257 start = first;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
258 heads = Collections.unmodifiableList(new ArrayList<Nodeid>(Arrays.asList(branchHeads)));
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
259 closed = isClosed;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
260 }
236
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
261
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
262 // incomplete branch, there's not enough information at the time of creation. shall be replaced with
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
263 // proper BI in #collect()
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
264 BranchInfo(String branchName, Nodeid[] branchHeads) {
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
265 this(branchName, Nodeid.NULL, branchHeads, false);
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
266 }
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
267
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
268 public String getName() {
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
269 return name;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
270 }
236
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
271 /*public*/ boolean isClosed() {
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
272 return closed;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
273 }
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
274 public List<Nodeid> getHeads() {
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
275 return heads;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
276 }
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
277 // public Nodeid getTip() {
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
278 // }
236
883300108179 Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 220
diff changeset
279 /*public*/ Nodeid getStart() {
220
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
280 // first node where branch appears
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
281 return start;
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
282 }
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
283 }
8de327242aa0 Basic information about branches
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
284 }