Mercurial > hg4j
annotate src/org/tmatesoft/hg/repo/HgStatusCollector.java @ 142:37a34044e6bd
More reasonable use of path normalizer and path.source
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 17 Feb 2011 05:06:07 +0100 |
parents | 8248aae33f7d |
children | d5268ca7715b |
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; |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
28 import java.util.TreeMap; |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
29 import java.util.TreeSet; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
31 import org.tmatesoft.hg.core.Nodeid; |
133
4a948ec83980
core.Path to util.Path as it's not Hg repo dependant
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
32 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
|
33 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
|
34 import org.tmatesoft.hg.util.PathRewrite; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
35 |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
36 |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 /** |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 * RevisionWalker? |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
39 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
40 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
41 * @author TMate Software Ltd. |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 */ |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
43 public class HgStatusCollector { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 private final HgRepository repo; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 private final Map<Integer, ManifestRevisionInspector> cache; // sparse array, in fact |
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
|
47 private PathPool pathPool; |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
49 public HgStatusCollector(HgRepository hgRepo) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 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
|
51 cache = new TreeMap<Integer, ManifestRevisionInspector>(); |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
52 ManifestRevisionInspector emptyFakeState = new ManifestRevisionInspector(); |
56
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
53 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
|
54 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
|
55 cache.put(-1, emptyFakeState); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
56 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
57 |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
58 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
|
59 return repo; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
60 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
61 |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
62 private ManifestRevisionInspector get(int rev) { |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
63 ManifestRevisionInspector i = cache.get(rev); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
64 if (i == null) { |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
65 i = new ManifestRevisionInspector(); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
66 cache.put(rev, i); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
67 repo.getManifest().walk(rev, rev, i); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
68 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
69 return i; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
70 } |
56
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
71 |
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
|
72 /*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
|
73 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
|
74 } |
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
|
75 /*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
|
76 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
|
77 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
|
78 } |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
79 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
|
80 } |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
diff
changeset
|
81 |
142
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
141
diff
changeset
|
82 /** |
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
141
diff
changeset
|
83 * 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
|
84 */ |
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
|
85 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
|
86 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
|
87 } |
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
90
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 |
56
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
90 // 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
|
91 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
|
92 int[] parents = new int[2]; |
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
93 repo.getChangelog().parents(rev, parents, null, null); |
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
94 walk(parents[0], rev, inspector); |
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
95 } |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
96 |
56
576d6e8a09f6
Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
97 // 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
|
98 // 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
|
99 // 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
|
100 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
|
101 if (rev1 == rev2) { |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
102 throw new IllegalArgumentException(); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
103 } |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
104 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
|
105 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
|
106 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
107 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
|
108 ((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
|
109 } |
68
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
110 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
|
111 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
|
112 } |
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
113 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
|
114 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
|
115 } |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
116 // 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
|
117 // 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
|
118 ManifestRevisionInspector r1, r2 ; |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
119 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
|
120 int minRev = rev1 < rev2 ? rev1 : rev2; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
121 int maxRev = minRev == rev1 ? rev2 : rev1; |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
122 if (minRev > 0) { |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
123 minRev--; // expand range a bit |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
124 // 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
|
125 // which gonna be read anyway |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
126 } |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
127 |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
128 repo.getManifest().walk(minRev, maxRev, new HgManifest.Inspector() { |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
129 private ManifestRevisionInspector delegate; |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
130 |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
131 public boolean begin(int revision, Nodeid nid) { |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
132 cache.put(revision, delegate = new ManifestRevisionInspector()); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
133 delegate.begin(revision, nid); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
134 return true; |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
135 } |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
136 |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
137 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
|
138 delegate.next(nid, fname, flags); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
139 return true; |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
140 } |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
141 |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
142 public boolean end(int revision) { |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
143 delegate.end(revision); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
144 delegate = null; |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
145 return true; |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
146 } |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
147 }); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
148 } |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
149 r1 = get(rev1); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
150 r2 = get(rev2); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
151 |
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
|
152 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
|
153 |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
154 TreeSet<String> r1Files = new TreeSet<String>(r1.files()); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
155 for (String fname : r2.files()) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
156 if (r1Files.remove(fname)) { |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
157 Nodeid nidR1 = r1.nodeid(fname); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
158 Nodeid nidR2 = r2.nodeid(fname); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
159 String flagsR1 = r1.flags(fname); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
160 String flagsR2 = r2.flags(fname); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
161 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
|
162 inspector.clean(pp.path(fname)); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
163 } 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
|
164 inspector.modified(pp.path(fname)); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
165 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
166 } else { |
141
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
135
diff
changeset
|
167 Path copyTarget = pp.path(fname); |
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
135
diff
changeset
|
168 Path copyOrigin = getOriginIfCopy(repo, copyTarget, r1Files, rev1); |
90
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
169 if (copyOrigin != null) { |
141
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
135
diff
changeset
|
170 inspector.copied(pp.path(copyOrigin) /*pipe through pool, just in case*/, copyTarget); |
90
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
171 } else { |
141
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
135
diff
changeset
|
172 inspector.added(copyTarget); |
88
61eedab3eb3e
Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
173 } |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
174 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
175 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
176 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
|
177 inspector.removed(pp.path(left)); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
178 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
179 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
180 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
181 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
|
182 Record rv = new Record(); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
183 walk(rev1, rev2, rv); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
184 return rv; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
185 } |
90
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
186 |
141
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
135
diff
changeset
|
187 /*package-local*/static Path getOriginIfCopy(HgRepository hgRepo, Path fname, Collection<String> originals, int originalChangelogRevision) { |
90
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
188 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
|
189 while (df.isCopy()) { |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
190 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
|
191 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
|
192 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
|
193 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
|
194 if (changelogRevision <= originalChangelogRevision) { |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
195 // 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
|
196 // (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
|
197 // 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
|
198 // 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
|
199 return original; |
90
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
200 } |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
201 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
|
202 } |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
203 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
|
204 } |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
205 return null; |
a95c700408a9
Correctly report copy/rename events for rev..working copy case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
89
diff
changeset
|
206 } |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
207 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
208 // 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
|
209 // 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
|
210 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
|
211 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
|
212 private Map<Path, Path> copied; |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
213 |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
214 private int startRev, endRev; |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
215 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
|
216 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
217 // 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
|
218 // 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
|
219 // 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
|
220 // 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
|
221 // 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
|
222 // 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
|
223 // 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
|
224 /*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
|
225 startRev = startRevision; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
226 endRev = endRevision; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
227 statusHelper = self; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
228 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
229 |
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
|
230 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
|
231 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
|
232 return null; |
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
233 } |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
234 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
|
235 return null; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
236 } |
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
|
237 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
|
238 } |
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
|
239 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
|
240 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
|
241 return null; |
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
242 } |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
243 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
|
244 return null; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
245 } |
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
|
246 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
|
247 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
59
diff
changeset
|
248 |
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
|
249 public List<Path> getModified() { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
250 return proper(modified); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
251 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
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 List<Path> getAdded() { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
254 return proper(added); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
255 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
256 |
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
|
257 public List<Path> getRemoved() { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
258 return proper(removed); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
259 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
260 |
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
|
261 public Map<Path,Path> getCopied() { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
262 if (copied == null) { |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
263 return Collections.emptyMap(); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
264 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
265 return Collections.unmodifiableMap(copied); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
266 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
267 |
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
|
268 public List<Path> getClean() { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
269 return proper(clean); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
270 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
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> getMissing() { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
273 return proper(missing); |
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> getUnknown() { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
277 return proper(unknown); |
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> getIgnored() { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
281 return proper(ignored); |
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 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
|
285 if (l == null) { |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
286 return Collections.emptyList(); |
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.unmodifiableList(l); |
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 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
291 // |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
292 // |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
293 |
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
|
294 public void modified(Path fname) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
295 modified = doAdd(modified, fname); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
296 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
297 |
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
|
298 public void added(Path fname) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
299 added = doAdd(added, fname); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
300 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
301 |
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
|
302 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
|
303 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
|
304 copied = new LinkedHashMap<Path, Path>(); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
305 } |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
306 added(fnameAdded); |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
68
diff
changeset
|
307 copied.put(fnameAdded, fnameOrigin); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
308 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
309 |
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
|
310 public void removed(Path fname) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
311 removed = doAdd(removed, fname); |
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 |
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
|
314 public void clean(Path fname) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
315 clean = doAdd(clean, fname); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
316 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
317 |
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
|
318 public void missing(Path fname) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
319 missing = doAdd(missing, fname); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
320 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
321 |
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
|
322 public void unknown(Path fname) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
323 unknown = doAdd(unknown, fname); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
324 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
325 |
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
|
326 public void ignored(Path fname) { |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
327 ignored = doAdd(ignored, fname); |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
328 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
329 |
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
|
330 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
|
331 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
|
332 l = new LinkedList<Path>(); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
333 } |
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
|
334 l.add(p); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
335 return l; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
336 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
337 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
338 |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
339 /*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
|
340 private final TreeMap<String, Nodeid> idsMap; |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
341 private final TreeMap<String, String> flagsMap; |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
342 |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
343 public ManifestRevisionInspector() { |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
344 idsMap = new TreeMap<String, Nodeid>(); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
345 flagsMap = new TreeMap<String, String>(); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
346 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
347 |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
348 public Collection<String> files() { |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
349 return idsMap.keySet(); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
350 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
351 |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
352 public Nodeid nodeid(String fname) { |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
353 return idsMap.get(fname); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
354 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
355 |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
356 public String flags(String fname) { |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
357 return flagsMap.get(fname); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
358 } |
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 // |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
361 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
362 public boolean next(Nodeid nid, String fname, String flags) { |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
363 idsMap.put(fname, nid); |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
364 flagsMap.put(fname, flags); |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
365 return true; |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
366 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
367 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
368 public boolean end(int revision) { |
89
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
369 // in fact, this class cares about single revision |
42bcb4bffd17
Refactored to simplify manifest collector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
88
diff
changeset
|
370 return false; |
55
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
371 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
372 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
373 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
|
374 return true; |
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 } |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
377 |
05829a70b30b
Status operation extracted into separate, cache-friendly class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
378 } |