Mercurial > hg4j
comparison 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 |
comparison
equal
deleted
inserted
replaced
127:2e395db595e2 | 128:44b97930570c |
---|---|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 * GNU General Public License for more details. | 11 * GNU General Public License for more details. |
12 * | 12 * |
13 * For information on how to redistribute this software under | 13 * For information on how to redistribute this software under |
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@svnkit.com | 15 * contact TMate Software at support@hg4j.com |
16 */ | 16 */ |
17 package org.tmatesoft.hg.core; | 17 package org.tmatesoft.hg.core; |
18 | |
19 import java.util.Date; | |
20 | |
21 import org.tmatesoft.hg.internal.ChangelogHelper; | |
22 import org.tmatesoft.hg.repo.Changeset; | |
18 | 23 |
19 public class HgStatus { | 24 public class HgStatus { |
20 | 25 |
21 public enum Kind { | 26 public enum Kind { |
22 Modified, Added, Removed, Unknown, Missing, Clean, Ignored | 27 Modified, Added, Removed, Unknown, Missing, Clean, Ignored |
23 }; | 28 }; |
24 | 29 |
25 private final HgStatus.Kind kind; | 30 private final HgStatus.Kind kind; |
26 private final Path path; | 31 private final Path path; |
27 private final Path origin; | 32 private final Path origin; |
33 private final ChangelogHelper logHelper; | |
28 | 34 |
29 HgStatus(HgStatus.Kind kind, Path path) { | 35 HgStatus(HgStatus.Kind kind, Path path, ChangelogHelper changelogHelper) { |
30 this(kind, path, null); | 36 this(kind, path, null, changelogHelper); |
31 } | 37 } |
32 | 38 |
33 HgStatus(HgStatus.Kind kind, Path path, Path copyOrigin) { | 39 HgStatus(HgStatus.Kind kind, Path path, Path copyOrigin, ChangelogHelper changelogHelper) { |
34 this.kind = kind; | 40 this.kind = kind; |
35 this.path = path; | 41 this.path = path; |
36 origin = copyOrigin; | 42 origin = copyOrigin; |
43 logHelper = changelogHelper; | |
37 } | 44 } |
38 | 45 |
39 public HgStatus.Kind getKind() { | 46 public HgStatus.Kind getKind() { |
40 return kind; | 47 return kind; |
41 } | 48 } |
49 } | 56 } |
50 | 57 |
51 public boolean isCopy() { | 58 public boolean isCopy() { |
52 return origin != null; | 59 return origin != null; |
53 } | 60 } |
54 | 61 |
55 // public String getModificationAuthor() { | 62 /** |
56 // } | 63 * @return <code>null</code> if author for the change can't be deduced (e.g. for clean files it's senseless) |
57 // | 64 */ |
58 // public Date getModificationDate() { | 65 public String getModificationAuthor() { |
59 // } | 66 Changeset cset = logHelper.findLatestChangeWith(path); |
67 if (cset == null) { | |
68 if (kind == Kind.Modified || kind == Kind.Added || kind == Kind.Removed /*&& RightBoundary is TIP*/) { | |
69 return logHelper.getNextCommitUsername(); | |
70 } | |
71 } else { | |
72 return cset.user(); | |
73 } | |
74 return null; | |
75 } | |
76 | |
77 public Date getModificationDate() { | |
78 Changeset cset = logHelper.findLatestChangeWith(path); | |
79 if (cset == null) { | |
80 // FIXME check dirstate and/or local file for tstamp | |
81 return new Date(); // what's correct | |
82 } else { | |
83 return cset.date(); | |
84 } | |
85 } | |
60 } | 86 } |