Signed-off-by: Robin Rosenberg <robin.rosenberg@xxxxxxxxxx> --- .../egit/ui/internal/decorators/GitDocument.java | 23 ++++++++++++++++++- .../internal/decorators/GitQuickDiffProvider.java | 8 +------ 2 files changed, 22 insertions(+), 9 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 69e9295..8c82a55 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@xxxxxxxxxx> + * Copyright (C) 2008, 2009 Robin Rosenberg <robin.rosenberg@xxxxxxxxxx> * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -8,6 +8,8 @@ package org.spearce.egit.ui.internal.decorators; import java.io.IOException; +import java.util.Map; +import java.util.WeakHashMap; import org.eclipse.core.resources.IEncodedStorage; import org.eclipse.core.resources.IProject; @@ -29,6 +31,7 @@ class GitDocument extends Document implements RepositoryListener { private final IResource resource; + static Map<GitDocument,Repository> doc2repo = new WeakHashMap<GitDocument, Repository>(); static GitDocument create(final IResource resource) throws IOException { GitDocument ret = null; @@ -44,7 +47,7 @@ static GitDocument create(final IResource resource) throws IOException { private GitDocument(IResource resource) { this.resource = resource; - GitQuickDiffProvider.doc2repo.put(this, getRepository()); + GitDocument.doc2repo.put(this, getRepository()); } void populate() throws IOException { @@ -95,6 +98,7 @@ void populate() throws IOException { } void dispose() { + doc2repo.remove(this); Repository repository = getRepository(); if (repository != null) repository.removeRepositoryChangedListener(this); @@ -119,4 +123,19 @@ private Repository getRepository() { return mapping.getRepository(); return null; } + + /** + * A change occurred to a repository. Update any GitDocument instances + * referring to such repositories. + * + * @param repository Repository which changed + * @throws IOException + */ + static void refreshRelevant(final Repository repository) throws IOException { + for (Map.Entry<GitDocument, Repository> i : doc2repo.entrySet()) { + if (i.getValue() == repository) { + i.getKey().populate(); + } + } + } } diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitQuickDiffProvider.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitQuickDiffProvider.java index 88f5ea0..6c71f3c 100644 --- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitQuickDiffProvider.java +++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitQuickDiffProvider.java @@ -37,7 +37,6 @@ private IResource resource; static Map<Repository,String> baseline = new WeakHashMap<Repository,String>(); - static Map<GitDocument,Repository> doc2repo = new WeakHashMap<GitDocument, Repository>(); /** * Create the GitQuickDiffProvider instance @@ -48,7 +47,6 @@ public GitQuickDiffProvider() { public void dispose() { Activator.trace("(GitQuickDiffProvider) dispose"); - doc2repo.remove(document); if (document != null) document.dispose(); } @@ -96,11 +94,7 @@ public void setId(String id) { */ public static void setBaselineReference(final Repository repository, final String baseline) throws IOException { GitQuickDiffProvider.baseline.put(repository, baseline); - for (Map.Entry<GitDocument, Repository> i : doc2repo.entrySet()) { - if (i.getValue() == repository) { - i.getKey().populate(); - } - } + GitDocument.refreshRelevant(repository); } } -- 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