annotate src/org/tmatesoft/hg/core/HgChangesetFileSneaker.java @ 694:7efabe0cddcf

Speed up (a) file rename history to minimize file reads; (b) file.isCopy(int) to read metadata for few revisions at once (use pattern assumes earlier revisions are likely to be queried, too); (c) HgIgnore.isIgnored by caching matched initial fragments (to substitute more expensive Matcher.matches with cheaper HashMap.contains)
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 05 Aug 2013 17:42:10 +0200
parents 72fc7774b87e
children
rev   line source
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:
diff changeset
1 /*
690
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
2 * Copyright (c) 2011-2013 TMate Software Ltd
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:
diff changeset
3 *
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:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
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:
diff changeset
5 * it under the terms of the GNU General Public License as published by
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:
diff changeset
6 * the Free Software Foundation; version 2 of the License.
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:
diff changeset
7 *
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:
diff changeset
8 * This program is distributed in the hope that it will be useful,
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:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
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:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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:
diff changeset
11 * GNU General Public License for more details.
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:
diff changeset
12 *
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:
diff changeset
13 * For information on how to redistribute this software under
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:
diff changeset
14 * the terms of a license other than GNU General Public License
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:
diff changeset
15 * contact TMate Software at support@hg4j.com
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:
diff changeset
16 */
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:
diff changeset
17 package org.tmatesoft.hg.core;
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:
diff changeset
18
690
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
19 import java.util.ArrayDeque;
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
20
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:
diff changeset
21 import org.tmatesoft.hg.internal.ManifestRevision;
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:
diff changeset
22 import org.tmatesoft.hg.repo.HgDataFile;
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: 417
diff changeset
23 import org.tmatesoft.hg.repo.HgInvalidStateException;
415
ee8264d80747 Explicit constant for regular file flags, access to flags for a given file revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 396
diff changeset
24 import org.tmatesoft.hg.repo.HgManifest;
690
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
25 import org.tmatesoft.hg.repo.HgManifest.Flags;
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:
diff changeset
26 import org.tmatesoft.hg.repo.HgRepository;
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: 417
diff changeset
27 import org.tmatesoft.hg.repo.HgRuntimeException;
690
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
28 import org.tmatesoft.hg.util.Outcome;
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
29 import org.tmatesoft.hg.util.Pair;
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:
diff changeset
30 import org.tmatesoft.hg.util.Path;
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:
diff changeset
31
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:
diff changeset
32 /**
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:
diff changeset
33 * Primary purpose is to provide information about file revisions at specific changeset. Multiple {@link #check(Path)} calls
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:
diff changeset
34 * are possible once {@link #changeset(Nodeid)} (and optionally, {@link #followRenames(boolean)}) were set.
251
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
35 *
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
36 * <p>Sample:
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
37 * <pre><code>
417
ccd7d25e5aea New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 415
diff changeset
38 * HgChangesetFileSneaker i = new HgChangesetFileSneaker(hgRepo).changeset(Nodeid.fromString("<40 digits>")).followRenames(true);
251
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
39 * if (i.check(file)) {
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
40 * HgCatCommand catCmd = new HgCatCommand(hgRepo).revision(i.getFileRevision());
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
41 * catCmd.execute(...);
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
42 * ...
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
43 * }
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
44 * </pre></code>
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:
diff changeset
45 *
417
ccd7d25e5aea New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 415
diff changeset
46 * TODO may add #manifest(Nodeid) to select manifest according to its revision (not only changeset revision as it's now)
354
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
47 *
417
ccd7d25e5aea New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 415
diff changeset
48 * <p>Unlike {@link HgManifest#getFileRevision(int, Path)}, this class is useful when few files from the same changeset have to be inspected
ccd7d25e5aea New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 415
diff changeset
49 *
ccd7d25e5aea New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 415
diff changeset
50 * @see HgManifest#getFileRevision(int, Path)
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:
diff changeset
51 * @author Artem Tikhomirov
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:
diff changeset
52 * @author TMate Software Ltd.
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:
diff changeset
53 */
434
7e1912b4ce99 Record few known issues while skimming through TODOs
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 427
diff changeset
54 public final class HgChangesetFileSneaker {
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:
diff changeset
55
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:
diff changeset
56 private final HgRepository repo;
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:
diff changeset
57 private boolean followRenames;
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:
diff changeset
58 private Nodeid cset;
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:
diff changeset
59 private ManifestRevision cachedManifest;
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:
diff changeset
60 private HgFileRevision fileRevision;
361
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
61 private boolean renamed;
454
36fd1fd06492 oth.util.Status renamed to Outcome as the noun is too overloaded, especially in scm
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 434
diff changeset
62 private Outcome checkResult;
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:
diff changeset
63
417
ccd7d25e5aea New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 415
diff changeset
64 public HgChangesetFileSneaker(HgRepository hgRepo) {
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:
diff changeset
65 repo = hgRepo;
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:
diff changeset
66 }
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:
diff changeset
67
251
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
68 /**
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
69 * Select specific changelog revision
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
70 *
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
71 * @param nid changeset identifier
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
72 * @return <code>this</code> for convenience
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
73 */
417
ccd7d25e5aea New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 415
diff changeset
74 public HgChangesetFileSneaker changeset(Nodeid nid) {
274
9fb50c04f03c Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 251
diff changeset
75 if (nid == null || nid.isNull()) {
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:
diff changeset
76 throw new IllegalArgumentException();
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:
diff changeset
77 }
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:
diff changeset
78 cset = nid;
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:
diff changeset
79 cachedManifest = null;
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:
diff changeset
80 fileRevision = null;
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:
diff changeset
81 return this;
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:
diff changeset
82 }
251
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
83
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
84 /**
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
85 * Whether to check file origins, default is false (look up only the name supplied)
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
86 *
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
87 * @param follow <code>true</code> to check copy/rename origin of the file if it is a copy.
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
88 * @return <code>this</code> for convenience
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
89 */
417
ccd7d25e5aea New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 415
diff changeset
90 public HgChangesetFileSneaker followRenames(boolean follow) {
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:
diff changeset
91 followRenames = follow;
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:
diff changeset
92 fileRevision = null;
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:
diff changeset
93 return this;
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:
diff changeset
94 }
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:
diff changeset
95
251
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
96 /**
454
36fd1fd06492 oth.util.Status renamed to Outcome as the noun is too overloaded, especially in scm
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 434
diff changeset
97 * Shortcut to perform {@link #check(Path)} and {@link #exists()}. Result of the check may be accessed via {@link #getCheckResult()}.
427
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
98 * Errors during the check, if any, are reported through exception.
251
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
99 *
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
100 * @param file name of the file in question
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
101 * @return <code>true</code> if file is known at the selected changeset.
427
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
102 * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state
251
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
103 * @throws IllegalArgumentException if {@link #changeset(Nodeid)} not specified or file argument is bad.
8c951645bea0 Some javadoc to explain HgFileInformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 248
diff changeset
104 */
427
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
105 public boolean checkExists(Path file) throws HgException {
361
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
106 check(file);
427
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
107 // next seems reasonable, however renders boolean return value useless. perhaps void or distinct method?
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
108 // if (checkResult.isOk() && !exists()) {
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
109 // throw new HgPathNotFoundException(checkResult.getMessage(), file);
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
110 // }
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
111 if (!checkResult.isOk() && checkResult.getException() instanceof HgRuntimeException) {
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
112 throw new HgLibraryFailureException((HgRuntimeException) checkResult.getException());
361
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
113 }
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
114 return checkResult.isOk() && exists();
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
115 }
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
116
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
117 /**
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
118 * Find file (or its origin, if {@link #followRenames(boolean)} was set to <code>true</code>) among files known at specified {@link #changeset(Nodeid)}.
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
119 *
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
120 * @param file name of the file in question
454
36fd1fd06492 oth.util.Status renamed to Outcome as the noun is too overloaded, especially in scm
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 434
diff changeset
121 * @return status object that describes outcome, {@link Outcome#isOk() Ok} status indicates successful completion of the operation, but doesn't imply
361
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
122 * file existence, use {@link #exists()} for that purpose. Message of the status may provide further hints on what exactly had happened.
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
123 * @throws IllegalArgumentException if {@link #changeset(Nodeid)} not specified or file argument is bad.
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
124 */
454
36fd1fd06492 oth.util.Status renamed to Outcome as the noun is too overloaded, especially in scm
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 434
diff changeset
125 public Outcome check(Path file) {
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:
diff changeset
126 fileRevision = null;
361
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
127 checkResult = null;
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:
diff changeset
128 renamed = false;
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:
diff changeset
129 if (cset == null || file == null || file.isDirectory()) {
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:
diff changeset
130 throw new IllegalArgumentException();
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:
diff changeset
131 }
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:
diff changeset
132 HgDataFile dataFile = repo.getFileNode(file);
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:
diff changeset
133 if (!dataFile.exists()) {
454
36fd1fd06492 oth.util.Status renamed to Outcome as the noun is too overloaded, especially in scm
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 434
diff changeset
134 checkResult = new Outcome(Outcome.Kind.Success, String.format("File named %s is not known in the repository", file));
361
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
135 return checkResult;
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:
diff changeset
136 }
361
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
137 Nodeid toExtract = null;
396
0ae53c32ecef Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 374
diff changeset
138 String phaseMsg = "Extract manifest revision failed";
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:
diff changeset
139 try {
361
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
140 if (cachedManifest == null) {
367
2fadf8695f8a Use 'revision index' instead of the vague 'local revision number' concept in the API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 361
diff changeset
141 int csetRev = repo.getChangelog().getRevisionIndex(cset);
361
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
142 cachedManifest = new ManifestRevision(null, null); // XXX how about context and cached manifest revisions
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
143 repo.getManifest().walk(csetRev, csetRev, cachedManifest);
367
2fadf8695f8a Use 'revision index' instead of the vague 'local revision number' concept in the API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 361
diff changeset
144 // cachedManifest shall be meaningful - changelog.getRevisionIndex() above ensures we've got version that exists.
361
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
145 }
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
146 toExtract = cachedManifest.nodeid(file);
396
0ae53c32ecef Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 374
diff changeset
147 phaseMsg = "Follow copy/rename failed";
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:
diff changeset
148 if (toExtract == null && followRenames) {
690
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
149 int csetIndex = repo.getChangelog().getRevisionIndex(cset);
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
150 int ccFileRevIndex = dataFile.getLastRevision(); // copy candidate
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
151 int csetFileEnds = dataFile.getChangesetRevisionIndex(ccFileRevIndex);
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
152 if (csetIndex > csetFileEnds) {
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
153 return new Outcome(Outcome.Kind.Success, String.format("%s: last known changeset for the file %s is %d. Follow renames is possible towards older changesets only", phaseMsg, file, csetFileEnds));
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:
diff changeset
154 }
691
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 690
diff changeset
155 // @see FileRenameHistory, with similar code, which doesn't trace alternative paths
690
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
156 // traceback stack keeps record of all files with isCopy(fileRev) == true we've tried to follow, so that we can try earlier file
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
157 // revisions in case followed fileRev didn't succeed
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
158 ArrayDeque<Pair<HgDataFile, Integer>> traceback = new ArrayDeque<Pair<HgDataFile, Integer>>();
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
159 do {
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
160 int ccCsetIndex = dataFile.getChangesetRevisionIndex(ccFileRevIndex);
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
161 if (ccCsetIndex <= csetIndex) {
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
162 // present dataFile is our (distant) origin
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
163 toExtract = dataFile.getRevision(ccFileRevIndex);
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
164 renamed = true;
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
165 break;
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
166 }
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
167 if (!dataFile.isCopy(ccFileRevIndex)) {
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
168 // nothing left to return to when traceback.isEmpty()
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
169 while (ccFileRevIndex == 0 && !traceback.isEmpty()) {
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
170 Pair<HgDataFile, Integer> lastTurnPoint = traceback.pop();
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
171 dataFile = lastTurnPoint.first();
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
172 ccFileRevIndex = lastTurnPoint.second(); // generally ccFileRevIndex != 0 here, but doesn't hurt to check, hence while
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
173 // fall through to shift down from the file revision we've already looked at
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
174 }
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
175 ccFileRevIndex--;
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
176 continue;
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
177 }
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
178 if (ccFileRevIndex > 0) {
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
179 // there's no reason to memorize turn point if it's the very first revision
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
180 // of the file and we won't be able to try any other earlier revision
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
181 traceback.push(new Pair<HgDataFile, Integer>(dataFile, ccFileRevIndex));
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
182 }
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
183 HgFileRevision origin = dataFile.getCopySource(ccFileRevIndex);
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
184 dataFile = repo.getFileNode(origin.getPath());
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
185 ccFileRevIndex = dataFile.getRevisionIndex(origin.getRevision());
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
186 } while (ccFileRevIndex >= 0);
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
187 // didn't get to csetIndex, no ancestor in file rename history found.
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:
diff changeset
188 }
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: 417
diff changeset
189 } catch (HgRuntimeException ex) {
454
36fd1fd06492 oth.util.Status renamed to Outcome as the noun is too overloaded, especially in scm
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 434
diff changeset
190 checkResult = new Outcome(Outcome.Kind.Failure, phaseMsg, ex);
361
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
191 return checkResult;
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:
diff changeset
192 }
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:
diff changeset
193 if (toExtract != null) {
690
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
194 Flags extractRevFlags = cachedManifest.flags(dataFile.getPath());
415
ee8264d80747 Explicit constant for regular file flags, access to flags for a given file revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 396
diff changeset
195 fileRevision = new HgFileRevision(repo, toExtract, extractRevFlags, dataFile.getPath());
454
36fd1fd06492 oth.util.Status renamed to Outcome as the noun is too overloaded, especially in scm
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 434
diff changeset
196 checkResult = new Outcome(Outcome.Kind.Success, String.format("File %s, revision %s found at changeset %s", dataFile.getPath(), toExtract.shortNotation(), cset.shortNotation()));
361
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
197 return checkResult;
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
198 }
690
b286222158be Fix file.isCopy() use for status and cat commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
199 checkResult = new Outcome(Outcome.Kind.Success, String.format("File %s nor its origins were known at revision %s", file, cset.shortNotation()));
361
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
200 return checkResult;
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
201 }
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
202
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
203 /**
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
204 * Re-get latest check status object
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
205 */
454
36fd1fd06492 oth.util.Status renamed to Outcome as the noun is too overloaded, especially in scm
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 434
diff changeset
206 public Outcome getCheckResult() {
361
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
207 assertCheckRan();
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
208 return checkResult;
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:
diff changeset
209 }
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:
diff changeset
210
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:
diff changeset
211 /**
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:
diff changeset
212 * @return result of the last {@link #check(Path)} call.
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:
diff changeset
213 */
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:
diff changeset
214 public boolean exists() {
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:
diff changeset
215 assertCheckRan();
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:
diff changeset
216 return fileRevision != null;
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:
diff changeset
217 }
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:
diff changeset
218
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:
diff changeset
219 /**
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:
diff changeset
220 * @return <code>true</code> if checked file was known by another name at the time of specified changeset.
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:
diff changeset
221 */
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:
diff changeset
222 public boolean hasAnotherName() {
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:
diff changeset
223 assertCheckRan();
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:
diff changeset
224 return renamed;
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:
diff changeset
225 }
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:
diff changeset
226
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:
diff changeset
227 /**
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:
diff changeset
228 * @return holder for file revision information
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:
diff changeset
229 */
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:
diff changeset
230 public HgFileRevision getFileRevision() {
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:
diff changeset
231 assertCheckRan();
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:
diff changeset
232 return fileRevision;
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:
diff changeset
233 }
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:
diff changeset
234
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:
diff changeset
235 /**
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:
diff changeset
236 * Name of the checked file as it was known at the time of the specified changeset.
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:
diff changeset
237 *
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:
diff changeset
238 * @return handy shortcut for <code>getFileRevision().getPath()</code>
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:
diff changeset
239 */
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:
diff changeset
240 public Path filename() {
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:
diff changeset
241 assertCheckRan();
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:
diff changeset
242 return fileRevision.getPath();
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:
diff changeset
243 }
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:
diff changeset
244
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:
diff changeset
245 /**
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:
diff changeset
246 * Revision of the checked file
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:
diff changeset
247 *
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:
diff changeset
248 * @return handy shortcut for <code>getFileRevision().getRevision()</code>
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:
diff changeset
249 */
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:
diff changeset
250 public Nodeid revision() {
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:
diff changeset
251 assertCheckRan();
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:
diff changeset
252 return fileRevision.getRevision();
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:
diff changeset
253 }
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:
diff changeset
254
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:
diff changeset
255 private void assertCheckRan() {
361
8099939af5fa Utilize status object to supply more information about manifest check for specific file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
256 if (checkResult == null) {
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: 417
diff changeset
257 throw new HgInvalidStateException("Shall invoke #check(Path) first");
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:
diff changeset
258 }
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:
diff changeset
259 }
417
ccd7d25e5aea New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 415
diff changeset
260
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:
diff changeset
261 }