Mercurial > hg4j
diff src/org/tmatesoft/hg/repo/HgBundle.java @ 357:dfb8405d996f
Clean debug stacktraces
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 06 Dec 2011 19:47:01 +0100 |
parents | 5f9073eabf06 |
children | fc8bc2f1edbe |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgBundle.java Tue Dec 06 14:25:52 2011 +0100 +++ b/src/org/tmatesoft/hg/repo/HgBundle.java Tue Dec 06 19:47:01 2011 +0100 @@ -18,13 +18,12 @@ import java.io.File; import java.io.IOException; -import java.util.LinkedList; import org.tmatesoft.hg.core.HgBadStateException; import org.tmatesoft.hg.core.HgCallbackTargetException; -import org.tmatesoft.hg.core.HgException; import org.tmatesoft.hg.core.HgInvalidFileException; import org.tmatesoft.hg.core.Nodeid; +import org.tmatesoft.hg.core.SessionContext; import org.tmatesoft.hg.internal.ByteArrayChannel; import org.tmatesoft.hg.internal.ByteArrayDataAccess; import org.tmatesoft.hg.internal.DataAccess; @@ -45,8 +44,10 @@ private final File bundleFile; private final DataAccessProvider accessProvider; +// private final SessionContext sessionContext; - HgBundle(DataAccessProvider dap, File bundle) { + HgBundle(SessionContext ctx, DataAccessProvider dap, File bundle) { +// sessionContext = ctx; accessProvider = dap; bundleFile = bundle; } @@ -185,15 +186,6 @@ } } - public void dump() throws HgException { - Dump dump = new Dump(); - inspectAll(dump); - System.out.println("Total files:" + dump.names.size()); - for (String s : dump.names) { - System.out.println(s); - } - } - // callback to minimize amount of Strings and Nodeids instantiated public interface Inspector { void changelogStart(); @@ -216,41 +208,6 @@ boolean element(GroupElement element); } - public static class Dump implements Inspector { - public final LinkedList<String> names = new LinkedList<String>(); - - public void changelogStart() { - System.out.println("Changelog group"); - } - - public void changelogEnd() { - } - - public void manifestStart() { - System.out.println("Manifest group"); - } - - public void manifestEnd() { - } - - public void fileStart(String name) { - names.add(name); - System.out.println(name); - } - - public void fileEnd(String name) { - } - - public boolean element(GroupElement ge) { - try { - System.out.printf(" %s %s %s %s; patches:%d\n", ge.node(), ge.firstParent(), ge.secondParent(), ge.cset(), ge.patch().count()); - } catch (Exception ex) { - ex.printStackTrace(); // FIXME - } - return true; - } - } - public void inspectChangelog(Inspector inspector) throws HgInvalidFileException { if (inspector == null) { throw new IllegalArgumentException(); @@ -449,5 +406,16 @@ public byte[] apply(DataAccess baseContent) throws IOException { return patch().apply(baseContent, -1); } + + public String toString() { + int patchCount; + try { + patchCount = patch().count(); + } catch (IOException ex) { + ex.printStackTrace(); + patchCount = -1; + } + return String.format("%s %s %s %s; patches:%d\n", node().shortNotation(), firstParent().shortNotation(), secondParent().shortNotation(), cset().shortNotation(), patchCount); + } } }