comparison src/org/tmatesoft/hg/internal/WorkingCopyContent.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 4e6179bde4fc
children
comparison
equal deleted inserted replaced
627:5153eb73b18d 628:6526d8adbc0f
24 import org.tmatesoft.hg.core.HgIOException; 24 import org.tmatesoft.hg.core.HgIOException;
25 import org.tmatesoft.hg.repo.HgDataFile; 25 import org.tmatesoft.hg.repo.HgDataFile;
26 import org.tmatesoft.hg.repo.HgInvalidFileException; 26 import org.tmatesoft.hg.repo.HgInvalidFileException;
27 import org.tmatesoft.hg.repo.HgInvalidStateException; 27 import org.tmatesoft.hg.repo.HgInvalidStateException;
28 import org.tmatesoft.hg.repo.HgRepository; 28 import org.tmatesoft.hg.repo.HgRepository;
29 import org.tmatesoft.hg.repo.HgRuntimeException;
29 import org.tmatesoft.hg.util.ByteChannel; 30 import org.tmatesoft.hg.util.ByteChannel;
30 import org.tmatesoft.hg.util.CancelledException; 31 import org.tmatesoft.hg.util.CancelledException;
31 32
32 /** 33 /**
33 * Access content of the working copy. The difference with {@link FileContentSupplier} is that this one doesn't need {@link File} 34 * Access content of the working copy. The difference with {@link FileContentSupplier} is that this one doesn't need {@link File}
45 if (!dataFile.exists()) { 46 if (!dataFile.exists()) {
46 throw new IllegalArgumentException(); 47 throw new IllegalArgumentException();
47 } 48 }
48 } 49 }
49 50
50 public void serialize(final DataSerializer out) throws HgIOException { 51 public void serialize(final DataSerializer out) throws HgIOException, HgRuntimeException {
51 final HgIOException failure[] = new HgIOException[1]; 52 final HgIOException failure[] = new HgIOException[1];
52 try { 53 try {
53 // TODO #workingCopy API is very limiting, CancelledException is inconvenient, 54 // TODO #workingCopy API is very limiting, CancelledException is inconvenient,
54 // and absence of HgIOException is very uncomfortable 55 // and absence of HgIOException is very uncomfortable
55 file.workingCopy(new ByteChannel() { 56 file.workingCopy(new ByteChannel() {
78 } catch (CancelledException ex) { 79 } catch (CancelledException ex) {
79 throw new HgInvalidStateException("Our channel doesn't cancel here"); 80 throw new HgInvalidStateException("Our channel doesn't cancel here");
80 } 81 }
81 } 82 }
82 83
83 public int serializeLength() { 84 public int serializeLength() throws HgRuntimeException {
84 return file.getLength(HgRepository.WORKING_COPY); 85 return file.getLength(HgRepository.WORKING_COPY);
85 } 86 }
86 } 87 }