Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java @ 120:b19f0ac5ee62
Check against working copy shall expect non-persistent modifications done by filters and not report such files as modified
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 04 Feb 2011 03:23:47 +0100 |
parents | 6c0be854d149 |
children | 4a948ec83980 |
comparison
equal
deleted
inserted
replaced
119:ed2b4adac51c | 120:b19f0ac5ee62 |
---|---|
14 * the terms of a license other than GNU General Public License | 14 * the terms of a license other than GNU General Public License |
15 * contact TMate Software at support@hg4j.com | 15 * contact TMate Software at support@hg4j.com |
16 */ | 16 */ |
17 package org.tmatesoft.hg.repo; | 17 package org.tmatesoft.hg.repo; |
18 | 18 |
19 import static java.lang.Math.max; | |
19 import static java.lang.Math.min; | 20 import static java.lang.Math.min; |
20 import static org.tmatesoft.hg.repo.HgRepository.BAD_REVISION; | 21 import static org.tmatesoft.hg.repo.HgRepository.BAD_REVISION; |
21 import static org.tmatesoft.hg.repo.HgRepository.TIP; | 22 import static org.tmatesoft.hg.repo.HgRepository.TIP; |
22 | 23 |
23 import java.io.BufferedInputStream; | |
24 import java.io.File; | 24 import java.io.File; |
25 import java.io.FileInputStream; | 25 import java.io.FileInputStream; |
26 import java.io.IOException; | 26 import java.io.IOException; |
27 import java.nio.ByteBuffer; | 27 import java.nio.ByteBuffer; |
28 import java.nio.channels.FileChannel; | 28 import java.nio.channels.FileChannel; |
30 import java.util.Set; | 30 import java.util.Set; |
31 import java.util.TreeSet; | 31 import java.util.TreeSet; |
32 | 32 |
33 import org.tmatesoft.hg.core.Nodeid; | 33 import org.tmatesoft.hg.core.Nodeid; |
34 import org.tmatesoft.hg.core.Path; | 34 import org.tmatesoft.hg.core.Path; |
35 import org.tmatesoft.hg.internal.ByteArrayChannel; | |
36 import org.tmatesoft.hg.internal.FilterByteChannel; | 35 import org.tmatesoft.hg.internal.FilterByteChannel; |
37 import org.tmatesoft.hg.repo.HgStatusCollector.ManifestRevisionInspector; | 36 import org.tmatesoft.hg.repo.HgStatusCollector.ManifestRevisionInspector; |
38 import org.tmatesoft.hg.util.ByteChannel; | 37 import org.tmatesoft.hg.util.ByteChannel; |
39 import org.tmatesoft.hg.util.FileWalker; | 38 import org.tmatesoft.hg.util.FileWalker; |
40 import org.tmatesoft.hg.util.PathPool; | 39 import org.tmatesoft.hg.util.PathPool; |
173 if ((r = getDirstate().checkNormal(fname)) != null) { | 172 if ((r = getDirstate().checkNormal(fname)) != null) { |
174 // either clean or modified | 173 // either clean or modified |
175 if (f.lastModified() / 1000 == r.time && r.size == f.length()) { | 174 if (f.lastModified() / 1000 == r.time && r.size == f.length()) { |
176 inspector.clean(getPathPool().path(fname)); | 175 inspector.clean(getPathPool().path(fname)); |
177 } else { | 176 } else { |
178 // FIXME check actual content to avoid false modified files | 177 // check actual content to avoid false modified files |
179 inspector.modified(getPathPool().path(fname)); | 178 HgDataFile df = repo.getFileNode(fname); |
179 if (!areTheSame(f, df.content(), df.getPath())) { | |
180 inspector.modified(df.getPath()); | |
181 } | |
180 } | 182 } |
181 } else if ((r = getDirstate().checkAdded(fname)) != null) { | 183 } else if ((r = getDirstate().checkAdded(fname)) != null) { |
182 if (r.name2 == null) { | 184 if (r.name2 == null) { |
183 inspector.added(getPathPool().path(fname)); | 185 inspector.added(getPathPool().path(fname)); |
184 } else { | 186 } else { |
257 FileChannel fc = fis.getChannel(); | 259 FileChannel fc = fis.getChannel(); |
258 ByteBuffer fb = ByteBuffer.allocate(min(data.length, 8192)); | 260 ByteBuffer fb = ByteBuffer.allocate(min(data.length, 8192)); |
259 final boolean[] checkValue = new boolean[] { true }; | 261 final boolean[] checkValue = new boolean[] { true }; |
260 ByteChannel check = new ByteChannel() { | 262 ByteChannel check = new ByteChannel() { |
261 int x = 0; | 263 int x = 0; |
264 final boolean debug = false; // XXX may want to add global variable to allow clients to turn | |
262 public int write(ByteBuffer buffer) throws Exception { | 265 public int write(ByteBuffer buffer) throws Exception { |
263 for (int i = buffer.remaining(); i > 0; i--, x++) { | 266 for (int i = buffer.remaining(); i > 0; i--, x++) { |
264 if (data[x] != buffer.get()) { | 267 if (data[x] != buffer.get()) { |
268 if (debug) { | |
269 byte[] xx = new byte[15]; | |
270 if (buffer.position() > 5) { | |
271 buffer.position(buffer.position() - 5); | |
272 } | |
273 buffer.get(xx); | |
274 System.out.print("expected >>" + new String(data, max(0, x - 4), 20) + "<< but got >>"); | |
275 System.out.println(new String(xx) + "<<"); | |
276 } | |
265 checkValue[0] = false; | 277 checkValue[0] = false; |
266 break; | 278 break; |
267 } | 279 } |
268 } | 280 } |
269 buffer.position(buffer.limit()); // mark as read | 281 buffer.position(buffer.limit()); // mark as read |