Skip to content

Commit

Permalink
fixed up the view and discovered that delta resolution is not working…
Browse files Browse the repository at this point in the history
… correctly
  • Loading branch information
schacon committed Sep 29, 2008
1 parent 80d2f38 commit 590a0b4
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 48 deletions.
84 changes: 43 additions & 41 deletions CommitsViewController.m
Expand Up @@ -27,7 +27,7 @@ - (void)viewWillAppear:(BOOL)animated {

// load data
NSLog(@"Data load");
self.commitList = [gitRepo getCommitsFromSha:gitSha withLimit:100];
self.commitList = [gitRepo getCommitsFromSha:gitSha withLimit:30];

// Scroll the table view to the top before it appears
[self.tableView reloadData];
Expand Down Expand Up @@ -58,9 +58,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
return cell;
}

#define NAME_TAG 1
#define TIME_TAG 2
#define IMAGE_TAG 3
#define ONE_TAG 1
#define TWO_TAG 2
#define THR_TAG 3
#define FOUR_TAG 4

- (void)configureCell:(UITableViewCell *)cell forIndexPath:(NSIndexPath *)indexPath {

Expand All @@ -70,30 +71,25 @@ - (void)configureCell:(UITableViewCell *)cell forIndexPath:(NSIndexPath *)indexP
static NSDateFormatter *dateFormatter = nil;
if (dateFormatter == nil) {
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"h:mm a"];
[dateFormatter setDateFormat:@"MMM dd YY, kk:ss"]; // Sept 5 08:30
}

ObjGitCommit *commit = [self.commitList objectAtIndex:indexPath.row];

UILabel *label;

// Get the time zone wrapper for the row
label = (UILabel *)[cell viewWithTag:NAME_TAG];
label.text = [commit author];

label = (UILabel *)[cell viewWithTag:TIME_TAG];
NSLog(@"DATE");
//NSLog(@"DATE:%@", [commit authored_date]);
//label.text = [dateFormatter stringFromDate:[commit authored_date]];
label.font = [UIFont fontWithName:@"Courier New" size:20];
label = (UILabel *)[cell viewWithTag:ONE_TAG];
label.text = [[commit sha] substringToIndex:6];

//label = (UILabel *)[cell viewWithTag:IMAGE_TAG];
//label.text = [commit author];
label = (UILabel *)[cell viewWithTag:TWO_TAG];
label.text = [commit author];

// Get the time zone wrapper for the row
//UIImageView *imageView = (UIImageView *)[cell viewWithTag:IMAGE_TAG];
//imageView.image = wrapper.image;
label = (UILabel *)[cell viewWithTag:THR_TAG];
label.text = [dateFormatter stringFromDate:[commit authored_date]];

label = (UILabel *)[cell viewWithTag:FOUR_TAG];
label.text = [commit message];
}


Expand All @@ -109,51 +105,57 @@ - (UITableViewCell *)tableviewCellWithReuseIdentifier:(NSString *)identifier {
UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:rect reuseIdentifier:identifier] autorelease];

#define LEFT_COLUMN_OFFSET 10.0
#define LEFT_COLUMN_WIDTH 160.0
#define LEFT_COLUMN_WIDTH 70.0

#define MIDDLE_COLUMN_OFFSET 170.0
#define MIDDLE_COLUMN_WIDTH 90.0
#define MIDDLE_COLUMN_OFFSET 80.0
#define MIDDLE_COLUMN_WIDTH 130.0

#define RIGHT_COLUMN_OFFSET 280.0
#define RIGHT_COLUMN_OFFSET 210.0
#define RIGHT_COLUMN_WIDTH 90.0

#define MAIN_FONT_SIZE 18.0
#define LABEL_HEIGHT 26.0

#define IMAGE_SIDE 30.0


/*
Create labels for the text fields; set the highlight color so that when the cell is selected it changes appropriately.
*/
UILabel *label;

rect = CGRectMake(LEFT_COLUMN_OFFSET, (ROW_HEIGHT - LABEL_HEIGHT) / 2.0, LEFT_COLUMN_WIDTH, LABEL_HEIGHT);
rect = CGRectMake(LEFT_COLUMN_OFFSET, 10, LEFT_COLUMN_WIDTH, LABEL_HEIGHT);
label = [[UILabel alloc] initWithFrame:rect];
label.tag = NAME_TAG;
label.font = [UIFont boldSystemFontOfSize:MAIN_FONT_SIZE];
label.tag = ONE_TAG;
label.font = [UIFont fontWithName:@"Courier New" size:15];
label.adjustsFontSizeToFitWidth = YES;
[cell.contentView addSubview:label];
label.highlightedTextColor = [UIColor whiteColor];
[label release];

rect = CGRectMake(MIDDLE_COLUMN_OFFSET, (ROW_HEIGHT - LABEL_HEIGHT) / 2.0, MIDDLE_COLUMN_WIDTH, LABEL_HEIGHT);
rect = CGRectMake(MIDDLE_COLUMN_OFFSET, 0, MIDDLE_COLUMN_WIDTH, LABEL_HEIGHT);
label = [[UILabel alloc] initWithFrame:rect];
label.tag = TIME_TAG;
label.font = [UIFont systemFontOfSize:MAIN_FONT_SIZE];
label.textAlignment = UITextAlignmentRight;
label.tag = TWO_TAG;
label.font = [UIFont systemFontOfSize:15];
label.textAlignment = UITextAlignmentLeft;
[cell.contentView addSubview:label];
label.highlightedTextColor = [UIColor whiteColor];
[label release];

rect = CGRectMake(RIGHT_COLUMN_OFFSET, 0, RIGHT_COLUMN_WIDTH, LABEL_HEIGHT);
label = [[UILabel alloc] initWithFrame:rect];
label.tag = THR_TAG;
label.textAlignment = UITextAlignmentRight;
label.font = [UIFont systemFontOfSize:10];
[cell.contentView addSubview:label];
label.highlightedTextColor = [UIColor whiteColor];
[label release];

// Create an image view for the quarter image

rect = CGRectMake(RIGHT_COLUMN_OFFSET, (ROW_HEIGHT - IMAGE_SIDE) / 2.0, IMAGE_SIDE, IMAGE_SIDE);

UIImageView *imageView = [[UIImageView alloc] initWithFrame:rect];
imageView.tag = IMAGE_TAG;
[cell.contentView addSubview:imageView];
[imageView release];

rect = CGRectMake(MIDDLE_COLUMN_OFFSET, LABEL_HEIGHT, 200.0, 15);
label = [[UILabel alloc] initWithFrame:rect];
label.tag = FOUR_TAG;
label.textAlignment = UITextAlignmentLeft;
label.font = [UIFont systemFontOfSize:10];
[cell.contentView addSubview:label];
label.highlightedTextColor = [UIColor whiteColor];
[label release];

return cell;
}
Expand Down
4 changes: 2 additions & 2 deletions Git/ObjGit.m
Expand Up @@ -115,7 +115,7 @@ - (NSString *) writeObject:(NSData *)objectData withType:(NSString *)type withSi

CC_SHA1([object bytes], [object length], rawsha);
[ObjGit gitUnpackHex:rawsha fillSha:sha1];
//NSLog(@"WRITING SHA: %s", sha1);
NSLog(@"WRITING SHA: %s", sha1);

// write object to file
shaStr = [NSString stringWithCString:sha1 encoding:NSASCIIStringEncoding];
Expand Down Expand Up @@ -162,7 +162,7 @@ - (NSMutableArray *) getCommitsFromSha:(NSString *)shaValue withLimit:(int)commi
- (ObjGitObject *) getObjectFromSha:(NSString *)sha1
{
NSString *objectPath = [self getLooseObjectPathBySha:sha1];
// NSLog(@"READ FROM FILE: %@", objectPath);
NSLog(@"READ FROM FILE: %@", objectPath);
NSFileHandle *fm = [NSFileHandle fileHandleForReadingAtPath:objectPath];
return [[ObjGitObject alloc] initFromRaw:[fm availableData] withSha:sha1];
}
Expand Down
4 changes: 2 additions & 2 deletions Git/ObjGitCommit.h
Expand Up @@ -25,10 +25,10 @@
@property(assign, readwrite) NSString *treeSha;
@property(assign, readwrite) NSString *author;
@property(assign, readwrite) NSString *author_email;
@property(retain, readwrite) NSDate *authored_date;
@property(copy , readwrite) NSDate *authored_date;
@property(assign, readwrite) NSString *committer;
@property(assign, readwrite) NSString *committer_email;
@property(retain, readwrite) NSDate *committed_date;
@property(retain, readwrite) NSDate *committed_date;
@property(assign, readwrite) NSString *message;
@property(assign, readwrite) ObjGitObject *git_object;

Expand Down
16 changes: 13 additions & 3 deletions Git/ObjGitServerHandler.m
Expand Up @@ -113,6 +113,7 @@ - (void) receiveNeeds

- (void) uploadPackFile
{
NSLog(@"upload pack file");
NSString *command, *shaValue;
NSArray *thisRef;

Expand All @@ -127,6 +128,7 @@ - (void) uploadPackFile
}
}

NSLog(@"gathering shas");
e = [needRefs objectEnumerator];
while ( (thisRef = [e nextObject]) ) {
command = [thisRef objectAtIndex:0];
Expand All @@ -141,6 +143,7 @@ - (void) uploadPackFile

- (void) sendPackData
{
NSLog(@"send pack data");
NSString *current;
NSEnumerator *e;

Expand Down Expand Up @@ -226,31 +229,38 @@ - (void) longVal:(uint32_t)raw toByteBuffer:(uint8_t *)buffer
- (void) gatherObjectShasFromCommit:(NSString *)shaValue
{
NSString *parentSha;

ObjGitCommit *commit = [[ObjGitCommit alloc] initFromGitObject:[gitRepo getObjectFromSha:shaValue]];
[refDict setObject:@"_commit" forKey:shaValue];

// add the tree objects
[self gatherObjectShasFromTree:[commit treeSha]];

NSArray *parents = [commit parentShas];
[commit release];

NSEnumerator *e = [parents objectEnumerator];
while ( (parentSha = [e nextObject]) ) {
NSLog(@"parent sha:%@", parentSha);
// TODO : check that refDict does not have this
[self gatherObjectShasFromCommit:parentSha];
}
}

- (void) gatherObjectShasFromTree:(NSString *)shaValue
{
ObjGitTree *tree = [[ObjGitTree alloc] initFromGitObject:[gitRepo getObjectFromSha:shaValue]];
NSLog(@"Gather from tree");
ObjGitTree *tree = [ObjGitTree alloc];
NSLog(@"Tree alloc");
ObjGit *g = [gitRepo getObjectFromSha:shaValue];
NSLog(@"Obj Init alloc");
[tree initFromGitObject:g];
NSLog(@"INIT");
[refDict setObject:@"/" forKey:shaValue];
NSLog(@"Tree added");
NSEnumerator *e = [[tree treeEntries] objectEnumerator];
NSArray *entries;
NSString *name, *sha, *mode;
while ( (entries = [e nextObject]) ) {
NSLog(@"Tree entry");
mode = [entries objectAtIndex:0];
name = [entries objectAtIndex:1];
sha = [entries objectAtIndex:2];
Expand Down
2 changes: 2 additions & 0 deletions Git/ObjGitTree.m
Expand Up @@ -13,7 +13,9 @@ @implementation ObjGitTree
@synthesize gitObject;

- (id) initFromGitObject:(ObjGitObject *)object {
NSLog(@"Tree init1");
self = [super init];
NSLog(@"Tree init");
gitObject = object;
[self parseContent];
return self;
Expand Down

0 comments on commit 590a0b4

Please sign in to comment.