Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for --left-right

This draws rectangles instead of circles when someone supplies
--left-right as a GitX argument
  • Loading branch information...
commit 78e45bd22cab91f0349e3de54109a7c86284e8a9 1 parent 69c0cae
@pieter pieter authored
View
2  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;
View
2  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
View
2  PBGitGrapher.m
@@ -129,7 +129,7 @@ - (void) parseCommits: (NSArray *) commits
++row;
previous = [[PBGraphCellInfo alloc] initWithPosition:newPos andLines:lines];
-
+ previous.sign = commit.sign;
if (refs && [refs objectForKey:commit.sha])
previous.refs = [refs objectForKey:commit.sha];
View
15 PBGitRevList.m
@@ -56,9 +56,16 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
- (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 @@ - (void) walkRevisionListWithSpecifier: (PBGitRevSpecifier*) rev
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)
View
1  PBGitRevSpecifier.h
@@ -20,6 +20,7 @@
- (BOOL) isSimpleRef;
- (NSString*) simpleRef;
- (BOOL) hasPathLimiter;
+- (BOOL) hasLeftRight;
- (BOOL) isEqualTo: (PBGitRevSpecifier*) other;
@property(readonly) NSString* description;
View
8 PBGitRevSpecifier.m
@@ -55,6 +55,14 @@ - (BOOL) hasPathLimiter;
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])
View
46 PBGitRevisionCell.m
@@ -108,20 +108,21 @@ - (void) drawLineFromColumn: (int) from toColumn: (int) to inRect: (NSRect) r of
}
-- (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 @@ - (void) drawCircleForColumn: (int) c inRect: (NSRect) r
[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 @@ - (void) drawWithFrame: (NSRect) rect inView:(NSView *)view
[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];
View
2  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;
View
2  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;
Please sign in to comment.
Something went wrong with that request. Please try again.