Mercurial > jhg
diff src/org/tmatesoft/hg/core/HgStatus.java @ 128:44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 16 Feb 2011 20:13:41 +0100 |
parents | 2e395db595e2 |
children | 645829962785 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/HgStatus.java Wed Feb 16 18:42:10 2011 +0100 +++ b/src/org/tmatesoft/hg/core/HgStatus.java Wed Feb 16 20:13:41 2011 +0100 @@ -12,10 +12,15 @@ * * For information on how to redistribute this software under * the terms of a license other than GNU General Public License - * contact TMate Software at support@svnkit.com + * contact TMate Software at support@hg4j.com */ package org.tmatesoft.hg.core; +import java.util.Date; + +import org.tmatesoft.hg.internal.ChangelogHelper; +import org.tmatesoft.hg.repo.Changeset; + public class HgStatus { public enum Kind { @@ -25,15 +30,17 @@ private final HgStatus.Kind kind; private final Path path; private final Path origin; + private final ChangelogHelper logHelper; - HgStatus(HgStatus.Kind kind, Path path) { - this(kind, path, null); + HgStatus(HgStatus.Kind kind, Path path, ChangelogHelper changelogHelper) { + this(kind, path, null, changelogHelper); } - HgStatus(HgStatus.Kind kind, Path path, Path copyOrigin) { + HgStatus(HgStatus.Kind kind, Path path, Path copyOrigin, ChangelogHelper changelogHelper) { this.kind = kind; this.path = path; origin = copyOrigin; + logHelper = changelogHelper; } public HgStatus.Kind getKind() { @@ -51,10 +58,29 @@ public boolean isCopy() { return origin != null; } - -// public String getModificationAuthor() { -// } -// -// public Date getModificationDate() { -// } + + /** + * @return <code>null</code> if author for the change can't be deduced (e.g. for clean files it's senseless) + */ + public String getModificationAuthor() { + Changeset cset = logHelper.findLatestChangeWith(path); + if (cset == null) { + if (kind == Kind.Modified || kind == Kind.Added || kind == Kind.Removed /*&& RightBoundary is TIP*/) { + return logHelper.getNextCommitUsername(); + } + } else { + return cset.user(); + } + return null; + } + + public Date getModificationDate() { + Changeset cset = logHelper.findLatestChangeWith(path); + if (cset == null) { + // FIXME check dirstate and/or local file for tstamp + return new Date(); // what's correct + } else { + return cset.date(); + } + } } \ No newline at end of file