[EGIT PATCH 2/5] quickdiff - Don't add GitDocument as repository listener more than once

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Doing so was very costly and led to sessions being locked
for a long time while refreshing the reference document used
by Eclipse's quickdiff feature.

Signed-off-by: Robin Rosenberg <robin.rosenberg@xxxxxxxxxx>
---
 .../egit/ui/internal/decorators/GitDocument.java   |    4 +++-
 .../src/org/spearce/jgit/lib/Repository.java       |    2 ++
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java
index a9c0c7d..69e9295 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitDocument.java
@@ -35,6 +35,9 @@ static GitDocument create(final IResource resource) throws IOException {
 		if (RepositoryProvider.getProvider(resource.getProject()) instanceof GitProvider) {
 			ret = new GitDocument(resource);
 			ret.populate();
+			final Repository repository = ret.getRepository();
+			if (repository != null)
+				repository.addRepositoryChangedListener(ret);
 		}
 		return ret;
 	}
@@ -52,7 +55,6 @@ void populate() throws IOException {
 			return;
 		final String gitPath = mapping.getRepoRelativePath(resource);
 		final Repository repository = getRepository();
-		repository.addRepositoryChangedListener(this);
 		String baseline = GitQuickDiffProvider.baseline.get(repository);
 		if (baseline == null)
 			baseline = Constants.HEAD;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
index cfd92b8..0f396ed 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -1132,6 +1132,7 @@ public File getWorkDir() {
 	 * @param l
 	 */
 	public void addRepositoryChangedListener(final RepositoryListener l) {
+		assert !listeners.contains(l);
 		listeners.add(l);
 	}
 
@@ -1150,6 +1151,7 @@ public void removeRepositoryChangedListener(final RepositoryListener l) {
 	 * @param l
 	 */
 	public static void addAnyRepositoryChangedListener(final RepositoryListener l) {
+		assert !allListeners.contains(l);
 		allListeners.add(l);
 	}
 
-- 
1.6.2.1.345.g89fb

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux