comparison 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
comparison
equal deleted inserted replaced
246:ff4fdbab4e2d 247:f052f40839ec
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.core; 17 package org.tmatesoft.hg.core;
18 18
19 import java.io.File;
19 import java.util.Date; 20 import java.util.Date;
20 21
21 import org.tmatesoft.hg.internal.ChangelogHelper; 22 import org.tmatesoft.hg.internal.ChangelogHelper;
22 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; 23 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
23 import org.tmatesoft.hg.util.Path; 24 import org.tmatesoft.hg.util.Path;
84 } 85 }
85 86
86 public Date getModificationDate() { 87 public Date getModificationDate() {
87 RawChangeset cset = logHelper.findLatestChangeWith(path); 88 RawChangeset cset = logHelper.findLatestChangeWith(path);
88 if (cset == null) { 89 if (cset == null) {
90 File localFile = new File(logHelper.getRepo().getWorkingDir(), path.toString());
91 if (localFile.canRead()) {
92 return new Date(localFile.lastModified());
93 }
89 // FIXME check dirstate and/or local file for tstamp 94 // FIXME check dirstate and/or local file for tstamp
90 return new Date(); // what's correct 95 return new Date(); // what's correct
91 } else { 96 } else {
92 return cset.date(); 97 return cset.date();
93 } 98 }