Mercurial > hg4j
annotate src/org/tmatesoft/hg/repo/HgStatusCollector.java @ 615:84104448a0bf
Test for repository locks
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> | 
|---|---|
| date | Mon, 13 May 2013 22:48:29 +0200 | 
| parents | 7bcfbc255f48 | 
| children | 6526d8adbc0f | 
| rev | line source | 
|---|---|
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 1 /* | 
| 455 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 2 * Copyright (c) 2011-2012 TMate Software Ltd | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 3 * | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
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: 
68diff
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: 
68diff
changeset | 6 * the Free Software Foundation; version 2 of the License. | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 7 * | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
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: 
68diff
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: 
68diff
changeset | 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 11 * GNU General Public License for more details. | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 12 * | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 13 * For information on how to redistribute this software under | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
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: 
94diff
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: 
68diff
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 | 
| 403 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 19 import static org.tmatesoft.hg.repo.HgRepository.*; | 
| 68 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
64diff
changeset | 20 | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 21 import java.util.Collection; | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 22 import java.util.Collections; | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 23 import java.util.LinkedHashMap; | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 24 import java.util.LinkedList; | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 25 import java.util.List; | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 26 import java.util.Map; | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 27 import java.util.TreeSet; | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 28 | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 29 import org.tmatesoft.hg.core.Nodeid; | 
| 281 
81e9a3c9bafe
Utilize IntMap when caching manifest revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
248diff
changeset | 30 import org.tmatesoft.hg.internal.IntMap; | 
| 248 
3fbfce107f94
Issue 8: Means to find out information about given file at specific changeset. Inner ManifestRevisionInspector got promoted to ManifestRevision
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
229diff
changeset | 31 import org.tmatesoft.hg.internal.ManifestRevision; | 
| 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: 
157diff
changeset | 32 import org.tmatesoft.hg.internal.Pool; | 
| 423 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 33 import org.tmatesoft.hg.util.CancelSupport; | 
| 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 34 import org.tmatesoft.hg.util.CancelledException; | 
| 431 
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
425diff
changeset | 35 import org.tmatesoft.hg.util.Convertor; | 
| 133 
4a948ec83980
core.Path to util.Path as it's not Hg repo dependant
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 36 import org.tmatesoft.hg.util.Path; | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 37 | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 38 | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 39 /** | 
| 423 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 40 * Collect status information for changes between two repository revisions. | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 41 * | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 42 * @author Artem Tikhomirov | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 43 * @author TMate Software Ltd. | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 44 */ | 
| 94 
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
93diff
changeset | 45 public class HgStatusCollector { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 46 | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 47 private final HgRepository repo; | 
| 281 
81e9a3c9bafe
Utilize IntMap when caching manifest revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
248diff
changeset | 48 private final IntMap<ManifestRevision> cache; // sparse array, in fact | 
| 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: 
157diff
changeset | 49 // 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: 
157diff
changeset | 50 // 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: 
157diff
changeset | 51 // 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: 
157diff
changeset | 52 // cache limit 100 - 19+ minutes to process 10000, and still working (too long, stopped) | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 53 private final int cacheMaxSize = 50; // do not keep too much manifest revisions | 
| 431 
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
425diff
changeset | 54 private Convertor<Path> 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: 
157diff
changeset | 55 private final Pool<Nodeid> cacheNodes; | 
| 285 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 56 private final Pool<Path> cacheFilenames; | 
| 248 
3fbfce107f94
Issue 8: Means to find out information about given file at specific changeset. Inner ManifestRevisionInspector got promoted to ManifestRevision
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
229diff
changeset | 57 private final ManifestRevision emptyFakeState; | 
| 229 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 58 private Path.Matcher scope = new Path.Matcher.Any(); | 
| 455 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 59 // @see #detectCopies() | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 60 private boolean detectCopies = true; | 
| 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: 
157diff
changeset | 61 | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 62 | 
| 94 
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
93diff
changeset | 63 public HgStatusCollector(HgRepository hgRepo) { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 64 this.repo = hgRepo; | 
| 281 
81e9a3c9bafe
Utilize IntMap when caching manifest revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
248diff
changeset | 65 cache = new IntMap<ManifestRevision>(cacheMaxSize); | 
| 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: 
157diff
changeset | 66 cacheNodes = new Pool<Nodeid>(); | 
| 285 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 67 cacheFilenames = new Pool<Path>(); | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 68 | 
| 284 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
282diff
changeset | 69 emptyFakeState = createEmptyManifestRevision(); | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 70 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 71 | 
| 64 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 72 public HgRepository getRepo() { | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 73 return repo; | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 74 } | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 75 | 
| 366 
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
360diff
changeset | 76 private ManifestRevision get(int rev) throws HgInvalidControlFileException { | 
| 248 
3fbfce107f94
Issue 8: Means to find out information about given file at specific changeset. Inner ManifestRevisionInspector got promoted to ManifestRevision
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
229diff
changeset | 77 ManifestRevision i = cache.get(rev); | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 78 if (i == null) { | 
| 405 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 79 if (rev == NO_REVISION) { | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 80 return emptyFakeState; | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 81 } | 
| 281 
81e9a3c9bafe
Utilize IntMap when caching manifest revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
248diff
changeset | 82 ensureCacheSize(); | 
| 248 
3fbfce107f94
Issue 8: Means to find out information about given file at specific changeset. Inner ManifestRevisionInspector got promoted to ManifestRevision
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
229diff
changeset | 83 i = new ManifestRevision(cacheNodes, cacheFilenames); | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 84 cache.put(rev, i); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 85 repo.getManifest().walk(rev, rev, i); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 86 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 87 return i; | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 88 } | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 89 | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 90 private boolean cached(int revision) { | 
| 405 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 91 return cache.containsKey(revision) || revision == NO_REVISION; | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 92 } | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 93 | 
| 281 
81e9a3c9bafe
Utilize IntMap when caching manifest revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
248diff
changeset | 94 private void ensureCacheSize() { | 
| 
81e9a3c9bafe
Utilize IntMap when caching manifest revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
248diff
changeset | 95 if (cache.size() > cacheMaxSize) { | 
| 
81e9a3c9bafe
Utilize IntMap when caching manifest revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
248diff
changeset | 96 // assume usually we go from oldest to newest, hence remove oldest as most likely to be no longer necessary | 
| 
81e9a3c9bafe
Utilize IntMap when caching manifest revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
248diff
changeset | 97 cache.removeFromStart(cache.size() - cacheMaxSize + 1 /* room for new element */); | 
| 
81e9a3c9bafe
Utilize IntMap when caching manifest revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
248diff
changeset | 98 } | 
| 
81e9a3c9bafe
Utilize IntMap when caching manifest revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
248diff
changeset | 99 } | 
| 
81e9a3c9bafe
Utilize IntMap when caching manifest revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
248diff
changeset | 100 | 
| 366 
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
360diff
changeset | 101 private void initCacheRange(int minRev, int maxRev) throws HgInvalidControlFileException { | 
| 281 
81e9a3c9bafe
Utilize IntMap when caching manifest revisions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
248diff
changeset | 102 ensureCacheSize(); | 
| 302 
a7a3395a519e
Walk explicit revisions to avoid troubles with unnatural repositories
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
285diff
changeset | 103 // In fact, walk(minRev, maxRev) doesn't imply | 
| 
a7a3395a519e
Walk explicit revisions to avoid troubles with unnatural repositories
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
285diff
changeset | 104 // there would be maxRev-minRev+1 revisions visited. For example, | 
| 
a7a3395a519e
Walk explicit revisions to avoid troubles with unnatural repositories
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
285diff
changeset | 105 // check cpython repo with 'hg log -r 22418:22420 --debug' and admire | 
| 
a7a3395a519e
Walk explicit revisions to avoid troubles with unnatural repositories
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
285diff
changeset | 106 // manifest revisions 66650, 21683, 21684. Thus, innocent walk(22418,22420) results in 40k+ revisions and OOME | 
| 
a7a3395a519e
Walk explicit revisions to avoid troubles with unnatural repositories
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
285diff
changeset | 107 // Instead, be explicit of what revisions are of interest | 
| 
a7a3395a519e
Walk explicit revisions to avoid troubles with unnatural repositories
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
285diff
changeset | 108 assert minRev <= maxRev; | 
| 
a7a3395a519e
Walk explicit revisions to avoid troubles with unnatural repositories
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
285diff
changeset | 109 int[] revisionsToCollect = new int[maxRev - minRev + 1]; | 
| 
a7a3395a519e
Walk explicit revisions to avoid troubles with unnatural repositories
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
285diff
changeset | 110 for (int x = minRev, i = 0; x <= maxRev; i++, x++) { | 
| 
a7a3395a519e
Walk explicit revisions to avoid troubles with unnatural repositories
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
285diff
changeset | 111 revisionsToCollect[i] = x; | 
| 
a7a3395a519e
Walk explicit revisions to avoid troubles with unnatural repositories
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
285diff
changeset | 112 } | 
| 424 
6437d261048a
Deprecated code removed
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
423diff
changeset | 113 repo.getManifest().walk(new HgManifest.Inspector() { | 
| 248 
3fbfce107f94
Issue 8: Means to find out information about given file at specific changeset. Inner ManifestRevisionInspector got promoted to ManifestRevision
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
229diff
changeset | 114 private ManifestRevision delegate; | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 115 private boolean cacheHit; // range may include revisions we already know about, do not re-create them | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 116 | 
| 222 
373e07cd3991
Due to discrepancy in manifest and changelor indexes, wrong manifest revisions got cached and compared
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
221diff
changeset | 117 public boolean begin(int manifestRevision, Nodeid nid, int changelogRevision) { | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 118 assert delegate == null; | 
| 405 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 119 if (cache.containsKey(changelogRevision)) { // don't need to check emptyFakeState hit as revision never NO_REVISION here | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 120 cacheHit = true; | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 121 } else { | 
| 248 
3fbfce107f94
Issue 8: Means to find out information about given file at specific changeset. Inner ManifestRevisionInspector got promoted to ManifestRevision
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
229diff
changeset | 122 cache.put(changelogRevision, delegate = new ManifestRevision(cacheNodes, cacheFilenames)); | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 123 // cache may grow bigger than max size here, but it's ok as present simplistic cache clearing mechanism may | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 124 // otherwise remove entries we just added | 
| 222 
373e07cd3991
Due to discrepancy in manifest and changelor indexes, wrong manifest revisions got cached and compared
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
221diff
changeset | 125 delegate.begin(manifestRevision, nid, changelogRevision); | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 126 cacheHit = false; | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 127 } | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 128 return true; | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 129 } | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 130 | 
| 285 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 131 public boolean next(Nodeid nid, Path fname, HgManifest.Flags flags) { | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 132 if (!cacheHit) { | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 133 delegate.next(nid, fname, flags); | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 134 } | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 135 return true; | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 136 } | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 137 | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 138 public boolean end(int revision) { | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 139 if (!cacheHit) { | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 140 delegate.end(revision); | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 141 } | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 142 cacheHit = false; | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 143 delegate = null; | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 144 return true; | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 145 } | 
| 302 
a7a3395a519e
Walk explicit revisions to avoid troubles with unnatural repositories
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
285diff
changeset | 146 }, revisionsToCollect); | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 147 } | 
| 56 
576d6e8a09f6
Analog of 'hg status --change' command
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
55diff
changeset | 148 | 
| 284 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
282diff
changeset | 149 /*package-local*/ static ManifestRevision createEmptyManifestRevision() { | 
| 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
282diff
changeset | 150 ManifestRevision fakeEmptyRev = new ManifestRevision(null, null); | 
| 405 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 151 fakeEmptyRev.begin(NO_REVISION, null, NO_REVISION); | 
| 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 152 fakeEmptyRev.end(NO_REVISION); | 
| 284 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
282diff
changeset | 153 return fakeEmptyRev; | 
| 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
282diff
changeset | 154 } | 
| 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
282diff
changeset | 155 | 
| 405 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 156 /** | 
| 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 157 * Access specific manifest revision | 
| 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 158 * @param rev | 
| 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 159 * @return | 
| 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 160 * @throws HgInvalidControlFileException | 
| 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 161 */ | 
| 366 
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
360diff
changeset | 162 /*package-local*/ ManifestRevision raw(int rev) throws HgInvalidControlFileException { | 
| 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: 
56diff
changeset | 163 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: 
56diff
changeset | 164 } | 
| 431 
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
425diff
changeset | 165 /*package-local*/ Convertor<Path> getPathPool() { | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 166 if (pathPool == null) { | 
| 431 
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
425diff
changeset | 167 pathPool = cacheFilenames; | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 168 } | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 169 return pathPool; | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 170 } | 
| 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 171 | 
| 142 
37a34044e6bd
More reasonable use of path normalizer and path.source
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
141diff
changeset | 172 /** | 
| 
37a34044e6bd
More reasonable use of path normalizer and path.source
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
141diff
changeset | 173 * Allows sharing of a common path cache | 
| 
37a34044e6bd
More reasonable use of path normalizer and path.source
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
141diff
changeset | 174 */ | 
| 431 
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
425diff
changeset | 175 public void setPathPool(Convertor<Path> pathConvertor) { | 
| 
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
425diff
changeset | 176 pathPool = pathConvertor; | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 177 } | 
| 229 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 178 | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 179 /** | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 180 * Limit activity of the collector to certain sub-tree of the repository. | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 181 * @param scopeMatcher tells whether collector shall report specific path, can be <code>null</code> | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 182 */ | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 183 public void setScope(Path.Matcher scopeMatcher) { | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 184 // do not assign null, ever | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 185 scope = scopeMatcher == null ? new Path.Matcher.Any() : scopeMatcher; | 
| 
1ec6b327a6ac
Scope for status reworked: explicit files or a general matcher
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
226diff
changeset | 186 } | 
| 455 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 187 | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 188 /** | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 189 * Select whether Collector shall tell "added-new" from "added-by-copy/rename" files. | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 190 * This is analogous to '-C' switch of 'hg status' command. | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 191 * | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 192 * <p>With copy detection turned off, files continue be reported as plain 'added' files. | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 193 * | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 194 * <p>By default, copy detection is <em>on</em>, as it's reasonably cheap. However, | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 195 * in certain scenarios it may be reasonable to turn it off, for example when it's a merge | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 196 * of two very different branches and there are a lot of files added/moved. | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 197 * | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 198 * Another legitimate reason to set detection to off if you're lazy to | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 199 * implement {@link HgStatusInspector#copied(Path, Path)} ;) | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 200 * | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 201 * @param detect <code>true</code> if copies detection is desirable | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 202 */ | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 203 public void detectCopies(boolean detect) { | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 204 // cpython, revision:72161, p1:72159, p2:72160 | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 205 // p2 comes from another branch with 321 file added (looks like copied/moved, however, the isCopy | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 206 // record present only for couple of them). With 2,5 ms per isCopy() operation, almost a second | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 207 // is spent detecting origins (according to Marc, of little use in this scenario, as it's second parent | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 208 // in the merge) - in fact, most of the time of the status operation | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 209 detectCopies = detect; | 
| 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 210 } | 
| 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: 
56diff
changeset | 211 | 
| 403 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 212 /** | 
| 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 213 * 'hg status --change REV' command counterpart. | 
| 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 214 * | 
| 423 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 215 * @throws CancelledException if operation execution was cancelled | 
| 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 216 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> | 
| 403 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 217 */ | 
| 423 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 218 public void change(int revisionIndex, HgStatusInspector inspector) throws CancelledException, HgRuntimeException { | 
| 405 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 219 int p; | 
| 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 220 if (revisionIndex == 0) { | 
| 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 221 p = NO_REVISION; | 
| 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 222 } else { | 
| 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 223 int[] parents = new int[2]; | 
| 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 224 repo.getChangelog().parents(revisionIndex, parents, null, null); | 
| 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 225 // #parents call above is responsible for NO_REVISION | 
| 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 226 p = parents[0]; // hg --change alsways uses first parent, despite the fact there might be valid (-1, 18) pair of parents | 
| 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 227 } | 
| 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 228 walk(p, revisionIndex, inspector); | 
| 56 
576d6e8a09f6
Analog of 'hg status --change' command
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
55diff
changeset | 229 } | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 230 | 
| 403 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 231 /** | 
| 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 232 * Parameters <b>rev1</b> and <b>rev2</b> are changelog revision indexes, shall not be the same. Argument order matters. | 
| 405 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 233 * Either rev1 or rev2 may be {@link HgRepository#NO_REVISION} to indicate comparison to empty repository | 
| 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 234 * | 
| 403 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 235 * @param rev1 <em>from</em> changeset index, non-negative or {@link HgRepository#TIP} | 
| 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 236 * @param rev2 <em>to</em> changeset index, non-negative or {@link HgRepository#TIP} | 
| 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 237 * @param inspector callback for status information | 
| 423 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 238 * @throws CancelledException if operation execution was cancelled | 
| 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 239 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> | 
| 403 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 240 * @throws IllegalArgumentException inspector other incorrect argument values | 
| 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 241 */ | 
| 423 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 242 public void walk(int rev1, int rev2, HgStatusInspector inspector) throws CancelledException, HgRuntimeException, IllegalArgumentException { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 243 if (rev1 == rev2) { | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 244 throw new IllegalArgumentException(); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 245 } | 
| 64 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 246 if (inspector == null) { | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 247 throw new IllegalArgumentException(); | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 248 } | 
| 403 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 249 final int lastChangelogRevision = repo.getChangelog().getLastRevision(); | 
| 68 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
64diff
changeset | 250 if (rev1 == TIP) { | 
| 403 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 251 rev1 = lastChangelogRevision; | 
| 68 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
64diff
changeset | 252 } | 
| 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
64diff
changeset | 253 if (rev2 == TIP) { | 
| 403 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 254 rev2 = lastChangelogRevision; | 
| 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 255 } | 
| 405 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 256 if (rev1 != NO_REVISION && (HgInternals.wrongRevisionIndex(rev1) || rev1 == WORKING_COPY || rev1 == BAD_REVISION || rev1 > lastChangelogRevision)) { | 
| 403 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 257 throw new HgInvalidRevisionException(rev1); | 
| 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 258 } | 
| 405 
866fc3b597a0
Add an explicit constant instead of -1 to indicate 'no revision' case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
403diff
changeset | 259 if (rev2 != NO_REVISION && (HgInternals.wrongRevisionIndex(rev2) || rev2 == WORKING_COPY || rev2 == BAD_REVISION || rev2 > lastChangelogRevision)) { | 
| 403 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 260 throw new HgInvalidRevisionException(rev2); | 
| 68 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
64diff
changeset | 261 } | 
| 282 
e51dd9a14b6f
Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
281diff
changeset | 262 if (inspector instanceof Record) { | 
| 
e51dd9a14b6f
Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
281diff
changeset | 263 ((Record) inspector).init(rev1, rev2, this); | 
| 
e51dd9a14b6f
Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
281diff
changeset | 264 } | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 265 // 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 | 266 // thus, we can optimize Manifest reads here (manifest.walk(rev1, rev2)) | 
| 248 
3fbfce107f94
Issue 8: Means to find out information about given file at specific changeset. Inner ManifestRevisionInspector got promoted to ManifestRevision
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
229diff
changeset | 267 ManifestRevision r1, r2 ; | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 268 boolean need1 = !cached(rev1), need2 = !cached(rev2); | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 269 if (need1 || need2) { | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 270 int minRev, maxRev; | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 271 if (need1 && need2 && Math.abs(rev1 - rev2) < 5 /*subjective equivalent of 'close enough'*/) { | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 272 minRev = rev1 < rev2 ? rev1 : rev2; | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 273 maxRev = minRev == rev1 ? rev2 : rev1; | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 274 if (minRev > 0) { | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 275 minRev--; // expand range a bit | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 276 } | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 277 initCacheRange(minRev, maxRev); | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 278 need1 = need2 = false; | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 279 } | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 280 // either both unknown and far from each other, or just one of them. | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 281 // read with neighbors to save potential subsequent calls for neighboring elements | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 282 // XXX perhaps, if revlog.baseRevision is cheap, shall expand minRev up to baseRevision | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 283 // which going to be read anyway | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 284 if (need1) { | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 285 minRev = rev1; | 
| 403 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 286 maxRev = rev1 < lastChangelogRevision-5 ? rev1+5 : lastChangelogRevision; | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 287 initCacheRange(minRev, maxRev); | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 288 } | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 289 if (need2) { | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 290 minRev = rev2; | 
| 403 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 291 maxRev = rev2 < lastChangelogRevision-5 ? rev2+5 : lastChangelogRevision; | 
| 197 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 292 initCacheRange(minRev, maxRev); | 
| 
3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
195diff
changeset | 293 } | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 294 } | 
| 89 
42bcb4bffd17
Refactored to simplify manifest collector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
88diff
changeset | 295 r1 = get(rev1); | 
| 
42bcb4bffd17
Refactored to simplify manifest collector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
88diff
changeset | 296 r2 = get(rev2); | 
| 
42bcb4bffd17
Refactored to simplify manifest collector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
88diff
changeset | 297 | 
| 423 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 298 final CancelSupport cs = CancelSupport.Factory.get(inspector); | 
| 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 299 | 
| 285 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 300 TreeSet<Path> r1Files = new TreeSet<Path>(r1.files()); | 
| 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 301 for (Path r2fname : r2.files()) { | 
| 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 302 if (!scope.accept(r2fname)) { | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
222diff
changeset | 303 continue; | 
| 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
222diff
changeset | 304 } | 
| 285 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 305 if (r1Files.remove(r2fname)) { | 
| 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 306 Nodeid nidR1 = r1.nodeid(r2fname); | 
| 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 307 Nodeid nidR2 = r2.nodeid(r2fname); | 
| 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 308 HgManifest.Flags flagsR1 = r1.flags(r2fname); | 
| 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 309 HgManifest.Flags flagsR2 = r2.flags(r2fname); | 
| 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 310 if (nidR1.equals(nidR2) && flagsR2 == flagsR1) { | 
| 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 311 inspector.clean(r2fname); | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 312 } else { | 
| 285 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 313 inspector.modified(r2fname); | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 314 } | 
| 423 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 315 cs.checkCancelled(); | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 316 } 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: 
142diff
changeset | 317 try { | 
| 285 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 318 Path copyTarget = r2fname; | 
| 455 
281cfb60e2ef
Added option to turn detection of copied files off during status operation
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 319 Path copyOrigin = detectCopies ? getOriginIfCopy(repo, copyTarget, r1Files, rev1) : null; | 
| 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: 
142diff
changeset | 320 if (copyOrigin != null) { | 
| 431 
12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
425diff
changeset | 321 inspector.copied(getPathPool().mangle(copyOrigin) /*pipe through pool, just in case*/, copyTarget); | 
| 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: 
142diff
changeset | 322 } 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: 
142diff
changeset | 323 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: 
142diff
changeset | 324 } | 
| 425 
48f993aa2f41
FIXMEs: exceptions, javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
424diff
changeset | 325 } catch (HgInvalidFileException ex) { | 
| 360 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 326 // record exception to a mediator and continue, | 
| 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: 
142diff
changeset | 327 // for a single file not to be irresolvable obstacle for a status operation | 
| 360 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 328 inspector.invalid(r2fname, ex); | 
| 88 
61eedab3eb3e
Status between two revisions to recognize copy/rename
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
74diff
changeset | 329 } | 
| 423 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 330 cs.checkCancelled(); | 
| 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 } | 
| 285 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 333 for (Path r1fname : r1Files) { | 
| 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 334 if (scope.accept(r1fname)) { | 
| 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 335 inspector.removed(r1fname); | 
| 423 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 336 cs.checkCancelled(); | 
| 226 
26ad7827a62d
Support status query for a single file or a subdirectory of a repository
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
222diff
changeset | 337 } | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 338 } | 
| 
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 | 
| 403 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 341 /** | 
| 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 342 * Collects status between two revisions, changes from <b>rev1</b> up to <b>rev2</b>. | 
| 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 343 * | 
| 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 344 * @param rev1 <em>from</em> changeset index | 
| 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 345 * @param rev2 <em>to</em> changeset index | 
| 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 346 * @return information object that describes change between the revisions | 
| 423 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 347 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> | 
| 403 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 348 */ | 
| 
2747b0723867
FIXMEs: work on exceptions and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
396diff
changeset | 349 public Record status(int rev1, int rev2) throws HgInvalidRevisionException, HgInvalidControlFileException { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 350 Record rv = new Record(); | 
| 423 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 351 try { | 
| 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 352 walk(rev1, rev2, rv); | 
| 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 353 } catch (CancelledException ex) { | 
| 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 354 // can't happen as long our Record class doesn't implement CancelSupport | 
| 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 355 HgInvalidStateException t = new HgInvalidStateException("Internal error"); | 
| 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 356 t.initCause(ex); | 
| 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 357 throw t; | 
| 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 358 } | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 359 return rv; | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 360 } | 
| 90 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 361 | 
| 425 
48f993aa2f41
FIXMEs: exceptions, javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
424diff
changeset | 362 /*package-local*/static Path getOriginIfCopy(HgRepository hgRepo, Path fname, Collection<Path> originals, int originalChangelogRevision) throws HgInvalidFileException { | 
| 90 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 363 HgDataFile df = hgRepo.getFileNode(fname); | 
| 320 
678e326fd27c
Issue 15: Exception accessing oddly named file from history
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
316diff
changeset | 364 if (!df.exists()) { | 
| 
678e326fd27c
Issue 15: Exception accessing oddly named file from history
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
316diff
changeset | 365 String msg = String.format("Didn't find file '%s' in the repo. Perhaps, bad storage name conversion?", fname); | 
| 425 
48f993aa2f41
FIXMEs: exceptions, javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
424diff
changeset | 366 throw new HgInvalidFileException(msg, null).setFileName(fname).setRevisionIndex(originalChangelogRevision); | 
| 320 
678e326fd27c
Issue 15: Exception accessing oddly named file from history
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
316diff
changeset | 367 } | 
| 90 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 368 while (df.isCopy()) { | 
| 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 369 Path original = df.getCopySourceName(); | 
| 285 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 370 if (originals.contains(original)) { | 
| 90 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 371 df = hgRepo.getFileNode(original); | 
| 367 
2fadf8695f8a
Use 'revision index' instead of the vague 'local revision number' concept in the API
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
366diff
changeset | 372 int changelogRevision = df.getChangesetRevisionIndex(0); | 
| 90 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 373 if (changelogRevision <= originalChangelogRevision) { | 
| 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 374 // 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: 
89diff
changeset | 375 // (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: 
89diff
changeset | 376 // 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: 
89diff
changeset | 377 // 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: 
135diff
changeset | 378 return original; | 
| 90 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 379 } | 
| 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 380 break; // copy/rename done later | 
| 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 381 } | 
| 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 382 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: 
89diff
changeset | 383 } | 
| 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 384 return null; | 
| 
a95c700408a9
Correctly report copy/rename events for rev..working copy case
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
89diff
changeset | 385 } | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 386 | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 387 // 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: 
68diff
changeset | 388 // XXX Need to specify whether copy targets are in added or not (@see Inspector#copied above) | 
| 316 
ee6b467c1a5f
Supply HGFileRevision with copy information when possible, calculate it otherwise
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
303diff
changeset | 389 /** | 
| 
ee6b467c1a5f
Supply HGFileRevision with copy information when possible, calculate it otherwise
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
303diff
changeset | 390 * Straightforward {@link HgStatusInspector} implementation that collects all status values. | 
| 
ee6b467c1a5f
Supply HGFileRevision with copy information when possible, calculate it otherwise
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
303diff
changeset | 391 * | 
| 
ee6b467c1a5f
Supply HGFileRevision with copy information when possible, calculate it otherwise
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
303diff
changeset | 392 * <p>Naturally, {@link Record Records} originating from {@link HgStatusCollector} would report only <em>modified, added, | 
| 
ee6b467c1a5f
Supply HGFileRevision with copy information when possible, calculate it otherwise
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
303diff
changeset | 393 * removed</em> and <em>clean</em> values, other are available only when using {@link Record} with {@link HgWorkingCopyStatusCollector}. | 
| 
ee6b467c1a5f
Supply HGFileRevision with copy information when possible, calculate it otherwise
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
303diff
changeset | 394 * | 
| 
ee6b467c1a5f
Supply HGFileRevision with copy information when possible, calculate it otherwise
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
303diff
changeset | 395 * <p>Note, this implementation records copied files as added, thus key values in {@link #getCopied()} map are subset of paths | 
| 
ee6b467c1a5f
Supply HGFileRevision with copy information when possible, calculate it otherwise
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
303diff
changeset | 396 * from {@link #getAdded()}. | 
| 
ee6b467c1a5f
Supply HGFileRevision with copy information when possible, calculate it otherwise
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
303diff
changeset | 397 */ | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 398 public static class Record implements HgStatusInspector { | 
| 423 
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
405diff
changeset | 399 // NOTE, shall not implement CancelSupport, or methods that use it and don't expect this exception shall be changed | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 400 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: 
90diff
changeset | 401 private Map<Path, Path> copied; | 
| 360 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 402 private Map<Path, Exception> failures; | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 403 | 
| 64 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 404 private int startRev, endRev; | 
| 94 
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
93diff
changeset | 405 private HgStatusCollector statusHelper; | 
| 64 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 406 | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 407 // 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: 
59diff
changeset | 408 // 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: 
59diff
changeset | 409 // 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: 
59diff
changeset | 410 // 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: 
59diff
changeset | 411 // 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: 
59diff
changeset | 412 // 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: 
59diff
changeset | 413 // how to supply [start..end] values there easily | 
| 94 
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
93diff
changeset | 414 /*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: 
59diff
changeset | 415 startRev = startRevision; | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 416 endRev = endRevision; | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 417 statusHelper = self; | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 418 } | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 419 | 
| 366 
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
360diff
changeset | 420 public Nodeid nodeidBeforeChange(Path fname) throws HgInvalidControlFileException { | 
| 68 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
64diff
changeset | 421 if (statusHelper == null || startRev == BAD_REVISION) { | 
| 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
64diff
changeset | 422 return null; | 
| 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
64diff
changeset | 423 } | 
| 64 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 424 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: 
59diff
changeset | 425 return null; | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 426 } | 
| 285 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 427 return statusHelper.raw(startRev).nodeid(fname); | 
| 64 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 428 } | 
| 366 
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
360diff
changeset | 429 public Nodeid nodeidAfterChange(Path fname) throws HgInvalidControlFileException { | 
| 68 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
64diff
changeset | 430 if (statusHelper == null || endRev == BAD_REVISION) { | 
| 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
64diff
changeset | 431 return null; | 
| 
0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
64diff
changeset | 432 } | 
| 64 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 433 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: 
59diff
changeset | 434 return null; | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 435 } | 
| 285 
6dbbc53fc46d
Use Path instead of plain String for manifest file names
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
284diff
changeset | 436 return statusHelper.raw(endRev).nodeid(fname); | 
| 64 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 437 } | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 438 | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 439 public List<Path> getModified() { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 440 return proper(modified); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 441 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 442 | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 443 public List<Path> getAdded() { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 444 return proper(added); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 445 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 446 | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 447 public List<Path> getRemoved() { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 448 return proper(removed); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 449 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 450 | 
| 316 
ee6b467c1a5f
Supply HGFileRevision with copy information when possible, calculate it otherwise
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
303diff
changeset | 451 /** | 
| 
ee6b467c1a5f
Supply HGFileRevision with copy information when possible, calculate it otherwise
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
303diff
changeset | 452 * Map files from {@link #getAdded()} to their original filenames, if were copied/moved. | 
| 
ee6b467c1a5f
Supply HGFileRevision with copy information when possible, calculate it otherwise
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
303diff
changeset | 453 */ | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 454 public Map<Path,Path> getCopied() { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 455 if (copied == null) { | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 456 return Collections.emptyMap(); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 457 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 458 return Collections.unmodifiableMap(copied); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 459 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 460 | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 461 public List<Path> getClean() { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 462 return proper(clean); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 463 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 464 | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 465 public List<Path> getMissing() { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 466 return proper(missing); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 467 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 468 | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 469 public List<Path> getUnknown() { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 470 return proper(unknown); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 471 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 472 | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 473 public List<Path> getIgnored() { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 474 return proper(ignored); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 475 } | 
| 360 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 476 | 
| 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 477 public Map<Path, Exception> getInvalid() { | 
| 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 478 if (failures == null) { | 
| 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 479 return Collections.emptyMap(); | 
| 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 480 } | 
| 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 481 return Collections.unmodifiableMap(failures); | 
| 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 482 } | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 483 | 
| 316 
ee6b467c1a5f
Supply HGFileRevision with copy information when possible, calculate it otherwise
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
303diff
changeset | 484 private static 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 | 485 if (l == null) { | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 486 return Collections.emptyList(); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 487 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 488 return Collections.unmodifiableList(l); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 489 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 490 | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 491 // | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 492 // | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 493 | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 494 public void modified(Path fname) { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 495 modified = doAdd(modified, fname); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 496 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 497 | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 498 public void added(Path fname) { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 499 added = doAdd(added, fname); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 500 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 501 | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 502 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 | 503 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: 
90diff
changeset | 504 copied = new LinkedHashMap<Path, Path>(); | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 505 } | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 506 added(fnameAdded); | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
68diff
changeset | 507 copied.put(fnameAdded, fnameOrigin); | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 508 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 509 | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 510 public void removed(Path fname) { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 511 removed = doAdd(removed, fname); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 512 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 513 | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 514 public void clean(Path fname) { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 515 clean = doAdd(clean, fname); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 516 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 517 | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 518 public void missing(Path fname) { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 519 missing = doAdd(missing, fname); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 520 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 521 | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 522 public void unknown(Path fname) { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 523 unknown = doAdd(unknown, fname); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 524 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 525 | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 526 public void ignored(Path fname) { | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 527 ignored = doAdd(ignored, fname); | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 528 } | 
| 360 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 529 | 
| 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 530 public void invalid(Path fname, Exception ex) { | 
| 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 531 if (failures == null) { | 
| 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 532 failures = new LinkedHashMap<Path, Exception>(); | 
| 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 533 } | 
| 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 534 failures.put(fname, ex); | 
| 
150500515714
Report non-critical errors during status operation to handler/inspector
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
354diff
changeset | 535 } | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 536 | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 537 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 | 538 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: 
90diff
changeset | 539 l = new LinkedList<Path>(); | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 540 } | 
| 93 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
90diff
changeset | 541 l.add(p); | 
| 55 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 542 return l; | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 543 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 544 } | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 545 | 
| 
05829a70b30b
Status operation extracted into separate, cache-friendly class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 546 } | 
