diff src/org/tmatesoft/hg/repo/HgBundle.java @ 186:44a34baabea0

Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 14 Apr 2011 00:47:04 +0200
parents f26ffe04ced0
children 9fb50c04f03c
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgBundle.java	Wed Apr 13 19:55:59 2011 +0200
+++ b/src/org/tmatesoft/hg/repo/HgBundle.java	Thu Apr 14 00:47:04 2011 +0200
@@ -75,6 +75,21 @@
 		return da;
 	}
 
+	private int uses = 0;
+	public HgBundle link() {
+		uses++;
+		return this;
+	}
+	public void unlink() {
+		uses--;
+		if (uses == 0 && bundleFile != null) {
+			bundleFile.deleteOnExit();
+		}
+	}
+	public boolean inUse() {
+		return uses > 0;
+	}
+
 	/**
 	 * Get changes recorded in the bundle that are missing from the supplied repository.
 	 * @param hgRepo repository that shall possess base revision for this bundle