]> source.dussan.org Git - jgit.git/commitdiff
Allow to get repo statistics from GarbageCollectionCommand before gc 96/11296/6
authorEdwin Kempin <edwin.kempin@sap.com>
Tue, 19 Mar 2013 06:28:36 +0000 (07:28 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 19 Mar 2013 23:46:27 +0000 (00:46 +0100)
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>
org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java

index 677f735cec3386c34ff71f775314c5334c8be05f..b64617b39bf151aa68bbf71adcbcc0d20781623b 100644 (file)
@@ -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}
index 7fda6cc01e7cd1fb72f05e9e5ca866541a5d0f7d..77b84d3a36140a889a1be2648f3cc16b22421e14 100644 (file)
@@ -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();
index 7a1efe89df8c1e581bbffef505f3d4466459ee03..d7eb8af958864437ff47406e8d50ecec9a11abb6 100644 (file)
@@ -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;