Mercurial > hg4j
annotate src/org/tmatesoft/hg/core/HgStatus.java @ 129:645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 16 Feb 2011 20:32:29 +0100 |
parents | 44b97930570c |
children | aa1629f36482 |
rev | line source |
---|---|
127
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011 TMate Software Ltd |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
128
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
127
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.core; |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
128
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
19 import java.util.Date; |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
20 |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
21 import org.tmatesoft.hg.internal.ChangelogHelper; |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
128
diff
changeset
|
22 import org.tmatesoft.hg.repo.HgChangelog.Changeset; |
128
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
23 |
127
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 public class HgStatus { |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
26 public enum Kind { |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 Modified, Added, Removed, Unknown, Missing, Clean, Ignored |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 }; |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
29 |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 private final HgStatus.Kind kind; |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 private final Path path; |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 private final Path origin; |
128
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
33 private final ChangelogHelper logHelper; |
127
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 |
128
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
35 HgStatus(HgStatus.Kind kind, Path path, ChangelogHelper changelogHelper) { |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
36 this(kind, path, null, changelogHelper); |
127
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 } |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 |
128
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
39 HgStatus(HgStatus.Kind kind, Path path, Path copyOrigin, ChangelogHelper changelogHelper) { |
127
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 this.kind = kind; |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
41 this.path = path; |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 origin = copyOrigin; |
128
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
43 logHelper = changelogHelper; |
127
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 } |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 public HgStatus.Kind getKind() { |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 return kind; |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 } |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 public Path getPath() { |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 return path; |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 } |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
53 |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 public Path getOriginalPath() { |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 return origin; |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
56 } |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
57 |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
58 public boolean isCopy() { |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
59 return origin != null; |
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
60 } |
128
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
61 |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
62 /** |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
63 * @return <code>null</code> if author for the change can't be deduced (e.g. for clean files it's senseless) |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
64 */ |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
65 public String getModificationAuthor() { |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
66 Changeset cset = logHelper.findLatestChangeWith(path); |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
67 if (cset == null) { |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
68 if (kind == Kind.Modified || kind == Kind.Added || kind == Kind.Removed /*&& RightBoundary is TIP*/) { |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
69 return logHelper.getNextCommitUsername(); |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
70 } |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
71 } else { |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
72 return cset.user(); |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
73 } |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
74 return null; |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
75 } |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
76 |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
77 public Date getModificationDate() { |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
78 Changeset cset = logHelper.findLatestChangeWith(path); |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
79 if (cset == null) { |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
80 // FIXME check dirstate and/or local file for tstamp |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
81 return new Date(); // what's correct |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
82 } else { |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
83 return cset.date(); |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
84 } |
44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
127
diff
changeset
|
85 } |
127
2e395db595e2
Moved HgStatus to toplevel
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
86 } |