# HG changeset patch # User Artem Tikhomirov # Date 1373635663 -7200 # Node ID 52af7f62e731a335fa88e79463faa6799fd41dcb # Parent b1a3a056d7e617368c7b64cd75b4c495bbb3c83c AIOOBE in BundleGenerator.ChunkGenerator.iterate when there are no outgoing changes on push diff -r b1a3a056d7e6 -r 52af7f62e731 src/org/tmatesoft/hg/core/HgPushCommand.java --- a/src/org/tmatesoft/hg/core/HgPushCommand.java Thu Jul 11 20:49:33 2013 +0200 +++ b/src/org/tmatesoft/hg/core/HgPushCommand.java Fri Jul 12 15:27:43 2013 +0200 @@ -87,15 +87,17 @@ } else { outgoing = new RevisionSet(l); } - // - // prepare bundle - BundleGenerator bg = new BundleGenerator(implRepo); - File bundleFile = bg.create(outgoing.asList()); - progress.worked(20); - HgBundle b = new HgLookup(repo.getSessionContext()).loadBundle(bundleFile); - // - // send changes - remoteRepo.unbundle(b, comparator.getRemoteHeads()); + if (!outgoing.isEmpty()) { + // + // prepare bundle + BundleGenerator bg = new BundleGenerator(implRepo); + File bundleFile = bg.create(outgoing.asList()); + progress.worked(20); + HgBundle b = new HgLookup(repo.getSessionContext()).loadBundle(bundleFile); + // + // send changes + remoteRepo.unbundle(b, comparator.getRemoteHeads()); + } // update phase information nevertheless progress.worked(20); // // update phase information diff -r b1a3a056d7e6 -r 52af7f62e731 src/org/tmatesoft/hg/internal/BundleGenerator.java --- a/src/org/tmatesoft/hg/internal/BundleGenerator.java Thu Jul 11 20:49:33 2013 +0200 +++ b/src/org/tmatesoft/hg/internal/BundleGenerator.java Fri Jul 12 15:27:43 2013 +0200 @@ -55,6 +55,9 @@ repo = hgRepo; } + /** + * @return never null. empty file if no changesets were written + */ public File create(List changesets) throws HgIOException, IOException { final HgChangelog clog = repo.getRepo().getChangelog(); final HgManifest manifest = repo.getRepo().getManifest(); @@ -85,6 +88,10 @@ manifestRevs.sort(true); // final File bundleFile = File.createTempFile("hg4j-", ".bundle"); + if (clogRevs.length == 0) { + // nothing to write + return bundleFile; + } final FileOutputStream osBundle = new FileOutputStream(bundleFile); final OutputStreamSerializer outRaw = new OutputStreamSerializer(osBundle); outRaw.write("HG10UN".getBytes(), 0, 6);