Mercurial > jhg
diff src/org/tmatesoft/hg/repo/HgBundle.java @ 295:981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 16 Sep 2011 05:35:32 +0200 |
parents | 9fb50c04f03c |
children | 694ebabb5cb3 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgBundle.java Wed Sep 14 04:41:57 2011 +0200 +++ b/src/org/tmatesoft/hg/repo/HgBundle.java Fri Sep 16 05:35:32 2011 +0200 @@ -23,6 +23,7 @@ import org.tmatesoft.hg.core.HgBadStateException; import org.tmatesoft.hg.core.HgException; +import org.tmatesoft.hg.core.HgInvalidFileException; import org.tmatesoft.hg.core.Nodeid; import org.tmatesoft.hg.internal.ByteArrayChannel; import org.tmatesoft.hg.internal.ByteArrayDataAccess; @@ -93,7 +94,7 @@ * @param hgRepo repository that shall possess base revision for this bundle * @param inspector callback to get each changeset found */ - public void changes(final HgRepository hgRepo, final HgChangelog.Inspector inspector) throws HgException, IOException { + public void changes(final HgRepository hgRepo, final HgChangelog.Inspector inspector) throws HgInvalidFileException { Inspector bundleInsp = new Inspector() { DigestHelper dh = new DigestHelper(); boolean emptyChangelog = true; @@ -180,7 +181,7 @@ inspectChangelog(bundleInsp); } - public void dump() throws IOException { + public void dump() throws HgException { Dump dump = new Dump(); inspectAll(dump); System.out.println("Total files:" + dump.names.size()); @@ -246,40 +247,51 @@ } } - public void inspectChangelog(Inspector inspector) throws IOException { + public void inspectChangelog(Inspector inspector) throws HgInvalidFileException { if (inspector == null) { throw new IllegalArgumentException(); } - DataAccess da = getDataStream(); + DataAccess da = null; try { + da = getDataStream(); internalInspectChangelog(da, inspector); + } catch (IOException ex) { + throw new HgInvalidFileException("Bundle.inspectChangelog failed", ex, bundleFile); } finally { - da.done(); + if (da != null) { + da.done(); + } } } - public void inspectManifest(Inspector inspector) throws IOException { + public void inspectManifest(Inspector inspector) throws HgInvalidFileException { if (inspector == null) { throw new IllegalArgumentException(); } - DataAccess da = getDataStream(); + DataAccess da = null; try { + da = getDataStream(); if (da.isEmpty()) { return; } skipGroup(da); // changelog internalInspectManifest(da, inspector); + } catch (IOException ex) { + throw new HgInvalidFileException("Bundle.inspectManifest failed", ex, bundleFile); } finally { - da.done(); + if (da != null) { + da.done(); + } } } - public void inspectFiles(Inspector inspector) throws IOException { + public void inspectFiles(Inspector inspector) throws HgInvalidFileException { if (inspector == null) { throw new IllegalArgumentException(); } - DataAccess da = getDataStream(); + DataAccess da = null; try { + da = getDataStream(); if (da.isEmpty()) { return; } @@ -289,22 +301,31 @@ } skipGroup(da); // manifest internalInspectFiles(da, inspector); + } catch (IOException ex) { + throw new HgInvalidFileException("Bundle.inspectFiles failed", ex, bundleFile); } finally { - da.done(); + if (da != null) { + da.done(); + } } } - public void inspectAll(Inspector inspector) throws IOException { + public void inspectAll(Inspector inspector) throws HgInvalidFileException { if (inspector == null) { throw new IllegalArgumentException(); } - DataAccess da = getDataStream(); + DataAccess da = null; try { + da = getDataStream(); internalInspectChangelog(da, inspector); internalInspectManifest(da, inspector); internalInspectFiles(da, inspector); + } catch (IOException ex) { + throw new HgInvalidFileException("Bundle.inspectAll failed", ex, bundleFile); } finally { - da.done(); + if (da != null) { + da.done(); + } } }