Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bugfix: fix duplicate commits in the history view

    1) stop a threading issue with old commits being added after the commits array was reset
    2) stop using --early-output (shouldn't there be an incremental output option???)
  • Loading branch information...
commit 1bad051779739d05ff330ef740bf246dc861a841 1 parent 25caa84
Nathan Kinsinger authored
7 PBGitHistoryGrapher.h
View
@@ -9,18 +9,23 @@
#import <Cocoa/Cocoa.h>
+#define kCurrentQueueKey @"kCurrentQueueKey"
+#define kNewCommitsKey @"kNewCommitsKey"
+
+
@class PBGitGrapher;
@interface PBGitHistoryGrapher : NSObject {
id delegate;
+ NSOperationQueue *currentQueue;
NSMutableSet *searchSHAs;
PBGitGrapher *grapher;
BOOL viewAllBranches;
}
-- (id) initWithBaseCommits:(NSSet *)commits viewAllBranches:(BOOL)viewAll delegate:(id)theDelegate;
+- (id) initWithBaseCommits:(NSSet *)commits viewAllBranches:(BOOL)viewAll queue:(NSOperationQueue *)queue delegate:(id)theDelegate;
- (void) graphCommits:(NSArray *)revList;
@end
14 PBGitHistoryGrapher.m
View
@@ -13,9 +13,10 @@
@implementation PBGitHistoryGrapher
-- (id) initWithBaseCommits:(NSSet *)commits viewAllBranches:(BOOL)viewAll delegate:(id)theDelegate
+- (id) initWithBaseCommits:(NSSet *)commits viewAllBranches:(BOOL)viewAll queue:(NSOperationQueue *)queue delegate:(id)theDelegate
{
delegate = theDelegate;
+ currentQueue = queue;
searchSHAs = [NSMutableSet setWithSet:commits];
grapher = [[PBGitGrapher alloc] initWithRepository:nil];
viewAllBranches = viewAll;
@@ -24,6 +25,13 @@ - (id) initWithBaseCommits:(NSSet *)commits viewAllBranches:(BOOL)viewAll delega
}
+- (void)sendCommits:(NSArray *)commits
+{
+ NSDictionary *commitData = [NSDictionary dictionaryWithObjectsAndKeys:currentQueue, kCurrentQueueKey, commits, kNewCommitsKey, nil];
+ [delegate performSelectorOnMainThread:@selector(updateCommitsFromGrapher:) withObject:commitData waitUntilDone:NO];
+}
+
+
- (void) graphCommits:(NSArray *)revList
{
if (!revList || [revList count] == 0)
@@ -43,12 +51,12 @@ - (void) graphCommits:(NSArray *)revList
}
}
if (++counter % 2000 == 0) {
- [delegate performSelectorOnMainThread:@selector(addCommitsFromArray:) withObject:[commits copy] waitUntilDone:NO];
+ [self sendCommits:commits];
commits = [NSMutableArray array];
}
}
- [delegate performSelectorOnMainThread:@selector(addCommitsFromArray:) withObject:commits waitUntilDone:YES];
+ [self sendCommits:commits];
[delegate performSelectorOnMainThread:@selector(finishedGraphing) withObject:nil waitUntilDone:NO];
}
2  PBGitHistoryList.h
View
@@ -40,7 +40,7 @@
- (void) forceUpdate;
- (void) updateHistory;
-- (void) addCommitsFromArray:(NSArray *)array;
+- (void) updateCommitsFromGrapher:(NSDictionary *)commitData;
@property (retain) PBGitRevList *projectRevList;
13 PBGitHistoryList.m
View
@@ -95,6 +95,7 @@ - (void) addCommitsFromArray:(NSArray *)array
{
if (!array || [array count] == 0)
return;
+
if (resetCommits) {
self.commits = [NSMutableArray array];
resetCommits = NO;
@@ -109,6 +110,14 @@ - (void) addCommitsFromArray:(NSArray *)array
}
+- (void) updateCommitsFromGrapher:(NSDictionary *)commitData
+{
+ if ([commitData objectForKey:kCurrentQueueKey] != graphQueue)
+ return;
+
+ [self addCommitsFromArray:[commitData objectForKey:kNewCommitsKey]];
+}
+
- (void) finishedGraphing
{
if (!currentRevList.isParsing && ([[graphQueue operations] count] == 0)) {
@@ -204,7 +213,7 @@ - (PBGitHistoryGrapher *) grapher
{
BOOL viewAllBranches = (repository.currentBranchFilter == kGitXAllBranchesFilter);
- return [[PBGitHistoryGrapher alloc] initWithBaseCommits:[self baseCommits] viewAllBranches:viewAllBranches delegate:self];
+ return [[PBGitHistoryGrapher alloc] initWithBaseCommits:[self baseCommits] viewAllBranches:viewAllBranches queue:graphQueue delegate:self];
}
@@ -301,6 +310,7 @@ - (void) updateProjectHistoryForRev:(PBGitRevSpecifier *)rev
lastBranchFilter = -1;
lastRemoteRef = nil;
lastSHA = nil;
+ self.commits = [NSMutableArray array];
[projectRevList loadRevisons];
return;
}
@@ -318,6 +328,7 @@ - (void) updateHistoryForRev:(PBGitRevSpecifier *)rev
lastBranchFilter = -1;
lastRemoteRef = nil;
lastSHA = nil;
+ self.commits = [NSMutableArray array];
[otherRevListParser loadRevisons];
}
26 PBGitRevList.mm
View
@@ -102,7 +102,7 @@ - (void) walkRevisionListWithSpecifier:(PBGitRevSpecifier*)rev
if (showSign)
formatString = [formatString stringByAppendingString:@"\01%m"];
- NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"log", @"-z", @"--early-output", @"--topo-order", @"--children", formatString, nil];
+ NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"log", @"-z", @"--topo-order", @"--children", formatString, nil];
if (!rev)
[arguments addObject:@"HEAD"];
@@ -124,30 +124,6 @@ - (void) walkRevisionListWithSpecifier:(PBGitRevSpecifier*)rev
if (!getline(stream, sha, '\1'))
break;
- // We reached the end of some temporary output. Show what we have
- // until now, and then start again. The sha of the next thing is still
- // in this buffer. So, we use a substring of current input.
- if (sha[1] == 'i') // Matches 'Final output'
- {
- num = 0;
- if ([currentThread isCancelled])
- break;
-
- NSDictionary *update = [NSDictionary dictionaryWithObjectsAndKeys:currentThread, kRevListThreadKey, revisions, kRevListRevisionsKey, nil];
- [self performSelectorOnMainThread:@selector(updateCommits:) withObject:update waitUntilDone:NO];
- revisions = [NSMutableArray array];
-
- if (isGraphing)
- g = [[PBGitGrapher alloc] initWithRepository:repository];
- revisions = [NSMutableArray array];
-
- // If the length is < 40, then there are no commits.. quit now
- if (sha.length() < 40)
- break;
-
- sha = sha.substr(sha.length() - 40, 40);
- }
-
// From now on, 1.2 seconds
string encoding_str;
getline(stream, encoding_str, '\1');
Please sign in to comment.
Something went wrong with that request. Please try again.