Mercurial > jhg
comparison src/org/tmatesoft/hg/core/HgStatus.java @ 628:6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 22 May 2013 15:52:31 +0200 |
parents | 31a89587eb04 |
children |
comparison
equal
deleted
inserted
replaced
627:5153eb73b18d | 628:6526d8adbc0f |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011-2012 TMate Software Ltd | 2 * Copyright (c) 2011-2013 TMate Software Ltd |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or modify | 4 * This program is free software; you can redistribute it and/or modify |
5 * it under the terms of the GNU General Public License as published by | 5 * it under the terms of the GNU General Public License as published by |
6 * the Free Software Foundation; version 2 of the License. | 6 * the Free Software Foundation; version 2 of the License. |
7 * | 7 * |
19 import java.io.File; | 19 import java.io.File; |
20 import java.util.Date; | 20 import java.util.Date; |
21 | 21 |
22 import org.tmatesoft.hg.internal.ChangelogHelper; | 22 import org.tmatesoft.hg.internal.ChangelogHelper; |
23 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; | 23 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; |
24 import org.tmatesoft.hg.repo.HgRuntimeException; | |
24 import org.tmatesoft.hg.util.Path; | 25 import org.tmatesoft.hg.util.Path; |
25 | 26 |
26 /** | 27 /** |
27 * Repository file status and extra handy information. | 28 * Repository file status and extra handy information. |
28 * | 29 * |
68 return origin != null; | 69 return origin != null; |
69 } | 70 } |
70 | 71 |
71 /** | 72 /** |
72 * @return <code>null</code> if author for the change can't be deduced (e.g. for clean files it's senseless) | 73 * @return <code>null</code> if author for the change can't be deduced (e.g. for clean files it's senseless) |
74 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> | |
73 */ | 75 */ |
74 public String getModificationAuthor() { | 76 public String getModificationAuthor() throws HgRuntimeException { |
75 RawChangeset cset = logHelper.findLatestChangeWith(path); | 77 RawChangeset cset = logHelper.findLatestChangeWith(path); |
76 if (cset == null) { | 78 if (cset == null) { |
77 if (kind == Kind.Modified || kind == Kind.Added || kind == Kind.Removed /*&& RightBoundary is TIP*/) { | 79 if (kind == Kind.Modified || kind == Kind.Added || kind == Kind.Removed /*&& RightBoundary is TIP*/) { |
78 // perhaps, also for Kind.Missing? | 80 // perhaps, also for Kind.Missing? |
79 return logHelper.getNextCommitUsername(); | 81 return logHelper.getNextCommitUsername(); |
82 return cset.user(); | 84 return cset.user(); |
83 } | 85 } |
84 return null; | 86 return null; |
85 } | 87 } |
86 | 88 |
87 public Date getModificationDate() { | 89 /** |
90 * @return date when the file was last modified, never <code>null</code>. Either date of changeset the file was modified at | |
91 * or timestamp of local file, if present | |
92 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> | |
93 */ | |
94 public Date getModificationDate() throws HgRuntimeException { | |
88 RawChangeset cset = logHelper.findLatestChangeWith(path); | 95 RawChangeset cset = logHelper.findLatestChangeWith(path); |
89 if (cset == null) { | 96 if (cset == null) { |
90 File localFile = new File(logHelper.getRepo().getWorkingDir(), path.toString()); | 97 File localFile = new File(logHelper.getRepo().getWorkingDir(), path.toString()); |
91 if (localFile.canRead()) { | 98 if (localFile.canRead()) { |
92 return new Date(localFile.lastModified()); | 99 return new Date(localFile.lastModified()); |
93 } | 100 } |
94 // TODO post-1.0 find out what to do in this case, perhaps, throw an exception? | 101 // TODO post-1.1 find out what to do in this case, perhaps, throw an exception? |
95 // perhaps check dirstate and/or local file for tstamp | 102 // perhaps check dirstate and for timestamp |
96 return new Date(); // what's correct? | 103 return new Date(); // what's correct? |
97 } else { | 104 } else { |
98 return cset.date(); | 105 return cset.date(); |
99 } | 106 } |
100 } | 107 } |