@@ -35,8 +35,6 @@ @implementation PBGitSidebarController
35
35
@synthesize remotes;
36
36
@synthesize sourceView;
37
37
@synthesize sourceListControlsView;
38
- @synthesize historyViewController;
39
- @synthesize commitViewController;
40
38
41
39
- (id )initWithRepository : (PBGitRepository *)theRepository superController : (PBGitWindowController *)controller
42
40
{
@@ -53,9 +51,6 @@ - (void)awakeFromNib
53
51
window.contentView = self.view ;
54
52
[self populateList ];
55
53
56
- historyViewController = [[PBGitHistoryController alloc ] initWithRepository: repository superController: superController];
57
- commitViewController = [[PBGitCommitController alloc ] initWithRepository: repository superController: superController];
58
-
59
54
[repository addObserver: self forKeyPath: @" currentBranch" options: 0 context: @" currentBranchChange" ];
60
55
[repository addObserver: self forKeyPath: @" branches" options: (NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew) context: @" branchesModified" ];
61
56
[repository addObserver: self forKeyPath: @" stashes" options: 0 context: @" stashesModified" ];
@@ -83,9 +78,6 @@ - (void)dealloc
83
78
84
79
- (void )closeView
85
80
{
86
- [historyViewController closeView ];
87
- [commitViewController closeView ];
88
-
89
81
[repository removeObserver: self forKeyPath: @" currentBranch" ];
90
82
[repository removeObserver: self forKeyPath: @" branches" ];
91
83
[repository removeObserver: self forKeyPath: @" stashes" ];
@@ -215,11 +207,6 @@ - (void) removeRevSpec:(PBGitRevSpecifier *)rev
215
207
[sourceView reloadData ];
216
208
}
217
209
218
- - (void )setHistorySearch : (NSString *)searchString mode : (PBHistorySearchMode)mode
219
- {
220
- [historyViewController.searchController setHistorySearch: searchString mode: mode];
221
- }
222
-
223
210
- (void ) openSubmoduleFromMenuItem : (NSMenuItem *)menuItem
224
211
{
225
212
[self openSubmoduleAtURL: [menuItem representedObject ]];
@@ -244,12 +231,12 @@ - (void)outlineViewSelectionDidChange:(NSNotification *)notification
244
231
if ([item revSpecifier ]) {
245
232
if (![repository.currentBranch isEqual: [item revSpecifier ]])
246
233
repository.currentBranch = [item revSpecifier ];
247
- [superController changeContentController: historyViewController];
234
+ [superController changeContentController: superController. historyViewController];
248
235
[PBGitDefaults setShowStageView: NO ];
249
236
}
250
237
251
238
if (item == stage) {
252
- [superController changeContentController: commitViewController];
239
+ [superController changeContentController: superController. commitViewController];
253
240
[PBGitDefaults setShowStageView: YES ];
254
241
}
255
242
@@ -258,12 +245,22 @@ - (void)outlineViewSelectionDidChange:(NSNotification *)notification
258
245
}
259
246
260
247
- (void )doubleClicked : (id )object {
261
- NSInteger rowNumber = [sourceView selectedRow ];
262
- if ([[sourceView itemAtRow: rowNumber] isKindOfClass: [PBGitSVSubmoduleItem class ]]) {
263
- PBGitSVSubmoduleItem *subModule = [sourceView itemAtRow: rowNumber];
264
-
265
- [self openSubmoduleAtURL: [subModule path ]];
266
- }
248
+ NSInteger rowNumber = [sourceView selectedRow ];
249
+
250
+ id item = [sourceView itemAtRow: rowNumber];
251
+ if ([item isKindOfClass: [PBGitSVSubmoduleItem class ]]) {
252
+ PBGitSVSubmoduleItem *subModule = item;
253
+
254
+ [self openSubmoduleAtURL: [subModule path ]];
255
+ } else if ([item isKindOfClass: [PBGitSVBranchItem class ]]) {
256
+ PBGitSVBranchItem *branch = item;
257
+
258
+ NSError *error = nil ;
259
+ BOOL success = [repository checkoutRefish: [branch ref ] error: &error];
260
+ if (!success) {
261
+ [self .windowController showErrorSheet: error];
262
+ }
263
+ }
267
264
}
268
265
269
266
- (BOOL )outlineView : (NSOutlineView *)outlineView shouldEditTableColumn : (NSTableColumn *)tableColumn item : (id )item
@@ -392,7 +389,7 @@ - (void) addMenuItemsForRef:(PBGitRef *)ref toMenu:(NSMenu *)menu
392
389
if (!ref)
393
390
return ;
394
391
395
- for (NSMenuItem *menuItem in [historyViewController.refController menuItemsForRef: ref])
392
+ for (NSMenuItem *menuItem in [superController. historyViewController.refController menuItemsForRef: ref])
396
393
[menu addItem: menuItem];
397
394
}
398
395
0 commit comments