Mercurial > hg4j
annotate src/org/tmatesoft/hg/repo/HgStatusCollector.java @ 195:c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 15 Apr 2011 05:17:44 +0200 |
parents | d5268ca7715b |
children | 3a7696fb457c |
rev | line source |
---|---|
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
2 * Copyright (c) 2011 TMate Software Ltd |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
3 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
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:
68
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:
68
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:
68
diff
changeset
|
7 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
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:
68
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:
68
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:
68
diff
changeset
|
11 * GNU General Public License for more details. |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
12 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
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:
68
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:
94
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
17 package org.tmatesoft.hg.repo; |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
19 import static org.tmatesoft.hg.repo.HgRepository.BAD_REVISION; |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
20 import static org.tmatesoft.hg.repo.HgRepository.TIP; |
68
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
21 |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 import java.util.Collection; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
23 import java.util.Collections; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 import java.util.LinkedHashMap; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 import java.util.LinkedList; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
26 import java.util.List; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 import java.util.Map; |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
28 import java.util.SortedMap; |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
29 import java.util.TreeMap; |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 import java.util.TreeSet; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 |
157
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
32 import org.tmatesoft.hg.core.HgDataStreamException; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
33 import org.tmatesoft.hg.core.Nodeid; |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
34 import org.tmatesoft.hg.internal.Pool; |
133
4a948ec83980
core.Path to util.Path as it's not Hg repo dependant
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
35 import org.tmatesoft.hg.util.Path; |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
36 import org.tmatesoft.hg.util.PathPool; |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
37 import org.tmatesoft.hg.util.PathRewrite; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
38 |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
39 |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 /** |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
41 * RevisionWalker? |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
42 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
43 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
44 * @author TMate Software Ltd. |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 */ |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
46 public class HgStatusCollector { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 private final HgRepository repo; |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
49 private final SortedMap<Integer, ManifestRevisionInspector> cache; // sparse array, in fact |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
50 // with cpython repository, ~70 000 changes, complete Log (direct out, no reverse) output |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
51 // no cache limit, no nodeids and fname caching - OOME on changeset 1035 |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
52 // no cache limit, but with cached nodeids and filenames - 1730+ |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
53 // cache limit 100 - 19+ minutes to process 10000, and still working (too long, stopped) |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
54 private final int cacheMaxSize = 100; // do not keep too much manifest revisions |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
55 private PathPool pathPool; |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
56 private final Pool<Nodeid> cacheNodes; |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
57 private final Pool<String> cacheFilenames; // XXX in fact, need to think if use of PathPool directly instead is better solution |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
58 |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
59 |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
60 public HgStatusCollector(HgRepository hgRepo) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
61 this.repo = hgRepo; |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
62 cache = new TreeMap<Integer, ManifestRevisionInspector>(); |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
63 cacheNodes = new Pool<Nodeid>(); |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
64 cacheFilenames = new Pool<String>(); |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
65 ManifestRevisionInspector emptyFakeState = new ManifestRevisionInspector(null, null); |
56
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
66 emptyFakeState.begin(-1, null); |
68
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
67 emptyFakeState.end(-1); // FIXME HgRepo.TIP == -1 as well, need to distinguish fake "prior to first" revision from "the very last" |
56
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
68 cache.put(-1, emptyFakeState); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
69 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
70 |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
71 public HgRepository getRepo() { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
72 return repo; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
73 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
74 |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
75 private ManifestRevisionInspector get(int rev) { |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
76 ManifestRevisionInspector i = cache.get(rev); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
77 if (i == null) { |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
78 if (cache.size() > cacheMaxSize) { |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
79 // assume usually we go from oldest to newest, hence remove oldest as most likely to be no longer necessary |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
80 cache.remove(cache.firstKey()); |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
81 } |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
82 i = new ManifestRevisionInspector(cacheNodes, cacheFilenames); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
83 cache.put(rev, i); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
84 repo.getManifest().walk(rev, rev, i); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
85 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
86 return i; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
87 } |
56
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
88 |
59
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
56
diff
changeset
|
89 /*package-local*/ ManifestRevisionInspector raw(int rev) { |
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
56
diff
changeset
|
90 return get(rev); |
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
56
diff
changeset
|
91 } |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
92 /*package-local*/ PathPool getPathPool() { |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
93 if (pathPool == null) { |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
94 pathPool = new PathPool(new PathRewrite.Empty()); |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
95 } |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
96 return pathPool; |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
97 } |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
98 |
142
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
141
diff
changeset
|
99 /** |
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
141
diff
changeset
|
100 * Allows sharing of a common path cache |
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
141
diff
changeset
|
101 */ |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
102 public void setPathPool(PathPool pathPool) { |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
103 this.pathPool = pathPool; |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
104 } |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
105 |
59
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
56
diff
changeset
|
106 |
56
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
107 // hg status --change <rev> |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
108 public void change(int rev, HgStatusInspector inspector) { |
56
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
109 int[] parents = new int[2]; |
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
110 repo.getChangelog().parents(rev, parents, null, null); |
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
111 walk(parents[0], rev, inspector); |
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
112 } |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
113 |
56
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
114 // I assume revision numbers are the same for changelog and manifest - here |
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
115 // user would like to pass changelog revision numbers, and I use them directly to walk manifest. |
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
116 // if this assumption is wrong, fix this (lookup manifest revisions from changeset). |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
117 public void walk(int rev1, int rev2, HgStatusInspector inspector) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
118 if (rev1 == rev2) { |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
119 throw new IllegalArgumentException(); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
120 } |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
121 if (inspector == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
122 throw new IllegalArgumentException(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
123 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
124 if (inspector instanceof Record) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
125 ((Record) inspector).init(rev1, rev2, this); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
126 } |
68
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
127 if (rev1 == TIP) { |
135
3959bffb14e9
explicit op name instead math op to get last rev number
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
128 rev1 = repo.getManifest().getLastRevision(); |
68
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
129 } |
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
130 if (rev2 == TIP) { |
135
3959bffb14e9
explicit op name instead math op to get last rev number
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
131 rev2 = repo.getManifest().getLastRevision(); |
68
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
132 } |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
133 // in fact, rev1 and rev2 are often next (or close) to each other, |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
134 // thus, we can optimize Manifest reads here (manifest.walk(rev1, rev2)) |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
135 ManifestRevisionInspector r1, r2 ; |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
136 if (!cache.containsKey(rev1) && !cache.containsKey(rev2) && Math.abs(rev1 - rev2) < 5 /*subjective equivalent of 'close enough'*/) { |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
137 int minRev = rev1 < rev2 ? rev1 : rev2; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
138 int maxRev = minRev == rev1 ? rev2 : rev1; |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
139 if (minRev > 0) { |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
140 minRev--; // expand range a bit |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
141 // XXX perhaps, if revlog.baseRevision is cheap, shall expand minRev up to baseRevision |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
142 // which gonna be read anyway |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
143 } |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
144 |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
145 repo.getManifest().walk(minRev, maxRev, new HgManifest.Inspector() { |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
146 private ManifestRevisionInspector delegate; |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
147 |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
148 public boolean begin(int revision, Nodeid nid) { |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
149 cache.put(revision, delegate = new ManifestRevisionInspector(cacheNodes, cacheFilenames)); |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
150 delegate.begin(revision, nid); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
151 return true; |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
152 } |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
153 |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
154 public boolean next(Nodeid nid, String fname, String flags) { |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
155 delegate.next(nid, fname, flags); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
156 return true; |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
157 } |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
158 |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
159 public boolean end(int revision) { |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
160 delegate.end(revision); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
161 delegate = null; |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
162 return true; |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
163 } |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
164 }); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
165 } |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
166 r1 = get(rev1); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
167 r2 = get(rev2); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
168 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
169 PathPool pp = getPathPool(); |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
170 |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
171 TreeSet<String> r1Files = new TreeSet<String>(r1.files()); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
172 for (String fname : r2.files()) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
173 if (r1Files.remove(fname)) { |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
174 Nodeid nidR1 = r1.nodeid(fname); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
175 Nodeid nidR2 = r2.nodeid(fname); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
176 String flagsR1 = r1.flags(fname); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
177 String flagsR2 = r2.flags(fname); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
178 if (nidR1.equals(nidR2) && ((flagsR2 == null && flagsR1 == null) || flagsR2.equals(flagsR1))) { |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
179 inspector.clean(pp.path(fname)); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
180 } else { |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
181 inspector.modified(pp.path(fname)); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
182 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
183 } else { |
157
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
184 try { |
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
185 Path copyTarget = pp.path(fname); |
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
186 Path copyOrigin = getOriginIfCopy(repo, copyTarget, r1Files, rev1); |
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
187 if (copyOrigin != null) { |
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
188 inspector.copied(pp.path(copyOrigin) /*pipe through pool, just in case*/, copyTarget); |
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
189 } else { |
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
190 inspector.added(copyTarget); |
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
191 } |
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
192 } catch (HgDataStreamException ex) { |
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
193 ex.printStackTrace(); |
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
194 // FIXME perhaps, shall record this exception to dedicated mediator and continue |
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
195 // for a single file not to be irresolvable obstacle for a status operation |
88
61eedab3eb3e
Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
196 } |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
197 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
198 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
199 for (String left : r1Files) { |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
200 inspector.removed(pp.path(left)); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
201 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
202 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
203 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
204 public Record status(int rev1, int rev2) { |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
205 Record rv = new Record(); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
206 walk(rev1, rev2, rv); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
207 return rv; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
208 } |
90
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
209 |
157
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
210 /*package-local*/static Path getOriginIfCopy(HgRepository hgRepo, Path fname, Collection<String> originals, int originalChangelogRevision) throws HgDataStreamException { |
90
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
211 HgDataFile df = hgRepo.getFileNode(fname); |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
212 while (df.isCopy()) { |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
213 Path original = df.getCopySourceName(); |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
214 if (originals.contains(original.toString())) { |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
215 df = hgRepo.getFileNode(original); |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
216 int changelogRevision = df.getChangesetLocalRevision(0); |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
217 if (changelogRevision <= originalChangelogRevision) { |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
218 // copy/rename source was known prior to rev1 |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
219 // (both r1Files.contains is true and original was created earlier than rev1) |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
220 // without r1Files.contains changelogRevision <= rev1 won't suffice as the file |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
221 // might get removed somewhere in between (changelogRevision < R < rev1) |
141
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
135
diff
changeset
|
222 return original; |
90
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
223 } |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
224 break; // copy/rename done later |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
225 } |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
226 df = hgRepo.getFileNode(original); // try more steps away |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
227 } |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
228 return null; |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
229 } |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
230 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
231 // XXX for r1..r2 status, only modified, added, removed (and perhaps, clean) make sense |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
232 // XXX Need to specify whether copy targets are in added or not (@see Inspector#copied above) |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
233 public static class Record implements HgStatusInspector { |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
234 private List<Path> modified, added, removed, clean, missing, unknown, ignored; |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
235 private Map<Path, Path> copied; |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
236 |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
237 private int startRev, endRev; |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
238 private HgStatusCollector statusHelper; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
239 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
240 // XXX StatusCollector may additionally initialize Record instance to speed lookup of changed file revisions |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
241 // here I need access to ManifestRevisionInspector via #raw(). Perhaps, non-static class (to get |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
242 // implicit reference to StatusCollector) may be better? |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
243 // Since users may want to reuse Record instance we've once created (and initialized), we need to |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
244 // ensure functionality is correct for each/any call (#walk checks instanceof Record and fixes it up) |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
245 // Perhaps, distinct helper (sc.getRevisionHelper().nodeid(fname)) would be better, just not clear |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
246 // how to supply [start..end] values there easily |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
247 /*package-local*/void init(int startRevision, int endRevision, HgStatusCollector self) { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
248 startRev = startRevision; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
249 endRev = endRevision; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
250 statusHelper = self; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
251 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
252 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
253 public Nodeid nodeidBeforeChange(Path fname) { |
68
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
254 if (statusHelper == null || startRev == BAD_REVISION) { |
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
255 return null; |
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
256 } |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
257 if ((modified == null || !modified.contains(fname)) && (removed == null || !removed.contains(fname))) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
258 return null; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
259 } |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
260 return statusHelper.raw(startRev).nodeid(fname.toString()); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
261 } |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
262 public Nodeid nodeidAfterChange(Path fname) { |
68
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
263 if (statusHelper == null || endRev == BAD_REVISION) { |
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
264 return null; |
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
265 } |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
266 if ((modified == null || !modified.contains(fname)) && (added == null || !added.contains(fname))) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
267 return null; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
268 } |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
269 return statusHelper.raw(endRev).nodeid(fname.toString()); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
270 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
271 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
272 public List<Path> getModified() { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
273 return proper(modified); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
274 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
275 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
276 public List<Path> getAdded() { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
277 return proper(added); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
278 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
279 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
280 public List<Path> getRemoved() { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
281 return proper(removed); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
282 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
283 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
284 public Map<Path,Path> getCopied() { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
285 if (copied == null) { |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
286 return Collections.emptyMap(); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
287 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
288 return Collections.unmodifiableMap(copied); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
289 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
290 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
291 public List<Path> getClean() { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
292 return proper(clean); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
293 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
294 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
295 public List<Path> getMissing() { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
296 return proper(missing); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
297 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
298 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
299 public List<Path> getUnknown() { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
300 return proper(unknown); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
301 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
302 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
303 public List<Path> getIgnored() { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
304 return proper(ignored); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
305 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
306 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
307 private List<Path> proper(List<Path> l) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
308 if (l == null) { |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
309 return Collections.emptyList(); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
310 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
311 return Collections.unmodifiableList(l); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
312 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
313 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
314 // |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
315 // |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
316 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
317 public void modified(Path fname) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
318 modified = doAdd(modified, fname); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
319 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
320 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
321 public void added(Path fname) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
322 added = doAdd(added, fname); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
323 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
324 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
325 public void copied(Path fnameOrigin, Path fnameAdded) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
326 if (copied == null) { |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
327 copied = new LinkedHashMap<Path, Path>(); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
328 } |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
329 added(fnameAdded); |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
330 copied.put(fnameAdded, fnameOrigin); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
331 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
332 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
333 public void removed(Path fname) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
334 removed = doAdd(removed, fname); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
335 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
336 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
337 public void clean(Path fname) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
338 clean = doAdd(clean, fname); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
339 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
340 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
341 public void missing(Path fname) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
342 missing = doAdd(missing, fname); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
343 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
344 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
345 public void unknown(Path fname) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
346 unknown = doAdd(unknown, fname); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
347 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
348 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
349 public void ignored(Path fname) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
350 ignored = doAdd(ignored, fname); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
351 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
352 |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
353 private static List<Path> doAdd(List<Path> l, Path p) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
354 if (l == null) { |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
355 l = new LinkedList<Path>(); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
356 } |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
357 l.add(p); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
358 return l; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
359 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
360 } |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
361 |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
362 /*package-local*/ static final class ManifestRevisionInspector implements HgManifest.Inspector { |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
363 private final TreeMap<String, Nodeid> idsMap; |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
364 private final TreeMap<String, String> flagsMap; |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
365 private final Pool<Nodeid> idsPool; |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
366 private final Pool<String> namesPool; |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
367 |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
368 // optional pools for effective management of nodeids and filenames (they are likely |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
369 // to be duplicated among different manifest revisions |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
370 public ManifestRevisionInspector(Pool<Nodeid> nodeidPool, Pool<String> filenamePool) { |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
371 idsPool = nodeidPool; |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
372 namesPool = filenamePool; |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
373 idsMap = new TreeMap<String, Nodeid>(); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
374 flagsMap = new TreeMap<String, String>(); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
375 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
376 |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
377 public Collection<String> files() { |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
378 return idsMap.keySet(); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
379 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
380 |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
381 public Nodeid nodeid(String fname) { |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
382 return idsMap.get(fname); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
383 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
384 |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
385 public String flags(String fname) { |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
386 return flagsMap.get(fname); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
387 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
388 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
389 // |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
390 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
391 public boolean next(Nodeid nid, String fname, String flags) { |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
392 if (namesPool != null) { |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
393 fname = namesPool.unify(fname); |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
394 } |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
395 if (idsPool != null) { |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
396 nid = idsPool.unify(nid); |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
397 } |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
398 idsMap.put(fname, nid); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
399 flagsMap.put(fname, flags); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
400 return true; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
401 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
402 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
403 public boolean end(int revision) { |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
404 // in fact, this class cares about single revision |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
405 return false; |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
406 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
407 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
408 public boolean begin(int revision, Nodeid nid) { |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
409 return true; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
410 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
411 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
412 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
413 } |