Mercurial > jhg
diff src/org/tmatesoft/hg/internal/RevlogChangeMonitor.java @ 621:99ad1e3a4e4d
RevlogStream: be aware of existence (not HgDataFile), facilitate use of an added HgDataFile over a commit; Rollback: be more sensitive about file changes (file size is not enough: write/rollback leaves it intact); tests
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Sat, 18 May 2013 22:23:57 +0200 |
parents | 66f1cc23b906 |
children |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/RevlogChangeMonitor.java Sat May 18 21:55:31 2013 +0200 +++ b/src/org/tmatesoft/hg/internal/RevlogChangeMonitor.java Sat May 18 22:23:57 2013 +0200 @@ -29,19 +29,22 @@ public class RevlogChangeMonitor { private final WeakHashMap<File, Long> lastKnownSize; + private final WeakHashMap<File, Long> lastKnownTime; private final File soleFile; - private long soleFileLength = -1; + private long soleFileSize = -1; + private long soleFileTime = -1; - // use single for multiple files. TODO repository/session context shall provide + // use single for multiple files. TODO [1.2] repository/session context shall provide // alternative (configurable) implementations, so that Java7 users may supply better one public RevlogChangeMonitor() { lastKnownSize = new WeakHashMap<File, Long>(); + lastKnownTime= new WeakHashMap<File, Long>(); soleFile = null; } public RevlogChangeMonitor(File f) { assert f != null; - lastKnownSize = null; + lastKnownSize = lastKnownTime = null; soleFile = f; } @@ -49,9 +52,11 @@ assert f != null; if (lastKnownSize == null) { assert f == soleFile; - soleFileLength = f.length(); + soleFileSize = f.length(); + soleFileTime = f.lastModified(); } else { lastKnownSize.put(f, f.length()); + lastKnownTime.put(f, f.lastModified()); } } @@ -59,13 +64,14 @@ assert f != null; if (lastKnownSize == null) { assert f == soleFile; - return soleFileLength != f.length(); + return soleFileSize != f.length() || soleFileTime != f.lastModified(); } else { Long lastSize = lastKnownSize.get(f); - if (lastSize == null) { + Long lastTime = lastKnownTime.get(f); + if (lastSize == null || lastTime == null) { return true; } - return f.length() != lastSize; + return f.length() != lastSize || f.lastModified() != lastTime; } } }