forked from pieter/gitx
-
Notifications
You must be signed in to change notification settings - Fork 2
/
PBGitHistoryGrapher.m
56 lines (43 loc) · 1.42 KB
/
PBGitHistoryGrapher.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// PBGitHistoryGrapher.m
// GitX
//
// Created by Nathan Kinsinger on 2/20/10.
// Copyright 2010 Nathan Kinsinger. All rights reserved.
//
#import "PBGitHistoryGrapher.h"
#import "PBGitGrapher.h"
@implementation PBGitHistoryGrapher
- (id) initWithBaseCommits:(NSSet *)commits viewAllBranches:(BOOL)viewAll delegate:(id)theDelegate
{
delegate = theDelegate;
searchSHAs = [NSMutableSet setWithSet:commits];
grapher = [[PBGitGrapher alloc] initWithRepository:nil];
viewAllBranches = viewAll;
return self;
}
- (void) graphCommits:(NSArray *)revList
{
if (!revList || [revList count] == 0)
return;
NSMutableArray *commits = [NSMutableArray array];
NSInteger counter = 0;
for (PBGitCommit *commit in revList) {
NSString *commitSHA = [commit realSha];
if (viewAllBranches || [searchSHAs containsObject:commitSHA]) {
[grapher decorateCommit:commit];
[commits addObject:commit];
if (!viewAllBranches) {
[searchSHAs removeObject:commitSHA];
[searchSHAs addObjectsFromArray:commit.parents];
}
}
if (++counter % 2000 == 0) {
[delegate performSelectorOnMainThread:@selector(addCommitsFromArray:) withObject:[commits copy] waitUntilDone:NO];
commits = [NSMutableArray array];
}
}
[delegate performSelectorOnMainThread:@selector(addCommitsFromArray:) withObject:commits waitUntilDone:YES];
[delegate performSelectorOnMainThread:@selector(finishedGraphing) withObject:nil waitUntilDone:NO];
}
@end