Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/HgStatusCollector.java @ 471:7bcfbc255f48
Merge changes from smartgit3 branch into 1.1 stream
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 11 Jul 2012 20:40:47 +0200 |
parents | 12f668401613 281cfb60e2ef |
children | 6526d8adbc0f |
comparison
equal
deleted
inserted
replaced
470:31bd09da0dcf | 471:7bcfbc255f48 |
---|---|
54 private Convertor<Path> pathPool; | 54 private Convertor<Path> pathPool; |
55 private final Pool<Nodeid> cacheNodes; | 55 private final Pool<Nodeid> cacheNodes; |
56 private final Pool<Path> cacheFilenames; | 56 private final Pool<Path> cacheFilenames; |
57 private final ManifestRevision emptyFakeState; | 57 private final ManifestRevision emptyFakeState; |
58 private Path.Matcher scope = new Path.Matcher.Any(); | 58 private Path.Matcher scope = new Path.Matcher.Any(); |
59 // @see #detectCopies() | |
60 private boolean detectCopies = true; | |
59 | 61 |
60 | 62 |
61 public HgStatusCollector(HgRepository hgRepo) { | 63 public HgStatusCollector(HgRepository hgRepo) { |
62 this.repo = hgRepo; | 64 this.repo = hgRepo; |
63 cache = new IntMap<ManifestRevision>(cacheMaxSize); | 65 cache = new IntMap<ManifestRevision>(cacheMaxSize); |
180 */ | 182 */ |
181 public void setScope(Path.Matcher scopeMatcher) { | 183 public void setScope(Path.Matcher scopeMatcher) { |
182 // do not assign null, ever | 184 // do not assign null, ever |
183 scope = scopeMatcher == null ? new Path.Matcher.Any() : scopeMatcher; | 185 scope = scopeMatcher == null ? new Path.Matcher.Any() : scopeMatcher; |
184 } | 186 } |
187 | |
188 /** | |
189 * Select whether Collector shall tell "added-new" from "added-by-copy/rename" files. | |
190 * This is analogous to '-C' switch of 'hg status' command. | |
191 * | |
192 * <p>With copy detection turned off, files continue be reported as plain 'added' files. | |
193 * | |
194 * <p>By default, copy detection is <em>on</em>, as it's reasonably cheap. However, | |
195 * in certain scenarios it may be reasonable to turn it off, for example when it's a merge | |
196 * of two very different branches and there are a lot of files added/moved. | |
197 * | |
198 * Another legitimate reason to set detection to off if you're lazy to | |
199 * implement {@link HgStatusInspector#copied(Path, Path)} ;) | |
200 * | |
201 * @param detect <code>true</code> if copies detection is desirable | |
202 */ | |
203 public void detectCopies(boolean detect) { | |
204 // cpython, revision:72161, p1:72159, p2:72160 | |
205 // p2 comes from another branch with 321 file added (looks like copied/moved, however, the isCopy | |
206 // record present only for couple of them). With 2,5 ms per isCopy() operation, almost a second | |
207 // is spent detecting origins (according to Marc, of little use in this scenario, as it's second parent | |
208 // in the merge) - in fact, most of the time of the status operation | |
209 detectCopies = detect; | |
210 } | |
185 | 211 |
186 /** | 212 /** |
187 * 'hg status --change REV' command counterpart. | 213 * 'hg status --change REV' command counterpart. |
188 * | 214 * |
189 * @throws CancelledException if operation execution was cancelled | 215 * @throws CancelledException if operation execution was cancelled |
288 } | 314 } |
289 cs.checkCancelled(); | 315 cs.checkCancelled(); |
290 } else { | 316 } else { |
291 try { | 317 try { |
292 Path copyTarget = r2fname; | 318 Path copyTarget = r2fname; |
293 Path copyOrigin = getOriginIfCopy(repo, copyTarget, r1Files, rev1); | 319 Path copyOrigin = detectCopies ? getOriginIfCopy(repo, copyTarget, r1Files, rev1) : null; |
294 if (copyOrigin != null) { | 320 if (copyOrigin != null) { |
295 inspector.copied(getPathPool().mangle(copyOrigin) /*pipe through pool, just in case*/, copyTarget); | 321 inspector.copied(getPathPool().mangle(copyOrigin) /*pipe through pool, just in case*/, copyTarget); |
296 } else { | 322 } else { |
297 inspector.added(copyTarget); | 323 inspector.added(copyTarget); |
298 } | 324 } |