comparison src/org/tmatesoft/hg/repo/HgRepository.java @ 636:ffce73efa2c2

HgCommitCommand: save last commit message
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 06 Jun 2013 19:39:06 +0200
parents 6526d8adbc0f
children c75297c17867
comparison
equal deleted inserted replaced
635:4ec2d44e2bf3 636:ffce73efa2c2
30 import org.tmatesoft.hg.core.HgIOException; 30 import org.tmatesoft.hg.core.HgIOException;
31 import org.tmatesoft.hg.core.Nodeid; 31 import org.tmatesoft.hg.core.Nodeid;
32 import org.tmatesoft.hg.core.SessionContext; 32 import org.tmatesoft.hg.core.SessionContext;
33 import org.tmatesoft.hg.internal.ConfigFile; 33 import org.tmatesoft.hg.internal.ConfigFile;
34 import org.tmatesoft.hg.internal.DirstateReader; 34 import org.tmatesoft.hg.internal.DirstateReader;
35 import org.tmatesoft.hg.internal.FileUtils;
35 import org.tmatesoft.hg.internal.Filter; 36 import org.tmatesoft.hg.internal.Filter;
36 import org.tmatesoft.hg.internal.Internals; 37 import org.tmatesoft.hg.internal.Internals;
37 import org.tmatesoft.hg.internal.PropertyMarshal; 38 import org.tmatesoft.hg.internal.PropertyMarshal;
38 import org.tmatesoft.hg.internal.RevlogStream; 39 import org.tmatesoft.hg.internal.RevlogStream;
39 import org.tmatesoft.hg.internal.SubrepoManager; 40 import org.tmatesoft.hg.internal.SubrepoManager;
357 * 358 *
358 * @return message used for last commit attempt, or <code>null</code> if none 359 * @return message used for last commit attempt, or <code>null</code> if none
359 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> 360 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
360 */ 361 */
361 public String getCommitLastMessage() throws HgInvalidControlFileException { 362 public String getCommitLastMessage() throws HgInvalidControlFileException {
362 File lastMessage = impl.getFileFromRepoDir(LastMessage.getPath()); 363 File lastMessage = impl.getRepositoryFile(LastMessage);
363 if (!lastMessage.canRead()) { 364 if (!lastMessage.canRead()) {
364 return null; 365 return null;
365 } 366 }
366 FileReader fr = null; 367 FileReader fr = null;
367 try { 368 try {
370 fr.read(cb); 371 fr.read(cb);
371 return cb.flip().toString(); 372 return cb.flip().toString();
372 } catch (IOException ex) { 373 } catch (IOException ex) {
373 throw new HgInvalidControlFileException("Can't retrieve message of last commit attempt", ex, lastMessage); 374 throw new HgInvalidControlFileException("Can't retrieve message of last commit attempt", ex, lastMessage);
374 } finally { 375 } finally {
375 if (fr != null) { 376 new FileUtils(getSessionContext().getLog()).closeQuietly(fr, lastMessage);
376 try {
377 fr.close();
378 } catch (IOException ex) {
379 getSessionContext().getLog().dump(getClass(), Warn, "Failed to close %s after read", lastMessage);
380 }
381 }
382 } 377 }
383 } 378 }
384 379
385 /** 380 /**
386 * Access repository lock that covers non-store parts of the repository (dirstate, branches, etc - 381 * Access repository lock that covers non-store parts of the repository (dirstate, branches, etc -