Merge pull request #79 from Uncommon/stashview

Fixes for stash display
This commit is contained in:
German Laullon
2011-06-17 14:58:18 -07:00
19 changed files with 781 additions and 526 deletions
+22 -3
View File
@@ -80,6 +80,8 @@
65D58BC7132D48C2003F7290 /* PBResetSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = 65D58BC6132D48C0003F7290 /* PBResetSheet.m */; };
770B37ED0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel in Sources */ = {isa = PBXBuildFile; fileRef = 770B37EC0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel */; };
77C8280E06725ACE000B614F /* ApplicationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77C8280C06725ACE000B614F /* ApplicationController.m */; };
89087CA613A3E46B00911503 /* PBWebCommitController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89087CA513A3E46B00911503 /* PBWebCommitController.m */; };
8998B1C613A55B3500121729 /* PBWebStashController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8998B1C513A55B3500121729 /* PBWebStashController.m */; };
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
@@ -335,6 +337,10 @@
77C82804067257F0000B614F /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
77C8280B06725ACE000B614F /* ApplicationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationController.h; sourceTree = "<group>"; };
77C8280C06725ACE000B614F /* ApplicationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ApplicationController.m; sourceTree = "<group>"; };
89087CA413A3E46500911503 /* PBWebCommitController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBWebCommitController.h; sourceTree = "<group>"; };
89087CA513A3E46B00911503 /* PBWebCommitController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBWebCommitController.m; sourceTree = "<group>"; };
8998B1AC13A55AC100121729 /* PBWebStashController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBWebStashController.h; sourceTree = "<group>"; };
8998B1C513A55B3500121729 /* PBWebStashController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBWebStashController.m; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* GitX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GitX.app; sourceTree = BUILT_PRODUCTS_DIR; };
911111E10E58BD5A00BF76B4 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/RepositoryWindow.xib; sourceTree = "<group>"; };
@@ -846,6 +852,17 @@
name = Models;
sourceTree = "<group>";
};
8998B1AB13A55A9B00121729 /* Stash */ = {
isa = PBXGroup;
children = (
DDB8FDFF13998CE2001A9EE2 /* PBStashContentController.h */,
DDB8FE0013998CE2001A9EE2 /* PBStashContentController.m */,
8998B1AC13A55AC100121729 /* PBWebStashController.h */,
8998B1C513A55B3500121729 /* PBWebStashController.m */,
);
name = Stash;
sourceTree = "<group>";
};
913D5E420E5563FD00CECEA2 /* cli */ = {
isa = PBXGroup;
children = (
@@ -941,18 +958,19 @@
F5EF8C880E9D498F0050906B /* History */,
F5E927F90E883EF600056E75 /* Commit */,
D82F435F111B9C6D00A25A39 /* Sheets */,
8998B1AB13A55A9B00121729 /* Stash */,
77C8280B06725ACE000B614F /* ApplicationController.h */,
77C8280C06725ACE000B614F /* ApplicationController.m */,
93CB42C00EAB7B2200530609 /* PBGitDefaults.h */,
93CB42C10EAB7B2200530609 /* PBGitDefaults.m */,
DDB8FDFF13998CE2001A9EE2 /* PBStashContentController.h */,
DDB8FE0013998CE2001A9EE2 /* PBStashContentController.m */,
F57CC43F0E05E496000472E2 /* PBGitWindowController.h */,
F57CC4400E05E496000472E2 /* PBGitWindowController.m */,
911111F60E594F3F00BF76B4 /* PBRepositoryDocumentController.h */,
911111F70E594F3F00BF76B4 /* PBRepositoryDocumentController.m */,
F5E926040E8827D300056E75 /* PBViewController.h */,
F5E926050E8827D300056E75 /* PBViewController.m */,
89087CA413A3E46500911503 /* PBWebCommitController.h */,
89087CA513A3E46B00911503 /* PBWebCommitController.m */,
F5EF8C8C0E9D4A5D0050906B /* PBWebController.h */,
F5EF8C8D0E9D4A5D0050906B /* PBWebController.m */,
F5FE6C010EB13BC900F30D12 /* PBServicesController.h */,
@@ -1204,7 +1222,6 @@
isa = PBXProject;
buildConfigurationList = 26FC0A880875C7B200E6366F /* Build configuration list for PBXProject "GitX" */;
compatibilityVersion = "Xcode 3.1";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
@@ -1457,6 +1474,8 @@
65D58BC7132D48C2003F7290 /* PBResetSheet.m in Sources */,
31776089133569350025876E /* SearchWebView.m in Sources */,
DDB8FE0113998CE2001A9EE2 /* PBStashContentController.m in Sources */,
89087CA613A3E46B00911503 /* PBWebCommitController.m in Sources */,
8998B1C613A55B3500121729 /* PBWebStashController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
+1 -1
View File
@@ -1,5 +1,5 @@
//
// PBGitHistoryView.h
// PBGitHistoryController.h
// GitX
//
// Created by Pieter de Bie on 19-09-08.
+1 -1
View File
@@ -1,5 +1,5 @@
//
// PBGitHistoryView.m
// PBGitHistoryController.m
// GitX
//
// Created by Pieter de Bie on 19-09-08.
+1 -1
View File
@@ -34,7 +34,7 @@
PBGitHistoryController *historyViewController;
PBGitCommitController *commitViewController;
PBStashContentController *stashViewController;
PBStashContentController *stashViewController;
}
- (void) selectStage;
+2
View File
@@ -56,6 +56,8 @@
- (IBAction) cloneTo:(id)sender;
- (IBAction) refresh:(id)sender;
- (void)selectCommitForSha:(NSString *)sha;
- (NSArray *)menuItemsForPaths:(NSArray *)paths;
- (void)setHistorySearch:(NSString *)searchString mode:(NSInteger)mode;
@end
+12
View File
@@ -234,6 +234,18 @@
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
- (void) selectCommitForSha:(NSString *)sha
{
if (contentController != sidebarController.historyViewController)
[sidebarController selectCurrentBranch];
[sidebarController.historyViewController selectCommit:sha];
}
- (NSArray *) menuItemsForPaths:(NSArray *)paths
{
return [sidebarController.historyViewController menuItemsForPaths:paths];
}
- (void)setHistorySearch:(NSString *)searchString mode:(NSInteger)mode
{
[sidebarController setHistorySearch:searchString mode:mode];
+2 -1
View File
@@ -15,7 +15,8 @@
// Controls the view displaying a stash diff
@interface PBStashContentController : PBViewController {
IBOutlet id webView;
IBOutlet PBWebHistoryController *webController;
IBOutlet PBWebStashController *unstagedController;
IBOutlet PBWebStashController *stagedController;
}
- (void) showStash:(PBGitStash*)stash;
+21 -4
View File
@@ -7,23 +7,40 @@
//
#import "PBStashContentController.h"
#import "PBGitCommit.h"
#import "PBGitDefaults.h"
#import "PBGitStash.h"
const CGFloat kMinPaneSize = 32.0;
@implementation PBStashContentController
- (void) awakeFromNib
{
[webController setRepository:repository];
[unstagedController setRepository:repository];
[stagedController setRepository:repository];
}
- (void) showStash:(PBGitStash*)stash
{
NSString *stashRef = [NSString stringWithFormat:@"refs/%@", [stash name]];
NSString *stashSha = [repository shaForRef:[PBGitRef refFromString:stashRef]];
PBGitCommit *commit = [PBGitCommit commitWithRepository:repository andSha:stashSha];
NSString *stashSHA = [repository shaForRef:[PBGitRef refFromString:stashRef]];
PBGitCommit *commit = [repository commitForSHA:stashSHA];
NSString *indexSHA = [commit.parents objectAtIndex:1];
PBGitCommit *indexCommit = [repository commitForSHA:indexSHA];
[webController changeContentTo:commit];
[unstagedController changeContentTo:commit];
[stagedController changeContentTo:indexCommit];
}
- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex
{
return kMinPaneSize;
}
- (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex
{
return [splitView frame].size.height - kMinPaneSize;
}
@end
+254 -253
View File
@@ -3,7 +3,7 @@
<data>
<int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">10J869</string>
<string key="IBDocument.InterfaceBuilderVersion">851</string>
<string key="IBDocument.InterfaceBuilderVersion">788</string>
<string key="IBDocument.AppKitVersion">1038.35</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
@@ -15,18 +15,18 @@
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>851</string>
<string>851</string>
<string>788</string>
<string>788</string>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="1"/>
<integer value="21"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.WebKitIBPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.WebKitIBPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -53,63 +53,109 @@
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="WebView" id="917684001">
<object class="NSSplitView" id="996164917">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">274</int>
<object class="NSMutableSet" key="NSDragTypes">
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="set.sortedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>Apple HTML pasteboard type</string>
<string>Apple PDF pasteboard type</string>
<string>Apple PICT pasteboard type</string>
<string>Apple URL pasteboard type</string>
<string>Apple Web Archive pasteboard type</string>
<string>NSColor pasteboard type</string>
<string>NSFilenamesPboardType</string>
<string>NSStringPboardType</string>
<string>NeXT RTFD pasteboard type</string>
<string>NeXT Rich Text Format v1.0 pasteboard type</string>
<string>NeXT TIFF v4.0 pasteboard type</string>
<string>WebURLsWithTitlesPboardType</string>
<string>public.png</string>
<string>public.url</string>
<string>public.url-name</string>
<object class="WebView" id="917684001">
<reference key="NSNextResponder" ref="996164917"/>
<int key="NSvFlags">274</int>
<object class="NSMutableSet" key="NSDragTypes">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="set.sortedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>Apple HTML pasteboard type</string>
<string>Apple PDF pasteboard type</string>
<string>Apple PICT pasteboard type</string>
<string>Apple URL pasteboard type</string>
<string>Apple Web Archive pasteboard type</string>
<string>NSColor pasteboard type</string>
<string>NSFilenamesPboardType</string>
<string>NSStringPboardType</string>
<string>NeXT RTFD pasteboard type</string>
<string>NeXT Rich Text Format v1.0 pasteboard type</string>
<string>NeXT TIFF v4.0 pasteboard type</string>
<string>WebURLsWithTitlesPboardType</string>
<string>public.png</string>
<string>public.url</string>
<string>public.url-name</string>
</object>
</object>
<string key="NSFrameSize">{480, 272}</string>
<reference key="NSSuperview" ref="996164917"/>
<reference key="NSNextKeyView"/>
<string key="FrameName"/>
<string key="GroupName"/>
<object class="WebPreferences" key="Preferences" id="913740547">
<string key="Identifier"/>
<object class="NSMutableDictionary" key="Values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>WebKitDefaultFixedFontSize</string>
<string>WebKitDefaultFontSize</string>
<string>WebKitMinimumFontSize</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="12"/>
<integer value="12"/>
<integer value="1"/>
</object>
</object>
</object>
<bool key="UseBackForwardList">YES</bool>
<bool key="AllowsUndo">YES</bool>
</object>
<object class="WebView" id="1021598825">
<reference key="NSNextResponder" ref="996164917"/>
<int key="NSvFlags">274</int>
<object class="NSMutableSet" key="NSDragTypes">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="set.sortedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>Apple HTML pasteboard type</string>
<string>Apple PDF pasteboard type</string>
<string>Apple PICT pasteboard type</string>
<string>Apple URL pasteboard type</string>
<string>Apple Web Archive pasteboard type</string>
<string>NSColor pasteboard type</string>
<string>NSFilenamesPboardType</string>
<string>NSStringPboardType</string>
<string>NeXT RTFD pasteboard type</string>
<string>NeXT Rich Text Format v1.0 pasteboard type</string>
<string>NeXT TIFF v4.0 pasteboard type</string>
<string>WebURLsWithTitlesPboardType</string>
<string>public.png</string>
<string>public.url</string>
<string>public.url-name</string>
</object>
</object>
<string key="NSFrame">{{0, 282}, {480, 272}}</string>
<reference key="NSSuperview" ref="996164917"/>
<reference key="NSNextKeyView"/>
<string key="FrameName"/>
<string key="GroupName"/>
<reference key="Preferences" ref="913740547"/>
<bool key="UseBackForwardList">YES</bool>
<bool key="AllowsUndo">YES</bool>
</object>
</object>
<string key="NSFrameSize">{480, 272}</string>
<string key="NSFrameSize">{480, 554}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSNextKeyView"/>
<string key="FrameName"/>
<string key="GroupName"/>
<object class="WebPreferences" key="Preferences">
<string key="Identifier"/>
<object class="NSMutableDictionary" key="Values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>WebKitDefaultFixedFontSize</string>
<string>WebKitDefaultFontSize</string>
<string>WebKitMinimumFontSize</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="12"/>
<integer value="12"/>
<integer value="1"/>
</object>
</object>
</object>
<bool key="UseBackForwardList">YES</bool>
<bool key="AllowsUndo">YES</bool>
<int key="NSDividerStyle">3</int>
</object>
</object>
<string key="NSFrameSize">{480, 272}</string>
<string key="NSFrameSize">{480, 554}</string>
<reference key="NSSuperview"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomObject" id="688478824">
<string key="NSClassName">PBWebHistoryController</string>
<string key="NSClassName">PBWebStashController</string>
</object>
<object class="NSCustomObject" id="977952731">
<string key="NSClassName">PBWebStashController</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
@@ -147,14 +193,6 @@
</object>
<int key="connectionID">7</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">webController</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="688478824"/>
</object>
<int key="connectionID">8</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">view</string>
@@ -171,6 +209,78 @@
</object>
<int key="connectionID">10</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">stashController</string>
<reference key="source" ref="688478824"/>
<reference key="destination" ref="1001"/>
</object>
<int key="connectionID">11</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">unstagedController</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="688478824"/>
</object>
<int key="connectionID">12</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">stashController</string>
<reference key="source" ref="977952731"/>
<reference key="destination" ref="1001"/>
</object>
<int key="connectionID">15</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">stagedController</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="977952731"/>
</object>
<int key="connectionID">16</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="977952731"/>
<reference key="destination" ref="1021598825"/>
</object>
<int key="connectionID">22</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">frameLoadDelegate</string>
<reference key="source" ref="1021598825"/>
<reference key="destination" ref="977952731"/>
</object>
<int key="connectionID">23</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">policyDelegate</string>
<reference key="source" ref="1021598825"/>
<reference key="destination" ref="977952731"/>
</object>
<int key="connectionID">24</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">UIDelegate</string>
<reference key="source" ref="1021598825"/>
<reference key="destination" ref="977952731"/>
</object>
<int key="connectionID">25</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="996164917"/>
<reference key="destination" ref="1001"/>
</object>
<int key="connectionID">26</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -204,20 +314,42 @@
<reference key="object" ref="1005"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="917684001"/>
<reference ref="996164917"/>
</object>
<reference key="parent" ref="0"/>
<string key="objectName">Stash</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="917684001"/>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">3</int>
<reference key="object" ref="688478824"/>
<reference key="parent" ref="0"/>
<string key="objectName">Unstaged Controller</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">13</int>
<reference key="object" ref="977952731"/>
<reference key="parent" ref="0"/>
<string key="objectName">Staged Controller</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">21</int>
<reference key="object" ref="996164917"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="917684001"/>
<reference ref="1021598825"/>
</object>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="917684001"/>
<reference key="parent" ref="996164917"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">17</int>
<reference key="object" ref="1021598825"/>
<reference key="parent" ref="996164917"/>
</object>
</object>
</object>
@@ -232,6 +364,9 @@
<string>1.IBPluginDependency</string>
<string>1.WindowOrigin</string>
<string>1.editorWindowContentRectSynchronizationRect</string>
<string>13.IBPluginDependency</string>
<string>17.IBPluginDependency</string>
<string>17.IBViewBoundsToFrameTransform</string>
<string>2.IBPluginDependency</string>
<string>2.IBViewBoundsToFrameTransform</string>
<string>3.IBPluginDependency</string>
@@ -241,10 +376,15 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{14, 862}, {480, 272}}</string>
<string>{{786, 804}, {480, 554}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{628, 654}</string>
<string>{{357, 416}, {480, 272}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.WebKitIBPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">AUJwAABCFAAAA</bytes>
</object>
<string>com.apple.WebKitIBPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">AUJwAABCFAAAA</bytes>
@@ -268,7 +408,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">10</int>
<int key="maxID">26</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -280,158 +420,6 @@
<string key="minorKey">NSApplication+GitXScripting.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">PBGitHistoryController</string>
<string key="superclassName">PBViewController</string>
<object class="NSMutableDictionary" key="actions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>cherryPick:</string>
<string>createBranch:</string>
<string>createTag:</string>
<string>merge:</string>
<string>openFilesAction:</string>
<string>openSelectedFile:</string>
<string>rebase:</string>
<string>refresh:</string>
<string>selectNext:</string>
<string>selectPrevious:</string>
<string>setBranchFilter:</string>
<string>setDetailedView:</string>
<string>setTreeView:</string>
<string>showAddRemoteSheet:</string>
<string>showCommitsFromTree:</string>
<string>showInFinderAction:</string>
<string>toggleQLPreviewPanel:</string>
<string>updateSearch:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>cherryPick:</string>
<string>createBranch:</string>
<string>createTag:</string>
<string>merge:</string>
<string>openFilesAction:</string>
<string>openSelectedFile:</string>
<string>rebase:</string>
<string>refresh:</string>
<string>selectNext:</string>
<string>selectPrevious:</string>
<string>setBranchFilter:</string>
<string>setDetailedView:</string>
<string>setTreeView:</string>
<string>showAddRemoteSheet:</string>
<string>showCommitsFromTree:</string>
<string>showInFinderAction:</string>
<string>toggleQLPreviewPanel:</string>
<string>updateSearch:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBActionInfo">
<string key="name">cherryPick:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">createBranch:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">createTag:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">merge:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">openFilesAction:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">openSelectedFile:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">rebase:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">refresh:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">selectNext:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">selectPrevious:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">setBranchFilter:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">setDetailedView:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">setTreeView:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">showAddRemoteSheet:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">showCommitsFromTree:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">showInFinderAction:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">toggleQLPreviewPanel:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">updateSearch:</string>
<string key="candidateClassName">id</string>
</object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">PBGitHistoryController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">PBGitRepository</string>
<string key="superclassName">NSDocument</string>
@@ -447,12 +435,14 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>webController</string>
<string>stagedController</string>
<string>unstagedController</string>
<string>webView</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>PBWebHistoryController</string>
<string>PBWebStashController</string>
<string>PBWebStashController</string>
<string>id</string>
</object>
</object>
@@ -460,14 +450,19 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>webController</string>
<string>stagedController</string>
<string>unstagedController</string>
<string>webView</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">webController</string>
<string key="candidateClassName">PBWebHistoryController</string>
<string key="name">stagedController</string>
<string key="candidateClassName">PBWebStashController</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">unstagedController</string>
<string key="candidateClassName">PBWebStashController</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">webView</string>
@@ -499,6 +494,25 @@
<string key="minorKey">PBViewController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">PBWebCommitController</string>
<string key="superclassName">PBWebController</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">contextMenuDelegate</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">contextMenuDelegate</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">contextMenuDelegate</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">PBWebCommitController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">PBWebController</string>
<string key="superclassName">NSObject</string>
@@ -540,43 +554,22 @@
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">PBWebHistoryController</string>
<string key="superclassName">PBWebController</string>
<string key="className">PBWebStashController</string>
<string key="superclassName">PBWebCommitController</string>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>contextMenuDelegate</string>
<string>historyController</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>PBGitHistoryController</string>
</object>
<string key="NS.key.0">stashController</string>
<string key="NS.object.0">PBStashContentController</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>contextMenuDelegate</string>
<string>historyController</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">contextMenuDelegate</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">historyController</string>
<string key="candidateClassName">PBGitHistoryController</string>
</object>
<string key="NS.key.0">stashController</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">stashController</string>
<string key="candidateClassName">PBStashContentController</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">PBWebHistoryController.h</string>
<string key="minorKey">PBWebStashController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
@@ -1114,6 +1107,14 @@
<string key="minorKey">AppKit.framework/Headers/NSSearchField.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSSplitView</string>
<string key="superclassName">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSSplitView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSTextField</string>
<string key="superclassName">NSControl</string>
+1
View File
@@ -20,6 +20,7 @@
}
@property (readonly) __weak PBGitRepository *repository;
@property (readonly) __weak PBGitWindowController *superController;
@property(copy) NSString *status;
@property(assign) BOOL isBusy;
+1
View File
@@ -12,6 +12,7 @@
@implementation PBViewController
@synthesize repository;
@synthesize superController;
@synthesize status;
@synthesize isBusy;
+41
View File
@@ -0,0 +1,41 @@
//
// PBWebCommitController.h
//
// Created by David Catmull on 10-06-11.
//
#import <Cocoa/Cocoa.h>
#import "PBWebController.h"
#import "PBRefContextDelegate.h"
@class NSString;
@class PBGitCommit;
// Displays the diff from a commit in the repository.
@interface PBWebCommitController : PBWebController {
IBOutlet id<PBRefContextDelegate> contextMenuDelegate;
NSString* currentSha;
NSString* diff;
}
- (void) changeContentTo: (PBGitCommit *) content;
- (void) sendKey: (NSString*) key;
- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2;
- (void) didLoad;
// Called when a commit or parent link is clicked.
- (void)selectCommit:(NSString *)sha;
// HTML listing refs (branch name, etc) for the displayed commit.
- (NSString*) refsForCurrentCommit;
// Look up a PBGitRef based on its SHA.
- (PBGitRef*) refFromString:(NSString*)refString;
// Choose which parents should be used for the diff
- (NSArray*) chooseDiffParents:(NSArray*)parents;
// Context menu items to be displayed for a file.
- (NSArray*) menuItemsForPath:(NSString*)path;
@property (readonly) NSString* diff;
@end
+361
View File
@@ -0,0 +1,361 @@
//
// PBWebCommitController.m
//
// Created by David Catmull on 10-06-11.
//
#import "PBWebCommitController.h"
#import "PBGitCommit.h"
#import "PBGitDefaults.h"
#import "GLFileView.h"
#import <CommonCrypto/CommonDigest.h>
@interface PBWebCommitController (Private)
- (NSArray *)parseHeader:(NSString *)text;
- (NSString *)htmlForHeader:(NSArray *)header withRefs:(NSString *)badges;
- (NSMutableDictionary *)parseStats:(NSString *)txt;
- (NSString *) arbitraryHashForString:(NSString*)concat;
@end
// -parseHeader: returns an array of dictionaries with these keys
const NSString *kHeaderKeyName = @"name";
const NSString *kHeaderKeyContent = @"content";
// Keys for the author/committer dictionary
const NSString *kAuthorKeyName = @"name";
const NSString *kAuthorKeyEmail = @"email";
const NSString *kAuthorKeyDate = @"date";
@implementation PBWebCommitController
@synthesize diff;
- (void) awakeFromNib
{
startFile = @"history";
[super awakeFromNib];
}
- (void)closeView
{
[[self script] setValue:nil forKey:@"commit"];
[super closeView];
}
- (void) didLoad
{
currentSha = nil;
}
- (void) changeContentTo: (PBGitCommit *) content
{
if (content == nil || !finishedLoading)
return;
currentSha = [content sha];
// Now we load the extended details. We used to do this in a separate thread,
// but this caused some funny behaviour because NSTask's and NSThread's don't really
// like each other. Instead, just do it async.
NSMutableArray *taskArguments = [NSMutableArray arrayWithObjects:@"show", @"--numstat", @"--summary", @"--pretty=raw", currentSha, nil];
if (![PBGitDefaults showWhitespaceDifferences])
[taskArguments insertObject:@"-w" atIndex:1];
NSFileHandle *handle = [repository handleForArguments:taskArguments];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// Remove notification, in case we have another one running
[nc removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:nil];
[nc addObserver:self selector:@selector(commitDetailsLoaded:) name:NSFileHandleReadToEndOfFileCompletionNotification object:handle];
[handle readToEndOfFileInBackgroundAndNotify];
}
- (void)commitDetailsLoaded:(NSNotification *)notification
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:nil];
NSData *data = [[notification userInfo] valueForKey:NSFileHandleNotificationDataItem];
if (!data)
return;
NSString *details = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
if (!details)
details = [[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding];
if (!details)
return;
// Header
NSArray *headerItems = [self parseHeader:details];
NSString *header = [self htmlForHeader:headerItems withRefs:[self refsForCurrentCommit]];
// In case the commit is a merge, we need to explicity give diff-tree the
// list of parents, or else it will yield an empty result.
// If it's not a merge, this won't hurt.
NSMutableArray *allParents = [NSMutableArray array];
for (NSDictionary *item in headerItems)
if ([[item objectForKey:kHeaderKeyName] isEqualToString:@"parent"])
[allParents addObject:[item objectForKey:kHeaderKeyContent]];
NSArray *parents = [self chooseDiffParents:allParents];
// File Stats
NSMutableDictionary *stats = [self parseStats:details];
// File list
NSMutableArray *args = [NSMutableArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", nil];
[args addObjectsFromArray:parents];
[args addObject:currentSha];
NSString *dt = [repository outputInWorkdirForArguments:args];
NSString *fileList = [GLFileView parseDiffTree:dt withStats:stats];
// Diffs list
args = [NSMutableArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", nil];
[args addObjectsFromArray:parents];
[args addObject:currentSha];
NSString *d = [repository outputInWorkdirForArguments:args];
NSString *diffs = [GLFileView parseDiff:d];
NSString *html = [NSString stringWithFormat:@"%@%@<div id='diffs'>%@</div>",header,fileList,diffs];
html = [html stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:[NSString stringWithFormat:@"%@^",currentSha]];
html = [html stringByReplacingOccurrencesOfString:@"{SHA}" withString:currentSha];
[[view windowScriptObject] callWebScriptMethod:@"showCommit" withArguments:[NSArray arrayWithObject:html]];
#ifdef DEBUG_BUILD
NSString *dom = [(DOMHTMLElement*)[[[view mainFrame] DOMDocument] documentElement] outerHTML];
NSString *tmpFile = @"~/tmp/test2.html";
[dom writeToFile:[tmpFile stringByExpandingTildeInPath] atomically:true encoding:NSUTF8StringEncoding error:nil];
#endif
}
- (NSString*) refsForCurrentCommit
{
return @"";
}
- (NSArray*) chooseDiffParents:(NSArray *)parents
{
return parents;
}
- (NSMutableDictionary *)parseStats:(NSString *)txt
{
NSArray *lines = [txt componentsSeparatedByString:@"\n"];
NSMutableDictionary *stats=[NSMutableDictionary dictionary];
int black=0;
for(NSString *line in lines){
if([line length]==0){
black++;
}else if(black==2){
NSArray *file=[line componentsSeparatedByString:@"\t"];
if([file count]==3){
[stats setObject:file forKey:[file objectAtIndex:2]];
}
}
}
return stats;
}
- (NSArray *)parseHeader:(NSString *)text
{
NSMutableArray *result = [NSMutableArray array];
NSArray *lines = [text componentsSeparatedByString:@"\n"];
BOOL parsingSubject = NO;
for (NSString *line in lines) {
if ([line length] == 0) {
if (!parsingSubject)
parsingSubject = TRUE;
else
break;
} else {
if (parsingSubject) {
NSString *trimmedLine = [line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[result addObject:[NSDictionary dictionaryWithObjectsAndKeys:
@"subject", kHeaderKeyName, trimmedLine, kHeaderKeyContent, nil]];
} else {
NSArray *comps = [line componentsSeparatedByString:@" "];
if ([comps count] == 2) {
[result addObject:[NSDictionary dictionaryWithObjectsAndKeys:
[comps objectAtIndex:0], kHeaderKeyName,
[comps objectAtIndex:1], kHeaderKeyContent, nil]];
} else if ([comps count] > 2) {
NSRange r_email_i = [line rangeOfString:@"<"];
NSRange r_email_e = [line rangeOfString:@">"];
NSRange r_name_i = [line rangeOfString:@" "];
NSString *name = [line substringWithRange:NSMakeRange(r_name_i.location,(r_email_i.location-r_name_i.location))];
NSString *email = [line substringWithRange:NSMakeRange(r_email_i.location+1,((r_email_e.location-1)-r_email_i.location))];
NSArray *t=[[line substringFromIndex:r_email_e.location+2] componentsSeparatedByString:@" "];
NSDate *date=[NSDate dateWithTimeIntervalSince1970:[[t objectAtIndex:0] doubleValue]];
NSDictionary *content = [NSDictionary dictionaryWithObjectsAndKeys:
name, kAuthorKeyName,
email, kAuthorKeyEmail,
date, kAuthorKeyDate,
nil];
[result addObject:[NSDictionary dictionaryWithObjectsAndKeys:
[comps objectAtIndex:0], kHeaderKeyName,
content, kHeaderKeyContent,
nil]];
}
}
}
}
return result;
}
- (NSString *)htmlForHeader:(NSArray *)header withRefs:(NSString *)badges
{
NSString *last_mail = @"";
NSMutableString *auths=[NSMutableString string];
NSMutableString *refs=[NSMutableString string];
NSMutableString *subject=[NSMutableString string];
for (NSDictionary *item in header) {
if ([[item objectForKey:kHeaderKeyName] isEqualToString:@"subject"]) {
[subject appendString:[NSString stringWithFormat:@"%@<br/>",[GLFileView escapeHTML:[item objectForKey:kHeaderKeyContent]]]];
}else{
if([[item objectForKey:kHeaderKeyContent] isKindOfClass:[NSString class]]){
[refs appendString:[NSString stringWithFormat:@"<tr><td>%@</td><td><a href='' onclick='selectCommit(this.innerHTML); return false;'>%@</a></td></tr>",[item objectForKey:kHeaderKeyName],[item objectForKey:kHeaderKeyContent]]];
}else{ // NSDictionary: author or committer
NSDictionary *content = [item objectForKey:kHeaderKeyContent];
NSString *email = [content objectForKey:kAuthorKeyEmail];
if(![email isEqualToString:last_mail]){
NSString *name = [content objectForKey:kAuthorKeyName];
NSDate *date = [content objectForKey:kAuthorKeyDate];
NSDateFormatter* theDateFormatter = [[NSDateFormatter alloc] init];
[theDateFormatter setDateStyle:NSDateFormatterMediumStyle];
[theDateFormatter setTimeStyle:NSDateFormatterMediumStyle];
NSString *dateString=[theDateFormatter stringForObjectValue:date];
[auths appendString:[NSString stringWithFormat:@"<div class='user %@ clearfix'>",[item objectForKey:kHeaderKeyName]]];
if([self isFeatureEnabled:@"gravatar"]){
NSString *hash=[self arbitraryHashForString:email];
[auths appendString:[NSString stringWithFormat:@"<img class='avatar' src='http://www.gravatar.com/avatar/%@?d=wavatar&s=30'/>",hash]];
}
[auths appendString:[NSString stringWithFormat:@"<p class='name'>%@ <span class='rol'>(%@)</span></p>",name,[item objectForKey:kHeaderKeyName]]];
[auths appendString:[NSString stringWithFormat:@"<p class='time'>%@</p></div>",dateString]];
}
last_mail=email;
}
}
}
return [NSString stringWithFormat:@"<div id='header' class='clearfix'><table class='references'>%@</table><p class='subject'>%@</p>%@<div id='badges'>%@</div></div>",refs,subject,auths,badges];
}
- (NSString *) arbitraryHashForString:(NSString*)concat {
const char *concat_str = [concat UTF8String];
unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5(concat_str, strlen(concat_str), result);
NSMutableString *hash = [NSMutableString string];
int i;
for (i = 0; i < 16; i++)
[hash appendFormat:@"%02x", result[i]];
return hash;
}
- (void)selectCommit:(NSString *)sha
{
}
// TODO: this is duplicated in PBWebDiffController
- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2
{
NSArray *args=[NSArray arrayWithObjects:@"difftool",@"--no-prompt",@"--tool=opendiff",sha,sha2,@"--",file,nil];
[repository handleInWorkDirForArguments:args];
}
- (void) sendKey: (NSString*) key
{
id script = [view windowScriptObject];
[script callWebScriptMethod:@"handleKeyFromCocoa" withArguments: [NSArray arrayWithObject:key]];
}
- (void) copySource
{
NSString *source = [(DOMHTMLElement *)[[[view mainFrame] DOMDocument] documentElement] outerHTML];
NSPasteboard *a =[NSPasteboard generalPasteboard];
[a declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:self];
[a setString:source forType: NSStringPboardType];
}
- (PBGitRef*) refFromString:(NSString*)refString
{
return nil;
}
- (NSArray*) menuItemsForPath:(NSString*)path
{
return nil;
}
- (NSArray *) webView:(WebView *)sender
contextMenuItemsForElement:(NSDictionary *)element
defaultMenuItems:(NSArray *)defaultMenuItems
{
DOMNode *node = [element valueForKey:@"WebElementDOMNode"];
while (node) {
// Every ref has a class name of 'refs' and some other class. We check on that to see if we pressed on a ref.
if ([[node className] hasPrefix:@"refs "]) {
NSString *selectedRefString = [[[node childNodes] item:0] textContent];
PBGitRef *ref = [self refFromString:selectedRefString];
if (ref != nil)
return [contextMenuDelegate menuItemsForRef:ref];
DLog(@"Could not find selected ref!");
return defaultMenuItems;
}
if ([node hasAttributes] && [[node attributes] getNamedItem:@"representedFile"])
return [self menuItemsForPath:[[[node attributes] getNamedItem:@"representedFile"] value]];
else if ([[node class] isEqual:[DOMHTMLImageElement class]]) {
// Copy Image is the only menu item that makes sense here since we don't need
// to download the image or open it in a new window (besides with the
// current implementation these two entries can crash GitX anyway)
for (NSMenuItem *item in defaultMenuItems)
if ([item tag] == WebMenuItemTagCopyImageToClipboard)
return [NSArray arrayWithObject:item];
return nil;
}
node = [node parentNode];
}
return defaultMenuItems;
}
// Open external links in the default browser
- (void)webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary *)actionInformation
request:(NSURLRequest *)request
newFrameName:(NSString *)frameName
decisionListener:(id < WebPolicyDecisionListener >)listener
{
[[NSWorkspace sharedWorkspace] openURL:[request URL]];
}
- getConfig:(NSString *)config
{
return [repository valueForKeyPath:[@"config." stringByAppendingString:config]];
}
- (void) preferencesChanged
{
[[self script] callWebScriptMethod:@"enableFeatures" withArguments:nil];
}
@end
+1
View File
@@ -10,6 +10,7 @@
#import "PBWebController.h"
#import "PBDiffWindowController.h"
// Instantiated in PBDiffWindow.xib, used by PBDiffWindowController
@interface PBWebDiffController : PBWebController {
IBOutlet PBDiffWindowController *diffController;
}
+4 -21
View File
@@ -1,5 +1,5 @@
//
// PBWebGitController.h
// PBWebHistoryController.h
// GitTest
//
// Created by Pieter de Bie on 14-06-08.
@@ -7,29 +7,12 @@
//
#import <Cocoa/Cocoa.h>
#import "PBWebController.h"
#import "PBWebCommitController.h"
#import "PBGitCommit.h"
#import "PBGitHistoryController.h"
#import "PBRefContextDelegate.h"
@class PBGitHistoryController;
@class NSString;
@interface PBWebHistoryController : PBWebController {
@interface PBWebHistoryController : PBWebCommitController {
IBOutlet PBGitHistoryController* historyController;
IBOutlet id<PBRefContextDelegate> contextMenuDelegate;
NSString* currentSha;
NSString* diff;
}
- (void) changeContentTo: (PBGitCommit *) content;
- (void) sendKey: (NSString*) key;
- (NSString *)parseHeader:(NSString *)txt withRefs:(NSString *)badges;
- (NSMutableDictionary *)parseStats:(NSString *)txt;
- (NSString *) someMethodThatReturnsSomeHashForSomeString:(NSString*)concat;
- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2;
@property (readonly) NSString* diff;
@end
+12 -240
View File
@@ -1,5 +1,5 @@
//
// PBWebGitController.m
// PBWebHistoryController.m
// GitTest
//
// Created by Pieter de Bie on 14-06-08.
@@ -8,13 +8,10 @@
#import "PBWebHistoryController.h"
#import "PBGitDefaults.h"
#import "GLFileView.h"
#import <CommonCrypto/CommonDigest.h>
#import "PBGitHistoryController.h"
@implementation PBWebHistoryController
@synthesize diff;
- (void) awakeFromNib
{
startFile = @"history";
@@ -33,7 +30,7 @@
- (void) didLoad
{
currentSha = nil;
[super didLoad];
[self changeContentTo: historyController.webCommit];
}
@@ -45,45 +42,8 @@
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
- (void) changeContentTo: (PBGitCommit *) content
- (NSString*) refsForCurrentCommit
{
if (content == nil || !finishedLoading)
return;
currentSha = [content sha];
// Now we load the extended details. We used to do this in a separate thread,
// but this caused some funny behaviour because NSTask's and NSThread's don't really
// like each other. Instead, just do it async.
NSMutableArray *taskArguments = [NSMutableArray arrayWithObjects:@"show", @"--numstat", @"--summary", @"--pretty=raw", currentSha, nil];
if (![PBGitDefaults showWhitespaceDifferences])
[taskArguments insertObject:@"-w" atIndex:1];
NSFileHandle *handle = [repository handleForArguments:taskArguments];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// Remove notification, in case we have another one running
[nc removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:nil];
[nc addObserver:self selector:@selector(commitDetailsLoaded:) name:NSFileHandleReadToEndOfFileCompletionNotification object:handle];
[handle readToEndOfFileInBackgroundAndNotify];
}
- (void)commitDetailsLoaded:(NSNotification *)notification
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSFileHandleReadToEndOfFileCompletionNotification object:nil];
NSData *data = [[notification userInfo] valueForKey:NSFileHandleNotificationDataItem];
if (!data)
return;
NSString *details = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
if (!details)
details = [[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding];
if (!details)
return;
NSMutableString *refs = [NSMutableString string];
NSArray *refsA = [historyController.webCommit refs];
NSString *currentRef = [[[historyController repository] headRef] simpleRef];
@@ -97,125 +57,7 @@
[refs appendString:[NSString stringWithFormat:@"<span class='%@'>%@</span>",style,[ref shortName]]];
}
// Header
NSString *header = [self parseHeader:details withRefs:refs];
// File Stats
NSMutableDictionary *stats = [self parseStats:details];
// File list
NSString *dt = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", currentSha, nil]];
NSString *fileList = [GLFileView parseDiffTree:dt withStats:stats];
// Diffs list
NSString *d = [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", currentSha, nil]];
NSString *diffs = [GLFileView parseDiff:d];
NSString *html = [NSString stringWithFormat:@"%@%@<div id='diffs'>%@</div>",header,fileList,diffs];
html = [html stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:[NSString stringWithFormat:@"%@^",currentSha]];
html = [html stringByReplacingOccurrencesOfString:@"{SHA}" withString:currentSha];
[[view windowScriptObject] callWebScriptMethod:@"showCommit" withArguments:[NSArray arrayWithObject:html]];
#ifdef DEBUG_BUILD
NSString *dom = [(DOMHTMLElement*)[[[view mainFrame] DOMDocument] documentElement] outerHTML];
NSString *tmpFile = @"~/tmp/test2.html";
[dom writeToFile:[tmpFile stringByExpandingTildeInPath] atomically:true encoding:NSUTF8StringEncoding error:nil];
#endif
}
- (NSMutableDictionary *)parseStats:(NSString *)txt
{
NSArray *lines = [txt componentsSeparatedByString:@"\n"];
NSMutableDictionary *stats=[NSMutableDictionary dictionary];
int black=0;
for(NSString *line in lines){
if([line length]==0){
black++;
}else if(black==2){
NSArray *file=[line componentsSeparatedByString:@"\t"];
if([file count]==3){
[stats setObject:file forKey:[file objectAtIndex:2]];
}
}
}
return stats;
}
- (NSString *)parseHeader:(NSString *)txt withRefs:(NSString *)badges
{
NSArray *lines = [txt componentsSeparatedByString:@"\n"];
NSString *line;
NSString *last_mail=@"";
NSMutableString *auths=[NSMutableString string];
NSMutableString *refs=[NSMutableString string];
NSMutableString *subject=[NSMutableString string];
BOOL subj=FALSE;
int i;
for (i=0; i<[lines count]; i++) {
line=[lines objectAtIndex:i];
if([line length]==0){
if(!subj){
subj=TRUE;
}else{
i=[lines count];
}
}else{
if (subj) {
NSString *trimmedLine = [line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[subject appendString:[NSString stringWithFormat:@"%@<br/>",[GLFileView escapeHTML:trimmedLine]]];
}else{
NSArray *comps=[line componentsSeparatedByString:@" "];
if([comps count]==2){
[refs appendString:[NSString stringWithFormat:@"<tr><td>%@</td><td><a href='' onclick='selectCommit(this.innerHTML); return false;'>%@</a></td></tr>",[comps objectAtIndex:0],[comps objectAtIndex:1]]];
}else if([comps count]>2){
NSRange r_email_i = [line rangeOfString:@"<"];
NSRange r_email_e = [line rangeOfString:@">"];
NSRange r_name_i = [line rangeOfString:@" "];
NSString *rol=[line substringToIndex:r_name_i.location];
NSString *name=[line substringWithRange:NSMakeRange(r_name_i.location,(r_email_i.location-r_name_i.location))];
NSString *email=[line substringWithRange:NSMakeRange(r_email_i.location+1,((r_email_e.location-1)-r_email_i.location))];
NSArray *t=[[line substringFromIndex:r_email_e.location+2] componentsSeparatedByString:@" "];
NSDate *date=[NSDate dateWithTimeIntervalSince1970:[[t objectAtIndex:0] doubleValue]];
NSDateFormatter* theDateFormatter = [[NSDateFormatter alloc] init];
[theDateFormatter setDateStyle:NSDateFormatterMediumStyle];
[theDateFormatter setTimeStyle:NSDateFormatterMediumStyle];
NSString *dateString=[theDateFormatter stringForObjectValue:date];
if(![email isEqualToString:last_mail]){
[auths appendString:[NSString stringWithFormat:@"<div class='user %@ clearfix'>",rol]];
if([self isFeatureEnabled:@"gravatar"]){
NSString *hash=[self someMethodThatReturnsSomeHashForSomeString:email];
[auths appendString:[NSString stringWithFormat:@"<img class='avatar' src='http://www.gravatar.com/avatar/%@?d=wavatar&s=30'/>",hash]];
}
[auths appendString:[NSString stringWithFormat:@"<p class='name'>%@ <span class='rol'>(%@)</span></p>",name,rol]];
[auths appendString:[NSString stringWithFormat:@"<p class='time'>%@</p></div>",dateString]];
}
last_mail=email;
}
}
}
}
return [NSString stringWithFormat:@"<div id='header' class='clearfix'><table class='references'>%@</table><p class='subject'>%@</p>%@<div id='badges'>%@</div></div>",refs,subject,auths,badges];
}
- (NSString *) someMethodThatReturnsSomeHashForSomeString:(NSString*)concat {
const char *concat_str = [concat UTF8String];
unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5(concat_str, strlen(concat_str), result);
NSMutableString *hash = [NSMutableString string];
int i;
for (i = 0; i < 16; i++)
[hash appendFormat:@"%02x", result[i]];
return hash;
return refs;
}
- (void)selectCommit:(NSString *)sha
@@ -223,87 +65,17 @@
[historyController selectCommit:sha];
}
// TODO: need to be refactoring
- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2
- (PBGitRef*) refFromString:(NSString*)refString
{
NSArray *args=[NSArray arrayWithObjects:@"difftool",@"--no-prompt",@"--tool=opendiff",sha,sha2,@"--",file,nil];
[historyController.repository handleInWorkDirForArguments:args];
for (PBGitRef *ref in historyController.webCommit.refs)
if ([[ref shortName] isEqualToString:refString])
return ref;
return nil;
}
- (void) sendKey: (NSString*) key
- (NSArray*) menuItemsForPath:(NSString*)path
{
id script = [view windowScriptObject];
[script callWebScriptMethod:@"handleKeyFromCocoa" withArguments: [NSArray arrayWithObject:key]];
}
- (void) copySource
{
NSString *source = [(DOMHTMLElement *)[[[view mainFrame] DOMDocument] documentElement] outerHTML];
NSPasteboard *a =[NSPasteboard generalPasteboard];
[a declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:self];
[a setString:source forType: NSStringPboardType];
}
- (NSArray *) webView:(WebView *)sender
contextMenuItemsForElement:(NSDictionary *)element
defaultMenuItems:(NSArray *)defaultMenuItems
{
DOMNode *node = [element valueForKey:@"WebElementDOMNode"];
while (node) {
// Every ref has a class name of 'refs' and some other class. We check on that to see if we pressed on a ref.
if ([[node className] hasPrefix:@"refs "]) {
NSString *selectedRefString = [[[node childNodes] item:0] textContent];
for (PBGitRef *ref in historyController.webCommit.refs)
{
if ([[ref shortName] isEqualToString:selectedRefString])
return [contextMenuDelegate menuItemsForRef:ref];
}
DLog(@"Could not find selected ref!");
return defaultMenuItems;
}
if ([node hasAttributes] && [[node attributes] getNamedItem:@"representedFile"])
return [historyController menuItemsForPaths:[NSArray arrayWithObject:[[[node attributes] getNamedItem:@"representedFile"] value]]];
else if ([[node class] isEqual:[DOMHTMLImageElement class]]) {
// Copy Image is the only menu item that makes sense here since we don't need
// to download the image or open it in a new window (besides with the
// current implementation these two entries can crash GitX anyway)
for (NSMenuItem *item in defaultMenuItems)
if ([item tag] == WebMenuItemTagCopyImageToClipboard)
return [NSArray arrayWithObject:item];
return nil;
}
node = [node parentNode];
}
return defaultMenuItems;
}
// Open external links in the default browser
- (void)webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary *)actionInformation
request:(NSURLRequest *)request
newFrameName:(NSString *)frameName
decisionListener:(id < WebPolicyDecisionListener >)listener
{
[[NSWorkspace sharedWorkspace] openURL:[request URL]];
}
- getConfig:(NSString *)config
{
return [historyController valueForKeyPath:[@"repository.config." stringByAppendingString:config]];
}
- (void)finalize
{
[super finalize];
}
- (void) preferencesChanged
{
[[self script] callWebScriptMethod:@"enableFeatures" withArguments:nil];
return [historyController menuItemsForPaths:[NSArray arrayWithObject:path]];
}
@end
+16
View File
@@ -0,0 +1,16 @@
//
// PBWebStashController.h
//
// Created by David Catmull on 12-06-11.
//
#import <Cocoa/Cocoa.h>
#import "PBWebCommitController.h"
@class PBStashContentController;
@interface PBWebStashController : PBWebCommitController {
IBOutlet PBStashContentController *stashController;
}
@end
+27
View File
@@ -0,0 +1,27 @@
//
// PBWebStashController.m
//
// Created by David Catmull on 12-06-11.
//
#import "PBWebStashController.h"
#import "PBStashContentController.h"
@implementation PBWebStashController
- (void)selectCommit:(NSString *)sha
{
[[stashController superController] selectCommitForSha:sha];
}
- (NSArray*) menuItemsForPath:(NSString*)path
{
return [[stashController superController] menuItemsForPaths:[NSArray arrayWithObject:path]];
}
- (NSArray*) chooseDiffParents:(NSArray *)parents
{
return [NSArray arrayWithObject:[parents lastObject]];
}
@end
+1 -1
View File
@@ -32,7 +32,7 @@ function HighlightAllOccurencesOfStringForElement(element,keyword) {
} else if (element.nodeType == 1) { // Element node
if (element.style.display != "none" && element.nodeName.toLowerCase() != 'select') {
for (var i=0; i<element.childNodes.length; i++) {
if((element.childNodes[i].nodeType==1)
if (element.childNodes[i].nodeType==1)
alert("-->"+element.childNodes[i].getAttribute('class'));
HighlightAllOccurencesOfStringForElement(element.childNodes[i],keyword);
}