git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[EGIT PATCH 6/9] Change GitHistoryPage to listen on any repository.

From
Robin Rosenberg <robin.rosenberg@dewire.com>
Date
Jul 10, 2008, 22:40 UTC
Message-ID
<1215729651-26781-7-git-send-email-robin.rosenberg@dewire.com>
In-Reply-To
<1215729651-26781-6-git-send-email-robin.rosenberg@dewire.com>
This makes listening simpler.
---
 .../egit/ui/internal/history/GitHistoryPage.java   |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
index 418f3b6..e3ff8d4 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java
@@ -234,11 +234,16 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
 		attachContextMenu(commentViewer.getControl());
 		attachContextMenu(fileViewer.getControl());
 		layout();
+
+		Repository.addAnyRepositoryChangedListener(this);
 	}
 
 	private Runnable refschangedRunnable;
 
 	public void refsChanged(final RefsChangedEvent e) {
+		if (e.getRepository() != db)
+			return;
+
 		if (getControl().isDisposed())
 			return;
 
@@ -480,6 +485,7 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
 	}
 
 	public void dispose() {
+		Repository.removeAnyRepositoryChangedListener(this);
 		cancelRefreshJob();
 		if (popupMgr != null) {
 			for (final IContributionItem i : popupMgr.getItems()) {
@@ -539,9 +545,6 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
 			revObjectSelectionProvider.setActiveRepository(null);
 		cancelRefreshJob();
 
-		if (db != null)
-			db.removeRepositoryChangedListener(this);
-
 		if (graph == null)
 			return false;
 
@@ -570,8 +573,6 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
 		if (db == null)
 			return false;
 
-		db.addRepositoryChangedListener(this);
-
 		final AnyObjectId headId;
 		try {
 			headId = db.resolve("HEAD");
-- 
1.5.6.2.220.g44701
Previous: Robin RosenbergNext: Robin Rosenberg
Message 7 of 19 in “Repository change listeners”
  1. 0/9 Repository change listenersRobin Rosenberg, Jul 10, 2008
  2. 1/9 Create a listener structure for changes to refs and indexRobin Rosenberg, Jul 10, 2008
  3. 2/9 Cached modification times for symbolic refs tooRobin Rosenberg, Jul 10, 2008
  4. 3/9 Connect the history page to the refs update subscription mechanismRobin Rosenberg, Jul 10, 2008
  5. 4/9 Add a method to listen to changes in any repositoryRobin Rosenberg, Jul 10, 2008
  6. 5/9 Add a job to periodically scan for repository changesRobin Rosenberg, Jul 10, 2008
  7. 6/9 Change GitHistoryPage to listen on any repository.Robin Rosenberg, Jul 10, 2008
  8. 7/9 Add a job to refresh projects when the index changes.Robin Rosenberg, Jul 10, 2008
  9. 8/9 Make git dectected changes depend on the automatic refresh settingRobin Rosenberg, Jul 10, 2008
  10. 9/9 Attach the resource decorator to the repository change event mechanismRobin Rosenberg, Jul 10, 2008
  11. Shawn O. PearceJul 11, 2008
  12. 7/7 Add a job to refresh projects when the index changes.Robin Rosenberg, Jul 11, 2008
  13. Shawn O. PearceJul 11, 2008
  14. 4/4 Add a method to listen to changes in any repositoryRobin Rosenberg, Jul 11, 2008
  15. jgit (was: [PATCH 4/4] Add a method...)Andreas Ericsson, Jul 11, 2008
  16. Robin RosenbergJul 11, 2008
  17. Shawn O. PearceJul 11, 2008
  18. Create a listener structure for changes to refs and indexRobin Rosenberg, Jul 11, 2008
  19. Shawn O. PearceJul 11, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.