Skip to content

Commit a9b2857

Browse files
committed
Merge pull request #189 from jphalip/master
Multiple performance and UI improvements
2 parents 7e8d79a + e4725ae commit a9b2857

12 files changed

+227
-60
lines changed

English.lproj/PBCreateTagSheet.xib

Lines changed: 153 additions & 23 deletions
Large diffs are not rendered by default.

GLFileView.m

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ - (NSString *) parseBlame:(NSString *)txt
550550
NSMutableDictionary *headers=[NSMutableDictionary dictionary];
551551
NSMutableString *res=[NSMutableString string];
552552

553+
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] initWithDateFormat:@"%Y-%m-%d %H:%M:%S" allowNaturalLanguage:NO];
554+
553555
[res appendString:@"<table class='blocks'>\n"];
554556
int i=0;
555557
while(i<[lines count]){
@@ -561,12 +563,32 @@ - (NSString *) parseBlame:(NSString *)txt
561563
[res appendFormat:@"<tr class='block l%d'>\n",nLines];
562564
line=[lines objectAtIndex:++i];
563565
if([[[line componentsSeparatedByString:@" "] objectAtIndex:0] isEqual:@"author"]){
564-
NSString *author=[line stringByReplacingOccurrencesOfString:@"author" withString:@""];
566+
NSString *author=[line stringByReplacingOccurrencesOfString:@"author " withString:@""];
567+
568+
NSString *timestamp=nil;
569+
while(timestamp==nil){
570+
line=[lines objectAtIndex:i++];
571+
if([[[line componentsSeparatedByString:@" "] objectAtIndex:0] isEqual:@"author-time"]){
572+
timestamp=[line stringByReplacingOccurrencesOfString:@"author-time " withString:@""];
573+
}
574+
}
575+
576+
NSString *timezone=nil;
577+
while(timezone==nil){
578+
line=[lines objectAtIndex:i++];
579+
if([[[line componentsSeparatedByString:@" "] objectAtIndex:0] isEqual:@"author-tz"]){
580+
timezone=[line stringByReplacingOccurrencesOfString:@"author-tz " withString:@""];
581+
}
582+
}
583+
584+
NSDate *date = [NSDate dateWithTimeIntervalSince1970:[timestamp doubleValue]];
585+
NSString *dateString = [NSString stringWithFormat:@"%@ %@",[dateFormatter stringFromDate: date],timezone];
586+
565587
NSString *summary=nil;
566588
while(summary==nil){
567589
line=[lines objectAtIndex:i++];
568590
if([[[line componentsSeparatedByString:@" "] objectAtIndex:0] isEqual:@"summary"]){
569-
summary=[line stringByReplacingOccurrencesOfString:@"summary" withString:@""];
591+
summary=[line stringByReplacingOccurrencesOfString:@"summary " withString:@""];
570592
}
571593
}
572594
NSRange trunc_c={0,7};
@@ -583,7 +605,8 @@ - (NSString *) parseBlame:(NSString *)txt
583605
if([summary length]>30){
584606
truncate_s=[summary substringWithRange:trunc];
585607
}
586-
NSString *block=[NSString stringWithFormat:@"<td><p class='author'><a href='' onclick='selectCommit(\"%@\"); return false;'>%@</a> %@</p><p class='summary'>%@</p></td>\n<td>\n",commitID,truncate_c,truncate_a,truncate_s];
608+
NSString *tooltip = [NSString stringWithFormat:@"%@\nAuthor: %@\nDate: %@\n\n%@",commitID,author,dateString,summary];
609+
NSString *block=[NSString stringWithFormat:@"<td><p class='author'><a title='%@' href='' onclick='selectCommit(\"%@\"); return false;'>%@</a> %@</p><p class='summary'>%@</p></td>\n<td>\n",tooltip,commitID,truncate_c,truncate_a,truncate_s];
587610
[headers setObject:block forKey:[header objectAtIndex:0]];
588611
}
589612
[res appendString:[headers objectForKey:[header objectAtIndex:0]]];
@@ -703,7 +726,7 @@ - (NSString *)numberOfMatchesString
703726

704727
- (void) updateSearch
705728
{
706-
[view search:searchField update:YES direction:YES];
729+
[view search:searchField update:YES grabFocus:NO direction:YES];
707730
[self updateSearchUI];
708731
}
709732

@@ -725,7 +748,7 @@ - (IBAction)searchFieldChanged:(id)sender
725748
{
726749
BOOL update=[[searchField stringValue] isEqualToString:searchString]? NO: YES;
727750
searchString=[searchField stringValue];
728-
[view search:searchField update:update direction:YES];
751+
[view search:searchField update:update grabFocus:YES direction:YES];
729752
[self updateSearchUI];
730753
}
731754

@@ -734,9 +757,9 @@ - (IBAction)stepperPressed:(id)sender {
734757
NSInteger selectedSegment = [sender selectedSegment];
735758

736759
if (selectedSegment == 0)
737-
[view search:searchField update:NO direction:NO];
760+
[view search:searchField update:NO grabFocus:YES direction:NO];
738761
else
739-
[view search:searchField update:NO direction:YES];
762+
[view search:searchField update:NO grabFocus:YES direction:YES];
740763
}
741764

742765
@end

PBCreateTagSheet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@
3434
@property (strong) IBOutlet NSTextField *tagNameField;
3535
@property (strong) IBOutlet NSTextView *tagMessageText;
3636
@property (strong) IBOutlet NSTextField *errorMessageField;
37+
@property (assign) BOOL replaceExisting;
3738

3839
@end

PBCreateTagSheet.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ @implementation PBCreateTagSheet
2626
@synthesize tagNameField;
2727
@synthesize tagMessageText;
2828
@synthesize errorMessageField;
29+
@synthesize replaceExisting;
2930

3031
static PBCreateTagSheet *sheet;
3132

@@ -69,13 +70,13 @@ - (IBAction) createTag:(id)sender
6970
}
7071

7172
NSString *refExistsReturnMessage;
72-
if([self.repository refExists:ref checkOnRemotesWithoutBranches:NO resultMessage:&refExistsReturnMessage])
73+
if(!self.replaceExisting && [self.repository refExists:ref checkOnRemotesWithoutBranches:NO resultMessage:&refExistsReturnMessage])
7374
{
7475
NSError *error = [NSError errorWithDomain:PBGitRepositoryErrorDomain
7576
code:0
7677
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
7778
refExistsReturnMessage, NSLocalizedDescriptionKey,
78-
@"Select other tagname.", NSLocalizedRecoverySuggestionErrorKey,
79+
@"Enter another tag name.", NSLocalizedRecoverySuggestionErrorKey,
7980
nil]
8081
];
8182
[[NSAlert alertWithError:error]runModal];
@@ -89,7 +90,7 @@ - (IBAction) createTag:(id)sender
8990
defaultButton:@"Yes"
9091
alternateButton:@"No"
9192
otherButton:nil
92-
informativeTextWithFormat:@"Still want to create the %@ %@?",[ref refishType],[ref shortName]] runModal];
93+
informativeTextWithFormat:@"Do you still want to create the %@ %@?",[ref refishType],[ref shortName]] runModal];
9394

9495
if (returnButton == NSAlertAlternateReturn)
9596
{
@@ -101,7 +102,7 @@ - (IBAction) createTag:(id)sender
101102
[self closeCreateTagSheet:sender];
102103

103104
NSString *message = [self.tagMessageText string];
104-
[self.repository createTag:tagName message:message atRefish:self.targetRefish];
105+
[self.repository createTag:tagName message:message atRefish:self.targetRefish force:self.replaceExisting];
105106
}
106107

107108

PBGitRepository.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ dispatch_queue_t PBGetWorkQueue();
8080
- (BOOL) rebaseBranch:(id <PBGitRefish>)branch onRefish:(id <PBGitRefish>)upstream;
8181
- (BOOL) renameRef:(PBGitRef*)ref withNewName:(NSString *)newName;
8282
- (BOOL) createBranch:(NSString *)branchName atRefish:(id <PBGitRefish>)ref;
83-
- (BOOL) createTag:(NSString *)tagName message:(NSString *)message atRefish:(id <PBGitRefish>)commitSHA;
83+
- (BOOL) createTag:(NSString *)tagName message:(NSString *)message atRefish:(id <PBGitRefish>)commitSHA force:(BOOL)force;
8484
- (BOOL) deleteRemote:(PBGitRef *)ref;
8585
- (BOOL) isRemoteConnected:(NSString*)remoteName;
8686
- (BOOL) deleteRemoteBranch:(PBGitRef *)ref;

PBGitRepository.m

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,13 @@ - (void) setup
186186
{
187187
config = [[PBGitConfig alloc] initWithRepositoryPath:[[self fileURL] path]];
188188
self.branches = [NSMutableArray array];
189-
[self reloadRefs];
190189
currentBranchFilter = [PBGitDefaults branchFilter];
191190
revisionList = [[PBGitHistoryList alloc] initWithRepository:self];
192-
193191
resetController = [[PBGitResetController alloc] initWithRepository:self];
194192
stashController = [[PBStashController alloc] initWithRepository:self];
195193
submoduleController = [[PBSubmoduleController alloc] initWithRepository:self];
194+
[self reloadRefs];
195+
[self readCurrentBranch];
196196
}
197197

198198
- (void)close
@@ -614,7 +614,7 @@ - (BOOL)refExists:(PBGitRef *)ref checkOnRemotesWithoutBranches:(BOOL)remoteChec
614614
{
615615
if (result)
616616
{
617-
*result = [NSString stringWithFormat:@"%@ exists already local as branch!",refShortName];
617+
*result = [NSString stringWithFormat:@"%@ already exists as local branch!",refShortName];
618618
}
619619
return YES;
620620
}
@@ -626,7 +626,7 @@ - (BOOL)refExists:(PBGitRef *)ref checkOnRemotesWithoutBranches:(BOOL)remoteChec
626626
{
627627
if (result)
628628
{
629-
*result = [NSString stringWithFormat:@"%@ exists already local as tag!",refShortName];
629+
*result = [NSString stringWithFormat:@"%@ already exists as local tag!",refShortName];
630630
}
631631
return YES;
632632
}
@@ -637,7 +637,7 @@ - (BOOL)refExists:(PBGitRef *)ref checkOnRemotesWithoutBranches:(BOOL)remoteChec
637637
{
638638
if (result)
639639
{
640-
*result = [NSString stringWithFormat:@"%@ exists already local as remotename!",refShortName];
640+
*result = [NSString stringWithFormat:@"%@ already exists as remote reference!",refShortName];
641641
}
642642
return YES;
643643
}
@@ -1428,7 +1428,7 @@ - (BOOL) renameRef:(PBGitRef*)ref withNewName:(NSString *)newName;
14281428
return retValue;
14291429
}
14301430

1431-
- (BOOL) createTag:(NSString *)tagName message:(NSString *)message atRefish:(id <PBGitRefish>)target
1431+
- (BOOL) createTag:(NSString *)tagName message:(NSString *)message atRefish:(id <PBGitRefish>)target force:(BOOL)force
14321432
{
14331433
if (!tagName)
14341434
return NO;
@@ -1441,6 +1441,10 @@ - (BOOL) createTag:(NSString *)tagName message:(NSString *)message atRefish:(id
14411441
[arguments addObject:[@"-m" stringByAppendingString:message]];
14421442
}
14431443

1444+
if (force) {
1445+
[arguments addObject:@"-f"];
1446+
}
1447+
14441448
[arguments addObject:tagName];
14451449

14461450
// if no refish then git will add it to HEAD

PBGitSidebarController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
- (void)setHistorySearch:(NSString *)searchString mode:(NSInteger)mode;
4848

49-
-(NSNumber *)countCommintsOf:(NSString *)range;
49+
-(NSNumber *)countCommitsOf:(NSString *)range;
5050
-(bool)remoteNeedFetch:(NSString *)remote;
5151

5252
@property(strong, readonly) NSMutableArray *items;

PBGitSidebarController.m

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ - (void)awakeFromNib
8484

8585
[sourceView setDoubleAction:@selector(outlineDoubleClicked)];
8686
[sourceView setTarget:self];
87+
[self updateMetaDataForBranches];
8788
}
8889

8990
- (void)closeView
@@ -162,33 +163,36 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
162163
for(PBGitSVRemoteItem* remote in [remotes children]){
163164
[self performSelectorInBackground:@selector(evaluateRemoteBadge:) withObject:remote];
164165
}
165-
166-
[self updateMetaDataforBranches:branches];
166+
[self updateMetaDataForBranches];
167167
}else{
168168
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
169169
}
170170
}
171171

172172

173-
-(void)updateMetaDataforBranches:(PBSourceViewItem *)theBranches
173+
-(void)updateMetaDataForBranches:(PBSourceViewItem *)theBranches
174174
{
175175
for(PBGitSVBranchItem* branch in [theBranches children]){
176176
if([branch isKindOfClass:[PBGitSVBranchItem class]]){
177177
dispatch_async(PBGetWorkQueue(),^{
178-
id ahead = [self countCommintsOf:[NSString stringWithFormat:@"origin/%@..%@",branch.revSpecifier,branch.revSpecifier]];
179-
id behind = [self countCommintsOf:[NSString stringWithFormat:@"%@..origin/%@",branch.revSpecifier,branch.revSpecifier]];
178+
id ahead = [self countCommitsOf:[NSString stringWithFormat:@"origin/%@..%@",branch.revSpecifier,branch.revSpecifier]];
179+
id behind = [self countCommitsOf:[NSString stringWithFormat:@"%@..origin/%@",branch.revSpecifier,branch.revSpecifier]];
180180
dispatch_async(dispatch_get_main_queue(),^{
181181
[branch setAhead:ahead];
182182
[branch setBehind:behind];
183183
[branch setIsCheckedOut:[branch.revSpecifier isEqual:[repository headRef]]];
184184
});
185185
});
186186
}else if ([branch isKindOfClass:[PBGitSVFolderItem class]]) {
187-
[self updateMetaDataforBranches: branch];
187+
[self updateMetaDataForBranches: branch];
188188
}
189189
}
190190
}
191191

192+
-(void)updateMetaDataForBranches
193+
{
194+
[self updateMetaDataForBranches: branches];
195+
}
192196

193197
#pragma mark Badges Methods
194198

@@ -205,7 +209,7 @@ -(void)evaluateRemoteBadge:(PBGitSVRemoteItem *)remote
205209
}
206210
}
207211

208-
-(NSNumber *)countCommintsOf:(NSString *)range
212+
-(NSNumber *)countCommitsOf:(NSString *)range
209213
{
210214
NSArray *args = [NSArray arrayWithObjects:@"rev-list", range, nil];
211215
int ret;

PBGitWindowController.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ - (void) changeContentController:(PBViewController *)controller
135135

136136
[self setNextResponder: contentController];
137137
[[self window] makeFirstResponder:[contentController firstResponder]];
138-
[contentController updateView];
139138
[contentController addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionInitial context:@"statusChange"];
140139
}
141140

PBRefMenuItem.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ + (NSArray *) defaultMenuItemsForRef:(PBGitRef *)ref inRepository:(PBGitReposito
6060
[items addObject:[PBRefMenuItem itemWithTitle:checkoutTitle action:@selector(checkout:) enabled:!isHead]];
6161
[items addObject:[PBRefMenuItem separatorItem]];
6262

63-
NSString *resetTitle = [NSString stringWithFormat:@"Reset %@ to %@", headRefName, targetRefName];
63+
NSString *resetTitle = [NSString stringWithFormat:@"Reset %@ to %@", headRefName, targetRefName];
6464
[items addObject:[PBRefMenuItem itemWithTitle: resetTitle action:@selector(reset:) enabled:YES]];
6565
[items addObject:[PBRefMenuItem separatorItem]];
6666

@@ -172,7 +172,7 @@ + (NSArray *) defaultMenuItemsForCommit:(PBGitCommit *)commit target:(id)target
172172
[items addObject:[PBRefMenuItem itemWithTitle:@"Checkout Commit" action:@selector(checkout:) enabled:YES]];
173173
[items addObject:[PBRefMenuItem separatorItem]];
174174

175-
NSString *resetTitle = [NSString stringWithFormat:@"Reset %@ to here", headBranchName];
175+
NSString *resetTitle = [NSString stringWithFormat:@"Reset %@ to here", headBranchName];
176176
[items addObject:[PBRefMenuItem itemWithTitle: resetTitle action:@selector(reset:) enabled:YES]];
177177
[items addObject:[PBRefMenuItem separatorItem]];
178178

0 commit comments

Comments
 (0)