# HG changeset patch # User Artem Tikhomirov # Date 1296786227 -3600 # Node ID b19f0ac5ee627ebf99435f85c1990740869fd9bd # Parent ed2b4adac51cfbf6a49b6625c4fa3dc1c2b65632 Check against working copy shall expect non-persistent modifications done by filters and not report such files as modified diff -r ed2b4adac51c -r b19f0ac5ee62 src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java --- a/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java Fri Feb 04 03:09:15 2011 +0100 +++ b/src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java Fri Feb 04 03:23:47 2011 +0100 @@ -16,11 +16,11 @@ */ package org.tmatesoft.hg.repo; +import static java.lang.Math.max; import static java.lang.Math.min; import static org.tmatesoft.hg.repo.HgRepository.BAD_REVISION; import static org.tmatesoft.hg.repo.HgRepository.TIP; -import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -32,7 +32,6 @@ import org.tmatesoft.hg.core.Nodeid; import org.tmatesoft.hg.core.Path; -import org.tmatesoft.hg.internal.ByteArrayChannel; import org.tmatesoft.hg.internal.FilterByteChannel; import org.tmatesoft.hg.repo.HgStatusCollector.ManifestRevisionInspector; import org.tmatesoft.hg.util.ByteChannel; @@ -175,8 +174,11 @@ if (f.lastModified() / 1000 == r.time && r.size == f.length()) { inspector.clean(getPathPool().path(fname)); } else { - // FIXME check actual content to avoid false modified files - inspector.modified(getPathPool().path(fname)); + // check actual content to avoid false modified files + HgDataFile df = repo.getFileNode(fname); + if (!areTheSame(f, df.content(), df.getPath())) { + inspector.modified(df.getPath()); + } } } else if ((r = getDirstate().checkAdded(fname)) != null) { if (r.name2 == null) { @@ -259,9 +261,19 @@ final boolean[] checkValue = new boolean[] { true }; ByteChannel check = new ByteChannel() { int x = 0; + final boolean debug = false; // XXX may want to add global variable to allow clients to turn public int write(ByteBuffer buffer) throws Exception { for (int i = buffer.remaining(); i > 0; i--, x++) { if (data[x] != buffer.get()) { + if (debug) { + byte[] xx = new byte[15]; + if (buffer.position() > 5) { + buffer.position(buffer.position() - 5); + } + buffer.get(xx); + System.out.print("expected >>" + new String(data, max(0, x - 4), 20) + "<< but got >>"); + System.out.println(new String(xx) + "<<"); + } checkValue[0] = false; break; }