aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Kempin2013-03-19 02:28:36 (EDT)
committerMatthias Sohn2013-03-19 19:46:27 (EDT)
commitb37b1c91651f3d78f3ae72fc5450d327c46906d8 (patch)
tree726724752b99769e7dc4cd826a4fc97cc83114b2
parent509c0b58ee6e38277c360df49d3d6400a3018748 (diff)
downloadjgit-b37b1c91651f3d78f3ae72fc5450d327c46906d8.zip
jgit-b37b1c91651f3d78f3ae72fc5450d327c46906d8.tar.gz
jgit-b37b1c91651f3d78f3ae72fc5450d327c46906d8.tar.bz2
Allow to get repo statistics from GarbageCollectionCommand before gcrefs/changes/96/11296/6
When running the garbage collection for a repository it is often interesting to compare the repository statistics from before and after the garbage collection to understand the effect of the garbage collection. This is why it makes sense that the GarbageCollectionCommand provides a method to retrieve the repository statistics before running the garbage collection. So far without running the garbage collection the repository statistics can only be retrieved by using JGit internal classes. This is what EGit and Gerrit do at the moment, but it would be better to have an API for this. Change-Id: Id7e579157e9fbef5cfd1fc9f97ada45f0ca8c379 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties1
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java18
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java1
3 files changed, 20 insertions, 0 deletions
diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
index 677f735..b64617b 100644
--- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
+++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
@@ -124,6 +124,7 @@ couldNotCheckOutBecauseOfConflicts=Could not check out because of conflicts
couldNotDeleteLockFileShouldNotHappen=Could not delete lock file. Should not happen
couldNotDeleteTemporaryIndexFileShouldNotHappen=Could not delete temporary index file. Should not happen
couldNotGetAdvertisedRef=Could not get advertised Ref for branch {0}
+couldNotGetRepoStatistics=Could not get repository statistics
couldNotLockHEAD=Could not lock HEAD
couldNotReadIndexInOneGo=Could not read index in one go, only {0} out of {1} read
couldNotReadObjectWhileParsingCommit=Could not read an object while parsing commit {0}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java
index 7fda6cc..77b84d3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java
@@ -129,6 +129,24 @@ public class GarbageCollectCommand extends GitCommand<Properties> {
}
}
+ /**
+ * Computes and returns the repository statistics.
+ *
+ * @return the repository statistics
+ * @throws GitAPIException
+ * thrown if the repository statistics cannot be computed
+ * @since 3.0
+ */
+ public Properties getStatistics() throws GitAPIException {
+ try {
+ GC gc = new GC((FileRepository) repo);
+ return toProperties(gc.getStatistics());
+ } catch (IOException e) {
+ throw new JGitInternalException(
+ JGitText.get().couldNotGetRepoStatistics, e);
+ }
+ }
+
@SuppressWarnings("boxing")
private static Properties toProperties(RepoStatistics stats) {
Properties p = new Properties();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
index 7a1efe8..d7eb8af 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
@@ -186,6 +186,7 @@ public class JGitText extends TranslationBundle {
/***/ public String couldNotDeleteLockFileShouldNotHappen;
/***/ public String couldNotDeleteTemporaryIndexFileShouldNotHappen;
/***/ public String couldNotGetAdvertisedRef;
+ /***/ public String couldNotGetRepoStatistics;
/***/ public String couldNotLockHEAD;
/***/ public String couldNotReadIndexInOneGo;
/***/ public String couldNotReadObjectWhileParsingCommit;