[PATCH] Reset the graph plotter internals when HEAD has changed.
- From
Robin Rosenberg <robin.rosenberg.lists@dewire.com>
- Date
- Jun 9, 2008, 22:50 UTC
- Message-ID
- <1213051816-4046-2-git-send-email-robin.rosenberg.lists@dewire.com>
- In-Reply-To
- <1213051816-4046-1-git-send-email-robin.rosenberg.lists@dewire.com>
From: Robin Rosenberg <robin.rosenberg@dewire.com>
When we reset HEAD to an old revision it becomes more visible than when we add a new commit. This is an intermediate solution.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
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 27cda08..278e1e4 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 @@ -162,6 +162,9 @@ public class GitHistoryPage extends HistoryPage { /** Revision walker that allocated our graph's commit nodes. */ private SWTWalk currentWalk; + /** Last HEAD */ + private AnyObjectId currentHeadId; + /** * Highlight flag that can be applied to commits to make them stand out. * <p> @@ -521,8 +524,18 @@ public class GitHistoryPage extends HistoryPage { if (db == null) return false; + final AnyObjectId headId; + try { + headId = db.resolve("HEAD"); + } catch (IOException e) { + Activator.logError("Cannot parse HEAD in: " + + db.getDirectory().getAbsolutePath(), e); + return false; + } + if (currentWalk == null || currentWalk.getRepository() != db - || pathChange(pathFilters, paths)) { + || pathChange(pathFilters, paths) + || headId != null && !headId.equals(currentHeadId)) { currentWalk = new SWTWalk(db); currentWalk.sort(RevSort.COMMIT_TIME_DESC, true); currentWalk.sort(RevSort.BOUNDARY, true); @@ -531,13 +544,12 @@ public class GitHistoryPage extends HistoryPage { currentWalk.reset(); } + if (headId == null) + return false; try { - final AnyObjectId headId = db.resolve("HEAD"); - if (headId == null) - return false; currentWalk.markStart(currentWalk.parseCommit(headId)); } catch (IOException e) { - Activator.logError("Cannot parse HEAD in: " + Activator.logError("Cannot read HEAD commit " + headId + " in: " + db.getDirectory().getAbsolutePath(), e); return false; }
-- 1.5.5.1.178.g1f811