diff --git a/PBGitCommit.h b/PBGitCommit.h index edee41e..2194608 100644 --- a/PBGitCommit.h +++ b/PBGitCommit.h @@ -17,6 +17,7 @@ NSString* details; NSArray* parents; NSDate* date; + char sign; PBGitRepository* repository; } @@ -28,6 +29,7 @@ @property (retain) NSArray* parents; @property (copy) NSDate* date; @property (readonly) NSString* dateString; +@property (assign) char sign; @property (readonly) NSString* details; @property (readonly) PBGitTree* tree; diff --git a/PBGitCommit.m b/PBGitCommit.m index 7cb7a7b..ff94454 100644 --- a/PBGitCommit.m +++ b/PBGitCommit.m @@ -11,7 +11,7 @@ @implementation PBGitCommit -@synthesize sha, repository, subject, author, date, parents; +@synthesize sha, repository, subject, author, date, parents, sign; - (NSString *) dateString diff --git a/PBGitGrapher.m b/PBGitGrapher.m index df7d87a..5dbcd46 100644 --- a/PBGitGrapher.m +++ b/PBGitGrapher.m @@ -129,7 +129,7 @@ ++row; previous = [[PBGraphCellInfo alloc] initWithPosition:newPos andLines:lines]; - + previous.sign = commit.sign; if (refs && [refs objectForKey:commit.sha]) previous.refs = [refs objectForKey:commit.sha]; diff --git a/PBGitRevList.m b/PBGitRevList.m index 57d7898..23f7582 100644 --- a/PBGitRevList.m +++ b/PBGitRevList.m @@ -56,9 +56,16 @@ - (void) walkRevisionListWithSpecifier: (PBGitRevSpecifier*) rev { - NSMutableArray * newArray = [NSMutableArray array]; + NSMutableArray* newArray = [NSMutableArray array]; + NSMutableArray* arguments; NSDate* start = [NSDate date]; - NSMutableArray* arguments = [NSMutableArray arrayWithObjects:@"log", @"--topo-order", @"--pretty=format:%H\01%an\01%s\01%P\01%at", nil]; + BOOL showSign = [rev hasLeftRight]; + + if (showSign) + arguments = [NSMutableArray arrayWithObjects:@"log", @"--topo-order", @"--pretty=format:%H\01%an\01%s\01%P\01%at\01%m", nil]; + else + arguments = [NSMutableArray arrayWithObjects:@"log", @"--topo-order", @"--pretty=format:%H\01%an\01%s\01%P\01%at", nil]; + if (!rev) [arguments addObject:@"HEAD"]; else @@ -100,7 +107,9 @@ newCommit.subject = [components objectAtIndex:2]; newCommit.author = [components objectAtIndex:1]; newCommit.date = [NSDate dateWithTimeIntervalSince1970:[[components objectAtIndex:4] intValue]]; - + if (showSign) + newCommit.sign = [[components objectAtIndex:5] characterAtIndex:0]; + [newArray addObject: newCommit]; num++; if (num % 10000 == 0) diff --git a/PBGitRevSpecifier.h b/PBGitRevSpecifier.h index cd9eb79..5477786 100644 --- a/PBGitRevSpecifier.h +++ b/PBGitRevSpecifier.h @@ -20,6 +20,7 @@ - (BOOL) isSimpleRef; - (NSString*) simpleRef; - (BOOL) hasPathLimiter; +- (BOOL) hasLeftRight; - (BOOL) isEqualTo: (PBGitRevSpecifier*) other; @property(readonly) NSString* description; diff --git a/PBGitRevSpecifier.m b/PBGitRevSpecifier.m index d3a99f7..55c2dcb 100644 --- a/PBGitRevSpecifier.m +++ b/PBGitRevSpecifier.m @@ -55,6 +55,14 @@ return NO; } +- (BOOL) hasLeftRight +{ + for (NSString* param in parameters) + if ([param isEqualToString:@"--left-right"]) + return YES; + return NO; +} + - (BOOL) isEqualTo: (PBGitRevSpecifier*) other { if ([self isSimpleRef] ^ [other isSimpleRef]) diff --git a/PBGitRevisionCell.m b/PBGitRevisionCell.m index d88c3ad..8a50c03 100644 --- a/PBGitRevisionCell.m +++ b/PBGitRevisionCell.m @@ -108,20 +108,21 @@ } -- (void) drawCircleForColumn: (int) c inRect: (NSRect) r +- (void) drawCircleInRect: (NSRect) r { - [[NSColor blackColor] set]; + int c = cellInfo.position; int columnWidth = 10; NSPoint origin = r.origin; NSPoint columnOrigin = { origin.x + columnWidth * c, origin.y}; - + NSRect oval = { columnOrigin.x - 5, columnOrigin.y + r.size.height * 0.5 - 5, 10, 10}; NSBezierPath * path = [NSBezierPath bezierPath]; path = [NSBezierPath bezierPathWithOvalInRect:oval]; - //[[col objectAtIndex:cellInfo.columns[c].color] set]; + + [[NSColor blackColor] set]; [path fill]; NSRect smallOval = { columnOrigin.x - 3, columnOrigin.y + r.size.height * 0.5 - 3, 6, 6}; @@ -130,6 +131,38 @@ [path fill]; } +- (void) drawTriangleInRect: (NSRect) r sign: (char) sign +{ + int c = cellInfo.position; + int columnHeight = 10; + int columnWidth = 8; + + NSPoint top; + if (sign == '<') + top.x = round(r.origin.x) + 10 * c + 4; + else { + top.x = round(r.origin.x) + 10 * c - 4; + columnWidth *= -1; + } + top.y = r.origin.y + (r.size.height - columnHeight) / 2; + + NSBezierPath * path = [NSBezierPath bezierPath]; + // Start at top + [path moveToPoint: NSMakePoint(top.x, top.y)]; + // Go down + [path lineToPoint: NSMakePoint(top.x, top.y + columnHeight)]; + // Go left top + [path lineToPoint: NSMakePoint(top.x - columnWidth, top.y + columnHeight / 2)]; + // Go to top again + [path closePath]; + + [[NSColor whiteColor] set]; + [path fill]; + [[NSColor blackColor] set]; + [path setLineWidth: 2]; + [path stroke]; +} + - (NSMutableDictionary*) attributesForRefLabelSelected: (BOOL) selected { NSMutableDictionary *attributes = [[[NSMutableDictionary alloc] initWithCapacity:2] autorelease]; @@ -213,7 +246,10 @@ [self drawLineFromColumn: line.from toColumn: line.to inRect:ownRect offset: 0 color:line.colorIndex]; } - [self drawCircleForColumn: cellInfo.position inRect: ownRect]; + if (cellInfo.sign == '<' || cellInfo.sign == '>') + [self drawTriangleInRect: ownRect sign: cellInfo.sign]; + else + [self drawCircleInRect: ownRect]; if (cellInfo.refs) [self drawRefsInRect:&rect]; diff --git a/PBGraphCellInfo.h b/PBGraphCellInfo.h index c399441..61139ea 100644 --- a/PBGraphCellInfo.h +++ b/PBGraphCellInfo.h @@ -14,11 +14,13 @@ int position; NSArray* lines; int numColumns; + char sign; NSArray* refs; } @property(readonly) NSArray* lines; @property(retain) NSArray* refs; @property(assign) int position, numColumns; +@property(assign) char sign; - (id)initWithPosition: (int) p andLines: (NSArray*) l; diff --git a/PBGraphCellInfo.m b/PBGraphCellInfo.m index 8beff21..c6d3412 100644 --- a/PBGraphCellInfo.m +++ b/PBGraphCellInfo.m @@ -10,7 +10,7 @@ @implementation PBGraphCellInfo -@synthesize lines, position, numColumns, refs; +@synthesize lines, position, numColumns, refs, sign; - (id)initWithPosition: (int) p andLines: (NSArray*) l { position = p;