Browse files

Select the commit as soon as it is available when updating the commit…

… list

This is important for large repositories as the commit will be selected when it is added instead of waiting for all the commits to be loaded.

Stop attempts to select the current commit again if it's already selected.

No longer need the updatedGraph property on the history list.
  • Loading branch information...
1 parent 69827e9 commit 81d7e78e7dd52eab4a1a6f26bff1e6edc0d7e396 @brotherbard committed Jul 3, 2010
Showing with 28 additions and 23 deletions.
  1. +28 −18 PBGitHistoryController.m
  2. +0 −2 PBGitHistoryList.h
  3. +0 −3 PBGitHistoryList.m
View
46 PBGitHistoryController.m
@@ -48,7 +48,6 @@ - (void)awakeFromNib
[treeController addObserver:self forKeyPath:@"selection" options:0 context:@"treeChange"];
[repository.revisionList addObserver:self forKeyPath:@"isUpdating" options:0 context:@"revisionListUpdating"];
- [repository.revisionList addObserver:self forKeyPath:@"updatedGraph" options:0 context:@"revisionListUpdatedGraph"];
[repository addObserver:self forKeyPath:@"currentBranch" options:0 context:@"branchChange"];
[repository addObserver:self forKeyPath:@"refs" options:0 context:@"updateRefs"];
@@ -83,26 +82,34 @@ - (void)awakeFromNib
[super awakeFromNib];
}
-- (void) updateKeys
+- (void)updateKeys
{
- // Remove any references in the QLPanel
- //[[QLPreviewPanel sharedPreviewPanel] setURLs:[NSArray array] currentIndex:0 preservingDisplayState:YES];
- // We have to do this manually, as NSTreeController leaks memory?
- //[treeController setSelectionIndexPaths:[NSArray array]];
+ PBGitCommit *lastObject = [[commitController selectedObjects] lastObject];
+ if (lastObject) {
+ if (![selectedCommit isEqual:lastObject]) {
+ selectedCommit = lastObject;
- selectedCommit = [[commitController selectedObjects] lastObject];
+ BOOL isOnHeadBranch = [selectedCommit isOnHeadBranch];
+ [mergeButton setEnabled:!isOnHeadBranch];
+ [cherryPickButton setEnabled:!isOnHeadBranch];
+ [rebaseButton setEnabled:!isOnHeadBranch];
+ }
+ }
+ else {
+ [mergeButton setEnabled:NO];
+ [cherryPickButton setEnabled:NO];
+ [rebaseButton setEnabled:NO];
+ }
if (self.selectedCommitDetailsIndex == kHistoryTreeViewIndex) {
self.gitTree = selectedCommit.tree;
[self restoreFileBrowserSelection];
}
- else // kHistoryDetailViewIndex
+ else {
+ // kHistoryDetailViewIndex
+ if (![self.webCommit isEqual:selectedCommit])
self.webCommit = selectedCommit;
-
- BOOL isOnHeadBranch = [selectedCommit isOnHeadBranch];
- [mergeButton setEnabled:!isOnHeadBranch];
- [cherryPickButton setEnabled:!isOnHeadBranch];
- [rebaseButton setEnabled:!isOnHeadBranch];
+ }
}
- (void) updateBranchFilterMatrix
@@ -141,6 +148,11 @@ - (PBGitCommit *) firstCommit
return nil;
}
+- (BOOL)isCommitSelected
+{
+ return [selectedCommit isEqual:[[commitController selectedObjects] lastObject]];
+}
+
- (void) setSelectedCommitDetailsIndex:(int)detailsIndex
{
if (selectedCommitDetailsIndex == detailsIndex)
@@ -230,10 +242,7 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
if([(NSString *)context isEqualToString:@"updateCommitCount"] || [(NSString *)context isEqualToString:@"revisionListUpdating"]) {
[self updateStatus];
- return;
- }
- if([(NSString *)context isEqualToString:@"revisionListUpdatedGraph"]) {
if ([repository.currentBranch isSimpleRef])
[self selectCommit:[repository shaForRef:[repository.currentBranch ref]]];
else
@@ -399,7 +408,7 @@ - (NSArray *) selectedObjectsForSHA:(PBGitSHA *)commitSHA
- (void)selectCommit:(PBGitSHA *)commitSHA
{
- if (!forceSelectionUpdate && [[selectedCommit sha] isEqual:commitSHA])
+ if (!forceSelectionUpdate && [[[[commitController selectedObjects] lastObject] sha] isEqual:commitSHA])
return;
NSInteger oldIndex = [[commitController selectionIndexes] firstIndex];
@@ -409,6 +418,8 @@ - (void)selectCommit:(PBGitSHA *)commitSHA
if (repository.currentBranchFilter != kGitXSelectedBranchFilter)
[self scrollSelectionToTopOfViewFrom:oldIndex];
+
+ forceSelectionUpdate = NO;
}
- (BOOL) hasNonlinearPath
@@ -428,7 +439,6 @@ - (void)closeView
[treeController removeObserver:self forKeyPath:@"selection"];
[repository.revisionList removeObserver:self forKeyPath:@"isUpdating"];
- [repository.revisionList removeObserver:self forKeyPath:@"updatedGraph"];
[repository removeObserver:self forKeyPath:@"currentBranch"];
[repository removeObserver:self forKeyPath:@"refs"];
}
View
2 PBGitHistoryList.h
@@ -28,7 +28,6 @@
PBGitRef *lastRemoteRef;
BOOL resetCommits;
BOOL shouldReloadProjectHistory;
- NSDate *updatedGraph;
PBGitHistoryGrapher *grapher;
NSOperationQueue *graphQueue;
@@ -49,6 +48,5 @@
@property (retain) NSMutableArray *commits;
@property (readonly) NSArray *projectCommits;
@property (assign) BOOL isUpdating;
-@property (retain) NSDate *updatedGraph;
@end
View
3 PBGitHistoryList.m
@@ -36,7 +36,6 @@ @implementation PBGitHistoryList
@synthesize projectRevList;
@synthesize commits;
@synthesize isUpdating;
-@synthesize updatedGraph;
@dynamic projectCommits;
@@ -137,7 +136,6 @@ - (void) finishedGraphing
{
if (!currentRevList.isParsing && ([[graphQueue operations] count] == 0)) {
self.isUpdating = NO;
- [self performSelector:@selector(setUpdatedGraph:) withObject:[NSDate date] afterDelay:0];
}
}
@@ -272,7 +270,6 @@ - (BOOL) selectedBranchNeedsNewGraph:(PBGitRevSpecifier *)rev
lastRemoteRef = [[rev ref] remoteRef];
lastSHA = nil;
self.isUpdating = NO;
- self.updatedGraph = [NSDate date];
return NO;
}

0 comments on commit 81d7e78

Please sign in to comment.