Mercurial > jhg
comparison src/org/tmatesoft/hg/core/HgCatCommand.java @ 423:9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Fri, 23 Mar 2012 22:51:18 +0100 |
| parents | 0ae53c32ecef |
| children | 31a89587eb04 |
comparison
equal
deleted
inserted
replaced
| 422:5d1cc7366d04 | 423:9c9c442b5f2e |
|---|---|
| 22 | 22 |
| 23 import java.io.IOException; | 23 import java.io.IOException; |
| 24 import java.nio.ByteBuffer; | 24 import java.nio.ByteBuffer; |
| 25 | 25 |
| 26 import org.tmatesoft.hg.repo.HgDataFile; | 26 import org.tmatesoft.hg.repo.HgDataFile; |
| 27 import org.tmatesoft.hg.repo.HgInvalidControlFileException; | |
| 28 import org.tmatesoft.hg.repo.HgInvalidFileException; | |
| 29 import org.tmatesoft.hg.repo.HgInvalidRevisionException; | |
| 27 import org.tmatesoft.hg.repo.HgRepository; | 30 import org.tmatesoft.hg.repo.HgRepository; |
| 28 import org.tmatesoft.hg.util.Adaptable; | 31 import org.tmatesoft.hg.util.Adaptable; |
| 29 import org.tmatesoft.hg.util.ByteChannel; | 32 import org.tmatesoft.hg.util.ByteChannel; |
| 30 import org.tmatesoft.hg.util.CancelSupport; | 33 import org.tmatesoft.hg.util.CancelSupport; |
| 31 import org.tmatesoft.hg.util.CancelledException; | 34 import org.tmatesoft.hg.util.CancelledException; |
| 159 int revToExtract; | 162 int revToExtract; |
| 160 if (cset != null) { | 163 if (cset != null) { |
| 161 int csetRev = repo.getChangelog().getRevisionIndex(cset); | 164 int csetRev = repo.getChangelog().getRevisionIndex(cset); |
| 162 Nodeid toExtract = null; | 165 Nodeid toExtract = null; |
| 163 do { | 166 do { |
| 167 // TODO post-1.0 perhaps, HgChangesetFileSneaker may come handy? | |
| 164 toExtract = repo.getManifest().getFileRevision(csetRev, file); | 168 toExtract = repo.getManifest().getFileRevision(csetRev, file); |
| 165 if (toExtract == null) { | 169 if (toExtract == null) { |
| 166 if (dataFile.isCopy()) { | 170 if (dataFile.isCopy()) { |
| 167 file = dataFile.getCopySourceName(); | 171 file = dataFile.getCopySourceName(); |
| 168 dataFile = repo.getFileNode(file); | 172 dataFile = repo.getFileNode(file); |
| 170 break; | 174 break; |
| 171 } | 175 } |
| 172 } | 176 } |
| 173 } while (toExtract == null); | 177 } while (toExtract == null); |
| 174 if (toExtract == null) { | 178 if (toExtract == null) { |
| 175 throw new HgBadStateException(String.format("File %s nor its origins were not known at repository %s revision", file, cset.shortNotation())); | 179 // TODO explicit FileNotFoundException? |
| 180 throw new HgBadArgumentException(String.format("File %s nor its origins were not known at repository %s revision", file, cset.shortNotation()), null); | |
| 176 } | 181 } |
| 177 revToExtract = dataFile.getRevisionIndex(toExtract); | 182 revToExtract = dataFile.getRevisionIndex(toExtract); |
| 178 } else if (revision != null) { | 183 } else if (revision != null) { |
| 179 revToExtract = dataFile.getRevisionIndex(revision); | 184 revToExtract = dataFile.getRevisionIndex(revision); |
| 180 } else { | 185 } else { |
