Mercurial > hg4j
comparison src/org/tmatesoft/hg/core/HgChangesetFileSneaker.java @ 454:36fd1fd06492
oth.util.Status renamed to Outcome as the noun is too overloaded, especially in scm
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 13 Jun 2012 21:07:39 +0200 |
parents | 7e1912b4ce99 |
children | 3ca4ae7bdd38 |
comparison
equal
deleted
inserted
replaced
453:7b883bf03b14 | 454:36fd1fd06492 |
---|---|
21 import org.tmatesoft.hg.repo.HgInvalidStateException; | 21 import org.tmatesoft.hg.repo.HgInvalidStateException; |
22 import org.tmatesoft.hg.repo.HgManifest; | 22 import org.tmatesoft.hg.repo.HgManifest; |
23 import org.tmatesoft.hg.repo.HgRepository; | 23 import org.tmatesoft.hg.repo.HgRepository; |
24 import org.tmatesoft.hg.repo.HgRuntimeException; | 24 import org.tmatesoft.hg.repo.HgRuntimeException; |
25 import org.tmatesoft.hg.util.Path; | 25 import org.tmatesoft.hg.util.Path; |
26 import org.tmatesoft.hg.util.Status; | 26 import org.tmatesoft.hg.util.Outcome; |
27 | 27 |
28 /** | 28 /** |
29 * Primary purpose is to provide information about file revisions at specific changeset. Multiple {@link #check(Path)} calls | 29 * Primary purpose is to provide information about file revisions at specific changeset. Multiple {@link #check(Path)} calls |
30 * are possible once {@link #changeset(Nodeid)} (and optionally, {@link #followRenames(boolean)}) were set. | 30 * are possible once {@link #changeset(Nodeid)} (and optionally, {@link #followRenames(boolean)}) were set. |
31 * | 31 * |
53 private boolean followRenames; | 53 private boolean followRenames; |
54 private Nodeid cset; | 54 private Nodeid cset; |
55 private ManifestRevision cachedManifest; | 55 private ManifestRevision cachedManifest; |
56 private HgFileRevision fileRevision; | 56 private HgFileRevision fileRevision; |
57 private boolean renamed; | 57 private boolean renamed; |
58 private Status checkResult; | 58 private Outcome checkResult; |
59 | 59 |
60 public HgChangesetFileSneaker(HgRepository hgRepo) { | 60 public HgChangesetFileSneaker(HgRepository hgRepo) { |
61 repo = hgRepo; | 61 repo = hgRepo; |
62 } | 62 } |
63 | 63 |
88 fileRevision = null; | 88 fileRevision = null; |
89 return this; | 89 return this; |
90 } | 90 } |
91 | 91 |
92 /** | 92 /** |
93 * Shortcut to perform {@link #check(Path)} and {@link #exists()}. Result of the check may be accessed via {@link #getCheckStatus()}. | 93 * Shortcut to perform {@link #check(Path)} and {@link #exists()}. Result of the check may be accessed via {@link #getCheckResult()}. |
94 * Errors during the check, if any, are reported through exception. | 94 * Errors during the check, if any, are reported through exception. |
95 * | 95 * |
96 * @param file name of the file in question | 96 * @param file name of the file in question |
97 * @return <code>true</code> if file is known at the selected changeset. | 97 * @return <code>true</code> if file is known at the selected changeset. |
98 * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state | 98 * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state |
112 | 112 |
113 /** | 113 /** |
114 * Find file (or its origin, if {@link #followRenames(boolean)} was set to <code>true</code>) among files known at specified {@link #changeset(Nodeid)}. | 114 * Find file (or its origin, if {@link #followRenames(boolean)} was set to <code>true</code>) among files known at specified {@link #changeset(Nodeid)}. |
115 * | 115 * |
116 * @param file name of the file in question | 116 * @param file name of the file in question |
117 * @return status object that describes outcome, {@link Status#isOk() Ok} status indicates successful completion of the operation, but doesn't imply | 117 * @return status object that describes outcome, {@link Outcome#isOk() Ok} status indicates successful completion of the operation, but doesn't imply |
118 * file existence, use {@link #exists()} for that purpose. Message of the status may provide further hints on what exactly had happened. | 118 * file existence, use {@link #exists()} for that purpose. Message of the status may provide further hints on what exactly had happened. |
119 * @throws IllegalArgumentException if {@link #changeset(Nodeid)} not specified or file argument is bad. | 119 * @throws IllegalArgumentException if {@link #changeset(Nodeid)} not specified or file argument is bad. |
120 */ | 120 */ |
121 public Status check(Path file) { | 121 public Outcome check(Path file) { |
122 fileRevision = null; | 122 fileRevision = null; |
123 checkResult = null; | 123 checkResult = null; |
124 renamed = false; | 124 renamed = false; |
125 if (cset == null || file == null || file.isDirectory()) { | 125 if (cset == null || file == null || file.isDirectory()) { |
126 throw new IllegalArgumentException(); | 126 throw new IllegalArgumentException(); |
127 } | 127 } |
128 HgDataFile dataFile = repo.getFileNode(file); | 128 HgDataFile dataFile = repo.getFileNode(file); |
129 if (!dataFile.exists()) { | 129 if (!dataFile.exists()) { |
130 checkResult = new Status(Status.Kind.OK, String.format("File named %s is not known in the repository", file)); | 130 checkResult = new Outcome(Outcome.Kind.Success, String.format("File named %s is not known in the repository", file)); |
131 return checkResult; | 131 return checkResult; |
132 } | 132 } |
133 Nodeid toExtract = null; | 133 Nodeid toExtract = null; |
134 HgManifest.Flags extractRevFlags = null; | 134 HgManifest.Flags extractRevFlags = null; |
135 String phaseMsg = "Extract manifest revision failed"; | 135 String phaseMsg = "Extract manifest revision failed"; |
151 toExtract = cachedManifest.nodeid(file); | 151 toExtract = cachedManifest.nodeid(file); |
152 extractRevFlags = cachedManifest.flags(file); | 152 extractRevFlags = cachedManifest.flags(file); |
153 } | 153 } |
154 } | 154 } |
155 } catch (HgRuntimeException ex) { | 155 } catch (HgRuntimeException ex) { |
156 checkResult = new Status(Status.Kind.ERROR, phaseMsg, ex); | 156 checkResult = new Outcome(Outcome.Kind.Failure, phaseMsg, ex); |
157 return checkResult; | 157 return checkResult; |
158 } | 158 } |
159 if (toExtract != null) { | 159 if (toExtract != null) { |
160 fileRevision = new HgFileRevision(repo, toExtract, extractRevFlags, dataFile.getPath()); | 160 fileRevision = new HgFileRevision(repo, toExtract, extractRevFlags, dataFile.getPath()); |
161 checkResult = new Status(Status.Kind.OK, String.format("File %s, revision %s found at changeset %s", dataFile.getPath(), toExtract.shortNotation(), cset.shortNotation())); | 161 checkResult = new Outcome(Outcome.Kind.Success, String.format("File %s, revision %s found at changeset %s", dataFile.getPath(), toExtract.shortNotation(), cset.shortNotation())); |
162 return checkResult; | 162 return checkResult; |
163 } | 163 } |
164 checkResult = new Status(Status.Kind.OK, String.format("File %s nor its origins were known at repository %s revision", file, cset.shortNotation())); | 164 checkResult = new Outcome(Outcome.Kind.Success, String.format("File %s nor its origins were known at repository %s revision", file, cset.shortNotation())); |
165 return checkResult; | 165 return checkResult; |
166 } | 166 } |
167 | 167 |
168 /** | 168 /** |
169 * @deprecated use {@link #getCheckResult()} instead | |
170 */ | |
171 @Deprecated | |
172 public Outcome getCheckStatus() { | |
173 return getCheckResult(); | |
174 } | |
175 /** | |
169 * Re-get latest check status object | 176 * Re-get latest check status object |
170 */ | 177 */ |
171 public Status getCheckStatus() { | 178 public Outcome getCheckResult() { |
172 assertCheckRan(); | 179 assertCheckRan(); |
173 return checkResult; | 180 return checkResult; |
174 } | 181 } |
175 | 182 |
176 /** | 183 /** |