Mercurial > hg4j
changeset 451:39fe00407937 smartgit3
HgBadStateException in ParentWalker.assertSortedIndex when phaseroots lists non-existent revision
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 08 Jun 2012 17:55:00 +0200 |
parents | 03fd8d079e9c |
children | 281cfb60e2ef |
files | src/org/tmatesoft/hg/internal/PhasesHelper.java |
diffstat | 1 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/PhasesHelper.java Thu Jun 07 17:06:23 2012 +0200 +++ b/src/org/tmatesoft/hg/internal/PhasesHelper.java Fri Jun 08 17:55:00 2012 +0200 @@ -113,12 +113,13 @@ private Boolean readRoots() throws HgInvalidControlFileException { // FIXME shall access phaseroots through HgRepository#repoPathHelper File phaseroots = new File(HgInternals.getRepositoryDir(repo), "store/phaseroots"); + BufferedReader br = null; try { if (!phaseroots.exists()) { return Boolean.FALSE; } HashMap<HgPhase, List<Nodeid>> phase2roots = new HashMap<HgPhase, List<Nodeid>>(); - BufferedReader br = new BufferedReader(new FileReader(phaseroots)); + br = new BufferedReader(new FileReader(phaseroots)); String line; while ((line = br.readLine()) != null) { String[] lc = line.trim().split("\\s+"); @@ -131,6 +132,10 @@ } int phaseIndex = Integer.parseInt(lc[0]); Nodeid rootRev = Nodeid.fromAscii(lc[1]); + if (!repo.getChangelog().isKnown(rootRev)) { + HgInternals.getContext(repo).getLog().warn(getClass(), "Phase(%d) root node %s doesn't exist in the repository, ignored.", phaseIndex, rootRev); + continue; + } HgPhase phase = HgPhase.parse(phaseIndex); List<Nodeid> roots = phase2roots.get(phase); if (roots == null) { @@ -142,6 +147,15 @@ secretPhaseRoots = phase2roots.containsKey(Secret) ? phase2roots.get(Secret) : Collections.<Nodeid>emptyList(); } catch (IOException ex) { throw new HgInvalidControlFileException(ex.toString(), ex, phaseroots); + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException ex) { + HgInternals.getContext(repo).getLog().info(getClass(), ex, null); + // ignore the exception otherwise + } + } } return Boolean.TRUE; }