diff src/org/tmatesoft/hg/core/HgStatus.java @ 247:f052f40839ec

Issue 9: NPE in getModificationDate for files with status 'Unknown'
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 12 Aug 2011 17:17:37 +0200
parents ba2bf656f00f
children 5f9073eabf06
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/HgStatus.java	Thu Aug 11 05:12:13 2011 +0200
+++ b/src/org/tmatesoft/hg/core/HgStatus.java	Fri Aug 12 17:17:37 2011 +0200
@@ -16,6 +16,7 @@
  */
 package org.tmatesoft.hg.core;
 
+import java.io.File;
 import java.util.Date;
 
 import org.tmatesoft.hg.internal.ChangelogHelper;
@@ -86,6 +87,10 @@
 	public Date getModificationDate() {
 		RawChangeset cset = logHelper.findLatestChangeWith(path);
 		if (cset == null) {
+			File localFile = new File(logHelper.getRepo().getWorkingDir(), path.toString());
+			if (localFile.canRead()) {
+				return new Date(localFile.lastModified());
+			}
 			// FIXME check dirstate and/or local file for tstamp
 			return new Date(); // what's correct 
 		} else {