Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java @ 506:27398bbfd543
Experiment to add a facility to check working files for actual changes
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 30 Nov 2012 22:52:39 +0100 |
parents | c1c8f6859d3f |
children | 5a455624be4f |
comparison
equal
deleted
inserted
replaced
505:3cd3c3d37432 | 506:27398bbfd543 |
---|---|
32 import java.util.TreeSet; | 32 import java.util.TreeSet; |
33 | 33 |
34 import org.tmatesoft.hg.core.Nodeid; | 34 import org.tmatesoft.hg.core.Nodeid; |
35 import org.tmatesoft.hg.core.SessionContext; | 35 import org.tmatesoft.hg.core.SessionContext; |
36 import org.tmatesoft.hg.internal.ByteArrayChannel; | 36 import org.tmatesoft.hg.internal.ByteArrayChannel; |
37 import org.tmatesoft.hg.internal.Experimental; | |
37 import org.tmatesoft.hg.internal.FilterByteChannel; | 38 import org.tmatesoft.hg.internal.FilterByteChannel; |
38 import org.tmatesoft.hg.internal.Internals; | 39 import org.tmatesoft.hg.internal.Internals; |
39 import org.tmatesoft.hg.internal.ManifestRevision; | 40 import org.tmatesoft.hg.internal.ManifestRevision; |
40 import org.tmatesoft.hg.internal.PathPool; | 41 import org.tmatesoft.hg.internal.PathPool; |
41 import org.tmatesoft.hg.internal.PathScope; | 42 import org.tmatesoft.hg.internal.PathScope; |
160 | 161 |
161 /** | 162 /** |
162 * Walk working copy, analyze status for each file found and missing. | 163 * Walk working copy, analyze status for each file found and missing. |
163 * May be invoked few times. | 164 * May be invoked few times. |
164 * | 165 * |
165 * <p>There's no dedicated constant to for working copy parent, at least now. | 166 * <p>There's no dedicated constant for working copy parent, at least now. |
166 * Use {@link HgRepository#WORKING_COPY} to indicate comparison | 167 * Use {@link HgRepository#WORKING_COPY} to indicate comparison |
167 * shall be run against working copy parent. Although a bit confusing, single case doesn't | 168 * shall be run against working copy parent. Although a bit confusing, single case doesn't |
168 * justify a dedicated constant. | 169 * justify a dedicated constant. |
169 * | 170 * |
170 * @param baseRevision revision index to check against, or {@link HgRepository#WORKING_COPY}. Note, {@link HgRepository#TIP} is not supported. | 171 * @param baseRevision revision index to check against, or {@link HgRepository#WORKING_COPY}. Note, {@link HgRepository#TIP} is not supported. |
320 t.initCause(ex); | 321 t.initCause(ex); |
321 throw t; | 322 throw t; |
322 } | 323 } |
323 return rv; | 324 return rv; |
324 } | 325 } |
326 | |
327 /** | |
328 * Compares file state from working directory against parent recorded in dirstate. | |
329 * Might be handy for merged files, always reported as 'modified' or files deemed modified | |
330 * based on their flags change. | |
331 * | |
332 * @param fname repository-relative path to the file in question | |
333 * @param fileInfo file content mediator | |
334 * @return <code>true</code> when content in working dir differs from that of manifest-recorded revision | |
335 */ | |
336 @Experimental(reason="Perhaps, HgDataFile#isWorkingCopyChanged() would be better - no need to pass any arguments?") | |
337 public boolean hasTangibleChanges(Path fname, FileInfo fileInfo) throws HgRuntimeException { | |
338 // see #checkLocalStatusAgainstFile() below for the origin of changed file check | |
339 HgDataFile df = repo.getFileNode(fname); | |
340 if (!df.exists()) { | |
341 throw new HgInvalidFileException("File not found", null).setFileName(fname); | |
342 } | |
343 Nodeid rev = getDirstateParentManifest().nodeid(fname); | |
344 return rev == null || !areTheSame(fileInfo, df, rev); | |
345 } | |
325 | 346 |
326 //******************************************** | 347 //******************************************** |
327 | 348 |
328 | 349 |
329 private void checkLocalStatusAgainstFile(Path fname, FileInfo f, HgStatusInspector inspector) { | 350 private void checkLocalStatusAgainstFile(Path fname, FileInfo f, HgStatusInspector inspector) { |