[EGIT PATCH 3/9] Connect the history page to the refs update subscription mechanism
Now the history page can get updated automatically without polling.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../egit/ui/internal/history/GitHistoryPage.java | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 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 7e2f726..418f3b6 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
@@ -168,6 +168,9 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
/** Last HEAD */
private AnyObjectId currentHeadId;
+ /** We need to remember the current repository */
+ private Repository db;
+
/**
* Highlight flag that can be applied to commits to make them stand out.
* <p>
@@ -536,6 +539,9 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
revObjectSelectionProvider.setActiveRepository(null);
cancelRefreshJob();
+ if (db != null)
+ db.removeRepositoryChangedListener(this);
+
if (graph == null)
return false;
@@ -543,7 +549,8 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
if (in == null || in.length == 0)
return false;
- Repository db = null;
+ db = null;
+
final ArrayList<String> paths = new ArrayList<String>(in.length);
for (final IResource r : in) {
final RepositoryMapping map = RepositoryMapping.getMapping(r);
@@ -563,6 +570,8 @@ 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