diff src/org/tmatesoft/hg/internal/BundleGenerator.java @ 670:52af7f62e731

AIOOBE in BundleGenerator.ChunkGenerator.iterate when there are no outgoing changes on push
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 12 Jul 2013 15:27:43 +0200
parents d25f0324a27a
children
line wrap: on
line diff
--- 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 <code>null</code>. empty file if no changesets were written
+	 */
 	public File create(List<Nodeid> 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);