# HG changeset patch # User Artem Tikhomirov # Date 1323197221 -3600 # Node ID dfb8405d996f524c83f541a9be0fae4641cc586c # Parent 91d75e1bac9fce0afb4b51b8539c01042a676b4e Clean debug stacktraces diff -r 91d75e1bac9f -r dfb8405d996f cmdline/org/tmatesoft/hg/console/Bundle.java --- a/cmdline/org/tmatesoft/hg/console/Bundle.java Tue Dec 06 14:25:52 2011 +0100 +++ b/cmdline/org/tmatesoft/hg/console/Bundle.java Tue Dec 06 19:47:01 2011 +0100 @@ -18,6 +18,7 @@ import java.io.File; import java.util.Collections; +import java.util.LinkedList; import org.tmatesoft.hg.core.HgCallbackTargetException; import org.tmatesoft.hg.core.HgException; @@ -26,6 +27,8 @@ import org.tmatesoft.hg.repo.HgChangelog; import org.tmatesoft.hg.repo.HgLookup; import org.tmatesoft.hg.repo.HgRepository; +import org.tmatesoft.hg.repo.HgBundle.GroupElement; +import org.tmatesoft.hg.repo.HgBundle.Inspector; import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; @@ -45,7 +48,7 @@ } File bundleFile = new File("/temp/hg/hg-bundle-cpython.tmp"); HgBundle hgBundle = new HgLookup().loadBundle(bundleFile); - hgBundle.inspectFiles(new HgBundle.Dump()); + hgBundle.inspectFiles(new Dump()); if (Boolean.parseBoolean("true")) { return; } @@ -100,4 +103,44 @@ */ + + public static void dump(HgBundle hgBundle) throws HgException { + Dump dump = new Dump(); + hgBundle.inspectAll(dump); + System.out.println("Total files:" + dump.names.size()); + for (String s : dump.names) { + System.out.println(s); + } + } + + public static class Dump implements Inspector { + public final LinkedList names = new LinkedList(); + + 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) { + System.out.printf(" %s\n", ge.toString()); + return true; + } + } } diff -r 91d75e1bac9f -r dfb8405d996f src/org/tmatesoft/hg/repo/HgBundle.java --- 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 names = new LinkedList(); - - 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); + } } } diff -r 91d75e1bac9f -r dfb8405d996f src/org/tmatesoft/hg/repo/HgLookup.java --- a/src/org/tmatesoft/hg/repo/HgLookup.java Tue Dec 06 14:25:52 2011 +0100 +++ b/src/org/tmatesoft/hg/repo/HgLookup.java Tue Dec 06 19:47:01 2011 +0100 @@ -83,7 +83,7 @@ if (location == null || !location.canRead()) { throw new HgInvalidFileException(String.format("Can't read file %s", location == null ? null : location.getPath()), null, location); } - return new HgBundle(new DataAccessProvider(getContext()), location).link(); + return new HgBundle(getContext(), new DataAccessProvider(getContext()), location).link(); } /** diff -r 91d75e1bac9f -r dfb8405d996f src/org/tmatesoft/hg/repo/HgRemoteRepository.java --- a/src/org/tmatesoft/hg/repo/HgRemoteRepository.java Tue Dec 06 14:25:52 2011 +0100 +++ b/src/org/tmatesoft/hg/repo/HgRemoteRepository.java Tue Dec 06 19:47:01 2011 +0100 @@ -110,7 +110,7 @@ ai = tempNode.get("xxx", null); tempNode.removeNode(); } catch (BackingStoreException ex) { - ex.printStackTrace(); + sessionContext.getLog().info(getClass(), ex, null); // IGNORE } authInfo = ai;