comparison src/org/tmatesoft/hg/core/HgFileInformer.java @ 396:0ae53c32ecef

Straighten out exceptions thrown when file access failed - three is too much
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 23 Feb 2012 01:06:24 +0100
parents c7a513d8ce20
children ee8264d80747
comparison
equal deleted inserted replaced
395:4732fffff58a 396:0ae53c32ecef
1 /* 1 /*
2 * Copyright (c) 2011 TMate Software Ltd 2 * Copyright (c) 2011-2012 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 *
16 */ 16 */
17 package org.tmatesoft.hg.core; 17 package org.tmatesoft.hg.core;
18 18
19 import org.tmatesoft.hg.internal.ManifestRevision; 19 import org.tmatesoft.hg.internal.ManifestRevision;
20 import org.tmatesoft.hg.repo.HgDataFile; 20 import org.tmatesoft.hg.repo.HgDataFile;
21 import org.tmatesoft.hg.repo.HgInternals;
22 import org.tmatesoft.hg.repo.HgRepository; 21 import org.tmatesoft.hg.repo.HgRepository;
23 import org.tmatesoft.hg.util.Path; 22 import org.tmatesoft.hg.util.Path;
24 import org.tmatesoft.hg.util.Status; 23 import org.tmatesoft.hg.util.Status;
25 24
26 /** 25 /**
120 if (!dataFile.exists()) { 119 if (!dataFile.exists()) {
121 checkResult = new Status(Status.Kind.OK, String.format("File named %s is not known in the repository", file)); 120 checkResult = new Status(Status.Kind.OK, String.format("File named %s is not known in the repository", file));
122 return checkResult; 121 return checkResult;
123 } 122 }
124 Nodeid toExtract = null; 123 Nodeid toExtract = null;
124 String phaseMsg = "Extract manifest revision failed";
125 try { 125 try {
126 if (cachedManifest == null) { 126 if (cachedManifest == null) {
127 int csetRev = repo.getChangelog().getRevisionIndex(cset); 127 int csetRev = repo.getChangelog().getRevisionIndex(cset);
128 cachedManifest = new ManifestRevision(null, null); // XXX how about context and cached manifest revisions 128 cachedManifest = new ManifestRevision(null, null); // XXX how about context and cached manifest revisions
129 repo.getManifest().walk(csetRev, csetRev, cachedManifest); 129 repo.getManifest().walk(csetRev, csetRev, cachedManifest);
130 // cachedManifest shall be meaningful - changelog.getRevisionIndex() above ensures we've got version that exists. 130 // cachedManifest shall be meaningful - changelog.getRevisionIndex() above ensures we've got version that exists.
131 } 131 }
132 toExtract = cachedManifest.nodeid(file); 132 toExtract = cachedManifest.nodeid(file);
133 phaseMsg = "Follow copy/rename failed";
133 if (toExtract == null && followRenames) { 134 if (toExtract == null && followRenames) {
134 while (toExtract == null && dataFile.isCopy()) { 135 while (toExtract == null && dataFile.isCopy()) {
135 renamed = true; 136 renamed = true;
136 file = dataFile.getCopySourceName(); 137 file = dataFile.getCopySourceName();
137 dataFile = repo.getFileNode(file); 138 dataFile = repo.getFileNode(file);
138 toExtract = cachedManifest.nodeid(file); 139 toExtract = cachedManifest.nodeid(file);
139 } 140 }
140 } 141 }
141 } catch (HgInvalidControlFileException ex) { 142 } catch (HgException ex) {
142 checkResult = new Status(Status.Kind.ERROR, "", ex); 143 checkResult = new Status(Status.Kind.ERROR, phaseMsg, ex);
143 return checkResult;
144 } catch (HgDataStreamException ex) {
145 checkResult = new Status(Status.Kind.ERROR, "Follow copy/rename failed", ex);
146 HgInternals.getContext(repo).getLog().warn(getClass(), ex, checkResult.getMessage());
147 return checkResult; 144 return checkResult;
148 } 145 }
149 if (toExtract != null) { 146 if (toExtract != null) {
150 fileRevision = new HgFileRevision(repo, toExtract, dataFile.getPath()); 147 fileRevision = new HgFileRevision(repo, toExtract, dataFile.getPath());
151 checkResult = new Status(Status.Kind.OK, String.format("File %s, revision %s found at changeset %s", dataFile.getPath(), toExtract.shortNotation(), cset.shortNotation())); 148 checkResult = new Status(Status.Kind.OK, String.format("File %s, revision %s found at changeset %s", dataFile.getPath(), toExtract.shortNotation(), cset.shortNotation()));