mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Merge branch 'insta-decorate'
* insta-decorate: Add framework to support removing refs Show refs in HTML view Allow copy and pasting of web source by pressing 'c' Refactor cellInfo structure Only decorate if we need to Multithread test Add objective c diff header Conflicts: GitX.xcodeproj/project.pbxproj
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
*.m diff=objc
|
||||
*.mm diff=objc
|
||||
@@ -8,7 +8,7 @@
|
||||
<string key="IBDocument.HIToolboxVersion">352.00</string>
|
||||
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<integer value="11"/>
|
||||
<integer value="30"/>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
@@ -1832,22 +1832,6 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
</object>
|
||||
<int key="connectionID">84</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">value: arrangedObjects.subject</string>
|
||||
<reference key="source" ref="855592717"/>
|
||||
<reference key="destination" ref="340269780"/>
|
||||
<object class="NSNibBindingConnector" key="connector">
|
||||
<reference key="NSSource" ref="855592717"/>
|
||||
<reference key="NSDestination" ref="340269780"/>
|
||||
<string key="NSLabel">value: arrangedObjects.subject</string>
|
||||
<string key="NSBinding">value</string>
|
||||
<string key="NSKeyPath">arrangedObjects.subject</string>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">85</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">value: arrangedObjects.author</string>
|
||||
@@ -2243,6 +2227,34 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
</object>
|
||||
<int key="connectionID">233</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">value: arrangedObjects</string>
|
||||
<reference key="source" ref="855592717"/>
|
||||
<reference key="destination" ref="340269780"/>
|
||||
<object class="NSNibBindingConnector" key="connector">
|
||||
<reference key="NSSource" ref="855592717"/>
|
||||
<reference key="NSDestination" ref="340269780"/>
|
||||
<string key="NSLabel">value: arrangedObjects</string>
|
||||
<string key="NSBinding">value</string>
|
||||
<string key="NSKeyPath">arrangedObjects</string>
|
||||
<object class="NSDictionary" key="NSOptions">
|
||||
<string key="NS.key.0">NSConditionallySetsEditable</string>
|
||||
<reference key="NS.object.0" ref="9"/>
|
||||
</object>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">243</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">UIDelegate</string>
|
||||
<reference key="source" ref="667595857"/>
|
||||
<reference key="destination" ref="422872293"/>
|
||||
</object>
|
||||
<int key="connectionID">244</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
@@ -3011,7 +3023,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">233</int>
|
||||
<int key="maxID">244</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
@@ -3095,7 +3107,11 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ</bytes>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">PBGitRevisionCell</string>
|
||||
<string key="superclassName">NSTextFieldCell</string>
|
||||
<string key="superclassName">NSActionCell</string>
|
||||
<object class="NSMutableDictionary" key="outlets">
|
||||
<string key="NS.key.0">objectValue</string>
|
||||
<string key="NS.object.0">id</string>
|
||||
</object>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">PBGitRevisionCell.h</string>
|
||||
|
||||
@@ -276,8 +276,6 @@
|
||||
F5C007730E731B48007B84B2 /* PBGitRef.h */,
|
||||
F5C007740E731B48007B84B2 /* PBGitRef.m */,
|
||||
F5C6F6750E65FE2B00478D97 /* Graphing */,
|
||||
F5FF4E780E082E440006317A /* PBGitGrapher.h */,
|
||||
F5FF4E790E082E440006317A /* PBGitGrapher.m */,
|
||||
F5945E150E02B0C200706420 /* PBGitRepository.h */,
|
||||
F5945E160E02B0C200706420 /* PBGitRepository.m */,
|
||||
F56524EE0E02D45200F03B52 /* PBGitCommit.h */,
|
||||
@@ -344,6 +342,8 @@
|
||||
F5C6F6750E65FE2B00478D97 /* Graphing */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F5FF4E780E082E440006317A /* PBGitGrapher.h */,
|
||||
F5FF4E790E082E440006317A /* PBGitGrapher.m */,
|
||||
F50FE0E10E07BE9600854FCD /* PBGitRevisionCell.h */,
|
||||
F50FE0E20E07BE9600854FCD /* PBGitRevisionCell.m */,
|
||||
F56CC7270E65E0AD004307B4 /* PBGitGraphLine.h */,
|
||||
|
||||
@@ -161,18 +161,4 @@
|
||||
int index = [[commitController selectionIndexes] firstIndex];
|
||||
[commitList scrollRowToVisible: index];
|
||||
}
|
||||
|
||||
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
|
||||
{
|
||||
if (![[aTableColumn identifier] isEqualToString:@"subject"])
|
||||
return;
|
||||
|
||||
PBGitRevisionCell* cell = aCell;
|
||||
if (self.repository.revisionList.grapher &&
|
||||
![commitController filterPredicate] &&
|
||||
[[commitController sortDescriptors] count] == 0) {
|
||||
PBGitGrapher* g = self.repository.revisionList.grapher;
|
||||
[cell setCellInfo: [g cellInfoForRow:rowIndex]];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
+4
-1
@@ -16,8 +16,10 @@
|
||||
NSString* author;
|
||||
NSString* details;
|
||||
NSArray* parents;
|
||||
NSArray* refs;
|
||||
NSDate* date;
|
||||
char sign;
|
||||
id lineInfo;
|
||||
PBGitRepository* repository;
|
||||
}
|
||||
|
||||
@@ -26,7 +28,7 @@
|
||||
@property (copy) NSString* sha;
|
||||
@property (copy) NSString* subject;
|
||||
@property (copy) NSString* author;
|
||||
@property (retain) NSArray* parents;
|
||||
@property (retain) NSArray* parents, *refs;
|
||||
@property (copy) NSDate* date;
|
||||
@property (readonly) NSString* dateString;
|
||||
@property (assign) char sign;
|
||||
@@ -35,4 +37,5 @@
|
||||
@property (readonly) PBGitTree* tree;
|
||||
@property (readonly) NSArray* treeContents;
|
||||
@property (retain) PBGitRepository* repository;
|
||||
@property (retain) id lineInfo;
|
||||
@end
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
|
||||
@implementation PBGitCommit
|
||||
|
||||
@synthesize sha, repository, subject, author, date, parents, sign;
|
||||
@synthesize sha, repository, subject, author, date, parents, sign, lineInfo, refs;
|
||||
|
||||
|
||||
- (NSString *) dateString
|
||||
|
||||
+4
-3
@@ -20,11 +20,12 @@ struct PBGitGraphColumn {
|
||||
#define PBGitMaxColumns 100
|
||||
|
||||
@interface PBGitGrapher : NSObject {
|
||||
NSMutableArray* cellsInfo;
|
||||
PBGraphCellInfo* previous;
|
||||
NSMutableArray* previousLanes;
|
||||
NSDictionary* refs;
|
||||
PBGitRepository* repository;
|
||||
}
|
||||
|
||||
- (id) initWithRepository: (PBGitRepository*) repo;
|
||||
- (void) parseCommits: (NSArray *) array;
|
||||
- (PBGraphCellInfo*) cellInfoForRow: (int) row;
|
||||
- (void) decorateCommit: (PBGitCommit *) commit;
|
||||
@end
|
||||
|
||||
+99
-121
@@ -14,149 +14,127 @@
|
||||
|
||||
- (id) initWithRepository: (PBGitRepository*) repo
|
||||
{
|
||||
refs = repo.refs;
|
||||
repository = repo;
|
||||
previousLanes = [NSMutableArray array];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) parseCommits: (NSArray *) commits
|
||||
- (void) decorateCommit: (PBGitCommit *) commit
|
||||
{
|
||||
cellsInfo = [NSMutableArray arrayWithCapacity: [commits count]];
|
||||
int row = 0;
|
||||
int i = 0, newPos = -1;
|
||||
NSMutableArray* currentLanes = [NSMutableArray array];
|
||||
NSMutableArray* lines = [NSMutableArray array];
|
||||
PBGitLane* currentLane = NULL;
|
||||
BOOL didFirst = NO;
|
||||
|
||||
NSDictionary* refs = nil;
|
||||
if (repository)
|
||||
refs = repository.refs;
|
||||
// First, iterate over earlier columns and pass through any that don't want this commit
|
||||
if (previous != nil) {
|
||||
|
||||
PBGraphCellInfo* previous;
|
||||
NSMutableArray* previousLanes = [NSMutableArray array];
|
||||
|
||||
for (PBGitCommit* commit in commits) {
|
||||
int i = 0, newPos = -1;
|
||||
NSMutableArray* currentLanes = [NSMutableArray array];
|
||||
NSMutableArray* lines = [NSMutableArray array];
|
||||
PBGitLane* currentLane = NULL;
|
||||
BOOL didFirst = NO;
|
||||
|
||||
// First, iterate over earlier columns and pass through any that don't want this commit
|
||||
if (previous != nil) {
|
||||
|
||||
// We can't count until numColumns here, as it's only used for the width of the cell.
|
||||
for (PBGitLane* lane in previousLanes) {
|
||||
i++;
|
||||
// This is our commit! We should do a "merge": move the line from
|
||||
// our upperMapping to their lowerMapping
|
||||
if ([lane isCommit:commit.sha]) {
|
||||
if (!didFirst) {
|
||||
didFirst = YES;
|
||||
currentLane = lane;
|
||||
[currentLanes addObject: lane];
|
||||
newPos = [currentLanes count];
|
||||
}
|
||||
[lines addObject: [PBGitGraphLine upperLineFrom: i to: newPos color: [lane index]]];
|
||||
// We can't count until numColumns here, as it's only used for the width of the cell.
|
||||
for (PBGitLane* lane in previousLanes) {
|
||||
i++;
|
||||
// This is our commit! We should do a "merge": move the line from
|
||||
// our upperMapping to their lowerMapping
|
||||
if ([lane isCommit:commit.sha]) {
|
||||
if (!didFirst) {
|
||||
didFirst = YES;
|
||||
currentLane = lane;
|
||||
[currentLanes addObject: lane];
|
||||
newPos = [currentLanes count];
|
||||
}
|
||||
else {
|
||||
// We are not this commit.
|
||||
// Try to find an earlier column for this commit.
|
||||
int j = 0;
|
||||
BOOL found = NO;
|
||||
for (PBGitLane* column in currentLanes) {
|
||||
j++;
|
||||
// ??? what is this?
|
||||
[lines addObject: [PBGitGraphLine upperLineFrom: i to: newPos color: [lane index]]];
|
||||
}
|
||||
else {
|
||||
// We are not this commit.
|
||||
// Try to find an earlier column for this commit.
|
||||
int j = 0;
|
||||
BOOL found = NO;
|
||||
for (PBGitLane* column in currentLanes) {
|
||||
j++;
|
||||
// ??? what is this?
|
||||
// if (j == newPos)
|
||||
// continue;
|
||||
if ([lane isCommit: commit.sha]) {
|
||||
// We already have a column for this commit. use it instead
|
||||
[lines addObject: [PBGitGraphLine upperLineFrom: i to: j color: [lane index]]];
|
||||
found = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// We need a new column for this.
|
||||
if (!found) {
|
||||
|
||||
// This was used as a hack to stop large lanes from drawing
|
||||
//if (previous->columns[i].color == 10)
|
||||
// continue;
|
||||
|
||||
[currentLanes addObject: lane];
|
||||
[lines addObject: [PBGitGraphLine upperLineFrom: i to: [currentLanes count] color: [lane index]]];
|
||||
[lines addObject: [PBGitGraphLine lowerLineFrom: [currentLanes count] to: [currentLanes count] color: [lane index]]];
|
||||
if ([lane isCommit: commit.sha]) {
|
||||
// We already have a column for this commit. use it instead
|
||||
[lines addObject: [PBGitGraphLine upperLineFrom: i to: j color: [lane index]]];
|
||||
found = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// For existing columns, we always just continue straight down
|
||||
// ^^ I don't know what that means anymore :(
|
||||
[lines addObject:[PBGitGraphLine lowerLineFrom:newPos to:newPos color: [currentLane index]]];
|
||||
}
|
||||
}
|
||||
|
||||
//Add your own parents
|
||||
|
||||
// If we already did the first parent, don't do so again
|
||||
if (!didFirst) {
|
||||
PBGitLane* newLane = [[PBGitLane alloc] initWithCommit:[commit.parents objectAtIndex:0]];
|
||||
[currentLanes addObject: newLane];
|
||||
newPos = [currentLanes count];
|
||||
[lines addObject:[PBGitGraphLine lowerLineFrom: newPos to: newPos color: [newLane index]]];
|
||||
}
|
||||
|
||||
// Add all other parents
|
||||
|
||||
// If we add at least one parent, we can go back a single column.
|
||||
// This boolean will tell us if that happened
|
||||
BOOL addedParent = NO;
|
||||
|
||||
for (NSString* parent in [commit.parents subarrayWithRange:NSMakeRange(1, [commit.parents count] -1)]) {
|
||||
int i = 0;
|
||||
BOOL was_displayed = NO;
|
||||
for (PBGitLane* column in currentLanes) {
|
||||
i++;
|
||||
if ([column isCommit: parent]) {
|
||||
[lines addObject:[PBGitGraphLine lowerLineFrom: i to: newPos color: [column index]]];
|
||||
was_displayed = YES;
|
||||
break;
|
||||
// We need a new column for this.
|
||||
if (!found) {
|
||||
|
||||
[currentLanes addObject: lane];
|
||||
[lines addObject: [PBGitGraphLine upperLineFrom: i to: [currentLanes count] color: [lane index]]];
|
||||
[lines addObject: [PBGitGraphLine lowerLineFrom: [currentLanes count] to: [currentLanes count] color: [lane index]]];
|
||||
}
|
||||
}
|
||||
if (was_displayed)
|
||||
continue;
|
||||
|
||||
// Really add this parent
|
||||
addedParent = YES;
|
||||
PBGitLane* newLane = [[PBGitLane alloc] initWithCommit:parent];
|
||||
[currentLanes addObject: newLane];
|
||||
[lines addObject:[PBGitGraphLine lowerLineFrom: [currentLanes count] to: newPos color: [newLane index]]];
|
||||
// For existing columns, we always just continue straight down
|
||||
// ^^ I don't know what that means anymore :(
|
||||
[lines addObject:[PBGitGraphLine lowerLineFrom:newPos to:newPos color: [currentLane index]]];
|
||||
}
|
||||
|
||||
++row;
|
||||
previous = [[PBGraphCellInfo alloc] initWithPosition:newPos andLines:lines];
|
||||
previous.sign = commit.sign;
|
||||
if (refs && [refs objectForKey:commit.sha])
|
||||
previous.refs = [refs objectForKey:commit.sha];
|
||||
|
||||
// If a parent was added, we have room to not indent.
|
||||
if (addedParent)
|
||||
previous.numColumns = [currentLanes count] - 1;
|
||||
else
|
||||
previous.numColumns = [currentLanes count];
|
||||
|
||||
if ([commit.parents count] > 0 && ![[commit.parents objectAtIndex:0] isEqualToString:@""])
|
||||
currentLane.sha = [commit.parents objectAtIndex:0];
|
||||
else
|
||||
[currentLanes removeObject:currentLane];
|
||||
|
||||
previousLanes = currentLanes;
|
||||
[cellsInfo addObject: previous];
|
||||
}
|
||||
}
|
||||
|
||||
- (PBGraphCellInfo*) cellInfoForRow: (int) row
|
||||
{
|
||||
return [cellsInfo objectAtIndex: row];
|
||||
//Add your own parents
|
||||
|
||||
// If we already did the first parent, don't do so again
|
||||
if (!didFirst) {
|
||||
PBGitLane* newLane = [[PBGitLane alloc] initWithCommit:[commit.parents objectAtIndex:0]];
|
||||
[currentLanes addObject: newLane];
|
||||
newPos = [currentLanes count];
|
||||
[lines addObject:[PBGitGraphLine lowerLineFrom: newPos to: newPos color: [newLane index]]];
|
||||
}
|
||||
|
||||
// Add all other parents
|
||||
|
||||
// If we add at least one parent, we can go back a single column.
|
||||
// This boolean will tell us if that happened
|
||||
BOOL addedParent = NO;
|
||||
|
||||
for (NSString* parent in [commit.parents subarrayWithRange:NSMakeRange(1, [commit.parents count] -1)]) {
|
||||
int i = 0;
|
||||
BOOL was_displayed = NO;
|
||||
for (PBGitLane* column in currentLanes) {
|
||||
i++;
|
||||
if ([column isCommit: parent]) {
|
||||
[lines addObject:[PBGitGraphLine lowerLineFrom: i to: newPos color: [column index]]];
|
||||
was_displayed = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (was_displayed)
|
||||
continue;
|
||||
|
||||
// Really add this parent
|
||||
addedParent = YES;
|
||||
PBGitLane* newLane = [[PBGitLane alloc] initWithCommit:parent];
|
||||
[currentLanes addObject: newLane];
|
||||
[lines addObject:[PBGitGraphLine lowerLineFrom: [currentLanes count] to: newPos color: [newLane index]]];
|
||||
}
|
||||
|
||||
previous = [[PBGraphCellInfo alloc] initWithPosition:newPos andLines:lines];
|
||||
previous.sign = commit.sign;
|
||||
|
||||
// If a parent was added, we have room to not indent.
|
||||
if (addedParent)
|
||||
previous.numColumns = [currentLanes count] - 1;
|
||||
else
|
||||
previous.numColumns = [currentLanes count];
|
||||
|
||||
if ([commit.parents count] > 0 && ![[commit.parents objectAtIndex:0] isEqualToString:@""])
|
||||
currentLane.sha = [commit.parents objectAtIndex:0];
|
||||
else
|
||||
[currentLanes removeObject:currentLane];
|
||||
|
||||
previousLanes = currentLanes;
|
||||
commit.lineInfo = previous;
|
||||
}
|
||||
|
||||
- (void) finalize
|
||||
{
|
||||
free(cellsInfo);
|
||||
[super finalize];
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -41,4 +41,13 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (BOOL)isKeyExcludedFromWebScript:(const char *)name {
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
@interface PBGitRevList : NSObject {
|
||||
NSArray* commits;
|
||||
id grapher;
|
||||
id repository;
|
||||
NSString* lastSha;
|
||||
}
|
||||
@@ -21,6 +20,5 @@
|
||||
- (void) reload;
|
||||
|
||||
@property(retain) NSArray* commits;
|
||||
@property(retain) id grapher;
|
||||
|
||||
@end
|
||||
|
||||
+60
-19
@@ -14,7 +14,7 @@
|
||||
|
||||
@implementation PBGitRevList
|
||||
|
||||
@synthesize commits, grapher;
|
||||
@synthesize commits;
|
||||
- initWithRepository: (id) repo
|
||||
{
|
||||
repository = repo;
|
||||
@@ -65,12 +65,16 @@
|
||||
[self readCommitsForce: NO];
|
||||
}
|
||||
|
||||
struct decorateParameters {
|
||||
NSMutableArray* revisions;
|
||||
PBGitRevSpecifier* rev;
|
||||
};
|
||||
|
||||
- (void) walkRevisionListWithSpecifier: (PBGitRevSpecifier*) rev
|
||||
{
|
||||
|
||||
NSMutableArray* newArray = [NSMutableArray array];
|
||||
NSMutableArray* arguments;
|
||||
NSDate* start = [NSDate date];
|
||||
BOOL showSign = [rev hasLeftRight];
|
||||
|
||||
if (showSign)
|
||||
@@ -85,6 +89,11 @@
|
||||
|
||||
NSFileHandle* handle = [repository handleForArguments: arguments];
|
||||
|
||||
// We decorate the commits in a separate thread.
|
||||
struct decorateParameters params = { newArray, rev };
|
||||
NSThread * decorationThread = [[NSThread alloc] initWithTarget: self selector: @selector(decorateRevisions:) object:¶ms];
|
||||
[decorationThread start];
|
||||
|
||||
int fd = [handle fileDescriptor];
|
||||
FILE* f = fdopen(fd, "r");
|
||||
int BUFFERSIZE = 2048;
|
||||
@@ -92,7 +101,7 @@
|
||||
buffer[BUFFERSIZE - 2] = 0;
|
||||
|
||||
char* l;
|
||||
int num = 0;
|
||||
|
||||
NSMutableString* currentLine = [NSMutableString string];
|
||||
while (l = fgets(buffer, BUFFERSIZE, f)) {
|
||||
NSString *s = [NSString stringWithCString:(const char *)l encoding:NSUTF8StringEncoding];
|
||||
@@ -122,28 +131,60 @@
|
||||
if (showSign)
|
||||
newCommit.sign = [[components objectAtIndex:5] characterAtIndex:0];
|
||||
|
||||
[newArray addObject: newCommit];
|
||||
num++;
|
||||
if (num % 10000 == 0)
|
||||
[self performSelectorOnMainThread:@selector(setCommits:) withObject:newArray waitUntilDone:NO];
|
||||
@synchronized(newArray) {
|
||||
[newArray addObject: newCommit];
|
||||
}
|
||||
currentLine = [NSMutableString string];
|
||||
}
|
||||
|
||||
[self performSelectorOnMainThread:@selector(setCommits:) withObject:newArray waitUntilDone:YES];
|
||||
[decorationThread cancel];
|
||||
|
||||
if (![rev hasPathLimiter]) {
|
||||
PBGitGrapher* g = [[PBGitGrapher alloc] initWithRepository: repository];
|
||||
[g parseCommits: self.commits];
|
||||
[self performSelectorOnMainThread:@selector(setGrapher:) withObject:g waitUntilDone:YES];
|
||||
[self performSelectorOnMainThread:@selector(setCommits:) withObject:newArray waitUntilDone:YES];
|
||||
}
|
||||
else
|
||||
grapher = nil;
|
||||
|
||||
NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:start];
|
||||
NSLog(@"Loaded %i commits in %f seconds", num, duration);
|
||||
[NSThread exit];
|
||||
}
|
||||
|
||||
// We're not supposed to pass on structs, only objects, but this is much easier
|
||||
- (void) decorateRevisions: (struct decorateParameters*) params
|
||||
{
|
||||
NSMutableArray* revisions = params->revisions;
|
||||
PBGitRevSpecifier* rev = params->rev;
|
||||
NSDictionary* refs = [repository refs];
|
||||
|
||||
BOOL decorateCommits = ![rev hasPathLimiter];
|
||||
NSDate* start = [NSDate date];
|
||||
|
||||
NSMutableArray* allRevisions = [NSMutableArray arrayWithCapacity:1000];
|
||||
int num = 0;
|
||||
|
||||
PBGitGrapher* g = [[PBGitGrapher alloc] initWithRepository: repository];
|
||||
|
||||
while (!([[NSThread currentThread] isCancelled] && [revisions count] == 0)) {
|
||||
if ([revisions count] == 0)
|
||||
usleep(5000);
|
||||
|
||||
NSArray* currentRevisions;
|
||||
@synchronized(revisions) {
|
||||
currentRevisions = [revisions copy];
|
||||
[revisions removeAllObjects];
|
||||
}
|
||||
for (PBGitCommit* commit in currentRevisions) {
|
||||
num++;
|
||||
if (decorateCommits)
|
||||
[g decorateCommit: commit];
|
||||
|
||||
if (refs && [refs objectForKey:commit.sha])
|
||||
commit.refs = [refs objectForKey:commit.sha];
|
||||
|
||||
[allRevisions addObject: commit];
|
||||
if (num % 1000 == 0 || num == 10)
|
||||
[self performSelectorOnMainThread:@selector(setCommits:) withObject:allRevisions waitUntilDone:NO];
|
||||
}
|
||||
}
|
||||
|
||||
[self performSelectorOnMainThread:@selector(setCommits:) withObject:allRevisions waitUntilDone:YES];
|
||||
NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:start];
|
||||
NSLog(@"Loaded %i commits in %f seconds", num, duration);
|
||||
|
||||
[NSThread exit];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+6
-4
@@ -8,11 +8,13 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "PBGitGrapher.h"
|
||||
#import "PBGraphCellInfo.h"
|
||||
|
||||
@interface PBGitRevisionCell : NSTextFieldCell {
|
||||
PBGraphCellInfo* cellInfo;
|
||||
BOOL isReady;
|
||||
@interface PBGitRevisionCell : NSActionCell {
|
||||
id objectValue;
|
||||
PBGraphCellInfo* cellInfo;
|
||||
NSTextFieldCell* textCell;
|
||||
}
|
||||
|
||||
@property(assign) PBGraphCellInfo* cellInfo;
|
||||
@property(retain) PBGitCommit* objectValue;
|
||||
@end
|
||||
|
||||
+35
-29
@@ -58,19 +58,11 @@
|
||||
|
||||
@implementation PBGitRevisionCell
|
||||
|
||||
@synthesize cellInfo;
|
||||
-(void) setCellInfo: (PBGraphCellInfo*) info
|
||||
{
|
||||
isReady = YES;
|
||||
cellInfo = info;
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (id) coder
|
||||
{
|
||||
self = [super initWithCoder:coder];
|
||||
if (self != nil) {
|
||||
isReady = NO;
|
||||
}
|
||||
textCell = [[NSTextFieldCell alloc] initWithCoder:coder];
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -196,13 +188,14 @@
|
||||
static const float ref_padding = 10.0f;
|
||||
static const float ref_spacing = 2.0f;
|
||||
|
||||
NSArray* refs = [self.objectValue refs];
|
||||
NSRect refRect = (NSRect){rect->origin, rect->size};
|
||||
|
||||
[[NSColor blackColor] setStroke];
|
||||
|
||||
int index;
|
||||
for (index = 0; index < [cellInfo.refs count]; ++index) {
|
||||
PBGitRef* ref = [cellInfo.refs objectAtIndex:index];
|
||||
for (index = 0; index < [refs count]; ++index) {
|
||||
PBGitRef* ref = [refs objectAtIndex:index];
|
||||
|
||||
NSMutableDictionary* attributes = [self attributesForRefLabelSelected:[self isHighlighted]];
|
||||
NSSize refSize = [[ref shortName] sizeWithAttributes:attributes];
|
||||
@@ -231,31 +224,44 @@
|
||||
|
||||
- (void) drawWithFrame: (NSRect) rect inView:(NSView *)view
|
||||
{
|
||||
if (!isReady)
|
||||
return [super drawWithFrame:rect inView:view];
|
||||
cellInfo = [self.objectValue lineInfo];
|
||||
|
||||
if (cellInfo) {
|
||||
float pathWidth = 10 + 10 * cellInfo.numColumns;
|
||||
|
||||
float pathWidth = 10 + 10 * cellInfo.numColumns;
|
||||
NSRect ownRect;
|
||||
NSDivideRect(rect, &ownRect, &rect, pathWidth, NSMinXEdge);
|
||||
|
||||
NSRect ownRect;
|
||||
NSDivideRect(rect, &ownRect, &rect, pathWidth, NSMinXEdge);
|
||||
for (PBGitGraphLine* line in cellInfo.lines) {
|
||||
if (line.upper == 0)
|
||||
[self drawLineFromColumn: line.from toColumn: line.to inRect:ownRect offset: ownRect.size.height color: line.colorIndex];
|
||||
else
|
||||
[self drawLineFromColumn: line.from toColumn: line.to inRect:ownRect offset: 0 color:line.colorIndex];
|
||||
}
|
||||
|
||||
for (PBGitGraphLine* line in cellInfo.lines) {
|
||||
if (line.upper == 0)
|
||||
[self drawLineFromColumn: line.from toColumn: line.to inRect:ownRect offset: ownRect.size.height color: line.colorIndex];
|
||||
if (cellInfo.sign == '<' || cellInfo.sign == '>')
|
||||
[self drawTriangleInRect: ownRect sign: cellInfo.sign];
|
||||
else
|
||||
[self drawLineFromColumn: line.from toColumn: line.to inRect:ownRect offset: 0 color:line.colorIndex];
|
||||
[self drawCircleInRect: ownRect];
|
||||
}
|
||||
|
||||
if (cellInfo.sign == '<' || cellInfo.sign == '>')
|
||||
[self drawTriangleInRect: ownRect sign: cellInfo.sign];
|
||||
else
|
||||
[self drawCircleInRect: ownRect];
|
||||
|
||||
if (cellInfo.refs)
|
||||
if ([self.objectValue refs])
|
||||
[self drawRefsInRect:&rect];
|
||||
|
||||
[super drawWithFrame:rect inView:view];
|
||||
isReady = NO;
|
||||
|
||||
// Still use this superclass because of hilighting differences
|
||||
//_contents = [self.objectValue subject];
|
||||
//[super drawWithFrame:rect inView:view];
|
||||
[textCell setObjectValue: [self.objectValue subject]];
|
||||
[textCell setHighlighted: [self isHighlighted]];
|
||||
[textCell drawWithFrame:rect inView: view];
|
||||
}
|
||||
|
||||
- (void) setObjectValue: (PBGitCommit*)object {
|
||||
[super setObjectValue:[NSValue valueWithNonretainedObject:object]];
|
||||
}
|
||||
|
||||
- (PBGitCommit*) objectValue {
|
||||
return [[super objectValue] nonretainedObjectValue];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -90,4 +90,24 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void) removeRef: (id) sender
|
||||
{
|
||||
NSLog(@"Removing refs is not yet supported");
|
||||
}
|
||||
|
||||
- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems {
|
||||
DOMNode *node = [element valueForKey:@"WebElementDOMNode"];
|
||||
|
||||
if ([[node className] isEqualToString:@"DOMText"])
|
||||
node = [node parentNode];
|
||||
|
||||
// Every ref has a class name of 'refs' and some other class. We check on that to see if we pressed on a ref.
|
||||
if ([[node className] hasPrefix:@"refs "]) {
|
||||
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"Remove" action:@selector(removeRef:) keyEquivalent: @""];
|
||||
[item setTarget: self];
|
||||
return [NSArray arrayWithObject: item];
|
||||
}
|
||||
|
||||
return defaultMenuItems;
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
<td class="property_name">Subject:</td>
|
||||
<td id="subjectID" style="font-weight:bold">Pieter de Bie</td>
|
||||
</tr>
|
||||
<tr style="display:none">
|
||||
<td class="property_name">Refs:</td>
|
||||
<td id="refs"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>
|
||||
<div id="message"></div>
|
||||
|
||||
@@ -2,6 +2,7 @@ var commit;
|
||||
var Commit = Class.create({
|
||||
initialize: function(obj) {
|
||||
this.raw = obj.details;
|
||||
this.refs = obj.refs;
|
||||
|
||||
var diffStart = this.raw.indexOf("\ndiff ");
|
||||
var messageStart = this.raw.indexOf("\n\n") + 2;
|
||||
@@ -67,6 +68,15 @@ var loadCommit = function() {
|
||||
new_row.innerHTML = "<td class='property_name'>Parent:</td><td><a href='' onclick=\"selectCommit(this.innerHTML); return false;\">" + parent + "</a></td>";
|
||||
});
|
||||
|
||||
if (commit.refs){
|
||||
$('refs').parentNode.style.display = "";
|
||||
$('refs').innerHTML = "";
|
||||
$A(commit.refs).each(function(ref) {
|
||||
$('refs').innerHTML += '<span class="refs ' + ref.type() + '">' + ref.shortName() + '</span>';
|
||||
});
|
||||
} else
|
||||
$('refs').parentNode.style.display = "none";
|
||||
|
||||
$("message").innerHTML = commit.message.replace(/\n/g,"<br>");
|
||||
|
||||
if (commit.diff.length < 10000) {
|
||||
|
||||
@@ -36,4 +36,24 @@ a.showdiff {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.refs {
|
||||
font-size: 9px;
|
||||
font-family: Helvetica;
|
||||
border: 1px solid black;
|
||||
margin-right: 5px;
|
||||
padding: 1px 3px 1px 3px;
|
||||
-webkit-border-radius: 2px;
|
||||
}
|
||||
|
||||
.refs.head {
|
||||
background-color: #aaf254;
|
||||
}
|
||||
|
||||
.refs.remote {
|
||||
background-color: #b2dfff;
|
||||
}
|
||||
|
||||
.refs.tag {
|
||||
background-color: #fced4f;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user