Merge remote branch 'refs/remotes/rastersize/master' into experimental

Conflicts:
	PBGitRepository.h
	PBGitSidebarController.m
	PBSourceViewCell.h
	PBSourceViewCell.m
This commit is contained in:
German Laullom
2011-01-27 16:45:11 -08:00
25 changed files with 547 additions and 373 deletions
+96 -31
View File
@@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">10H574</string>
<string key="IBDocument.InterfaceBuilderVersion">804</string>
<string key="IBDocument.SystemVersion">10J567</string>
<string key="IBDocument.InterfaceBuilderVersion">851</string>
<string key="IBDocument.AppKitVersion">1038.35</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<string key="IBDocument.HIToolboxVersion">462.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">804</string>
<string key="NS.object.0">851</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -43,6 +43,37 @@
<int key="NSvFlags">268</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSButton" id="604563603">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{18, 193}, {158, 18}}</string>
<reference key="NSSuperview" ref="1005"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="254305730">
<int key="NSCellFlags">-2080244224</int>
<int key="NSCellFlags2">0</int>
<string key="NSContents">Refresh automatically</string>
<object class="NSFont" key="NSSupport" id="734450335">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<reference key="NSControlView" ref="604563603"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">2</int>
<object class="NSCustomResource" key="NSNormalImage" id="136676346">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSSwitch</string>
</object>
<object class="NSButtonImageSource" key="NSAlternateImage" id="690089052">
<string key="NSImageName">NSSwitch</string>
</object>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
</object>
<object class="NSTextField" id="63761450">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
@@ -53,11 +84,7 @@
<int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">272630784</int>
<string key="NSContents">Reset all dialog warnings:</string>
<object class="NSFont" key="NSSupport" id="734450335">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<reference key="NSSupport" ref="734450335"/>
<reference key="NSControlView" ref="63761450"/>
<object class="NSColor" key="NSBackgroundColor" id="124675276">
<int key="NSColorSpace">6</int>
@@ -160,13 +187,8 @@
<reference key="NSControlView" ref="968361983"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">2</int>
<object class="NSCustomResource" key="NSNormalImage" id="114317419">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSSwitch</string>
</object>
<object class="NSButtonImageSource" key="NSAlternateImage" id="690089052">
<string key="NSImageName">NSSwitch</string>
</object>
<reference key="NSNormalImage" ref="136676346"/>
<reference key="NSAlternateImage" ref="690089052"/>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">200</int>
@@ -274,7 +296,7 @@
<reference key="NSControlView" ref="910887184"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="114317419"/>
<reference key="NSNormalImage" ref="136676346"/>
<reference key="NSAlternateImage" ref="690089052"/>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
@@ -285,7 +307,7 @@
<object class="NSButton" id="160081910">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{18, 193}, {279, 18}}</string>
<string key="NSFrame">{{18, 218}, {279, 18}}</string>
<reference key="NSSuperview" ref="1005"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="876763316">
@@ -296,7 +318,7 @@
<reference key="NSControlView" ref="160081910"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="114317419"/>
<reference key="NSNormalImage" ref="136676346"/>
<reference key="NSAlternateImage" ref="690089052"/>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
@@ -307,7 +329,7 @@
<object class="NSButton" id="68472633">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{18, 218}, {207, 18}}</string>
<string key="NSFrame">{{18, 243}, {207, 18}}</string>
<reference key="NSSuperview" ref="1005"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="456188813">
@@ -318,7 +340,7 @@
<reference key="NSControlView" ref="68472633"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="114317419"/>
<reference key="NSNormalImage" ref="136676346"/>
<reference key="NSAlternateImage" ref="690089052"/>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
@@ -327,7 +349,7 @@
</object>
</object>
</object>
<string key="NSFrameSize">{400, 254}</string>
<string key="NSFrameSize">{401, 279}</string>
<reference key="NSSuperview"/>
<string key="NSClassName">NSView</string>
</object>
@@ -366,7 +388,7 @@
<reference key="NSControlView" ref="250497668"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="114317419"/>
<reference key="NSNormalImage" ref="136676346"/>
<reference key="NSAlternateImage" ref="690089052"/>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
@@ -506,7 +528,7 @@
<integer value="2"/>
</object>
</object>
<string key="NS.format">EEEE, MMMM d, yyyy h:mm:ss a</string>
<string key="NS.format">EEEE, dd MMMM, yyyy HH:mm:ss </string>
<bool key="NS.natural">NO</bool>
</object>
<reference key="NSControlView" ref="1045127964"/>
@@ -557,7 +579,7 @@
<reference key="NSControlView" ref="890810109"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="114317419"/>
<reference key="NSNormalImage" ref="136676346"/>
<reference key="NSAlternateImage" ref="690089052"/>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
@@ -573,6 +595,10 @@
<string key="NSClassName">SUUpdater</string>
</object>
<object class="NSUserDefaultsController" id="557723770">
<object class="NSMutableArray" key="NSDeclaredKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>PBRefreshAutomatically</string>
</object>
<bool key="NSSharedInstance">YES</bool>
</object>
<object class="NSCustomView" id="263788152">
@@ -594,7 +620,7 @@
<reference key="NSControlView" ref="237556568"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="114317419"/>
<reference key="NSNormalImage" ref="136676346"/>
<reference key="NSAlternateImage" ref="690089052"/>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
@@ -616,7 +642,7 @@
<reference key="NSControlView" ref="485413225"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="114317419"/>
<reference key="NSNormalImage" ref="136676346"/>
<reference key="NSAlternateImage" ref="690089052"/>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
@@ -638,7 +664,7 @@
<reference key="NSControlView" ref="933582906"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="114317419"/>
<reference key="NSNormalImage" ref="136676346"/>
<reference key="NSAlternateImage" ref="690089052"/>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
@@ -660,7 +686,7 @@
<reference key="NSControlView" ref="766070942"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="114317419"/>
<reference key="NSNormalImage" ref="136676346"/>
<reference key="NSAlternateImage" ref="690089052"/>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
@@ -1079,6 +1105,22 @@
</object>
<int key="connectionID">140</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: values.PBRefreshAutomatically</string>
<reference key="source" ref="604563603"/>
<reference key="destination" ref="557723770"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="604563603"/>
<reference key="NSDestination" ref="557723770"/>
<string key="NSLabel">value: values.PBRefreshAutomatically</string>
<string key="NSBinding">value</string>
<string key="NSKeyPath">values.PBRefreshAutomatically</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">144</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -1124,6 +1166,7 @@
<reference ref="25030403"/>
<reference ref="83909567"/>
<reference ref="63761450"/>
<reference ref="604563603"/>
</object>
<reference key="parent" ref="0"/>
<string key="objectName">General</string>
@@ -1543,6 +1586,20 @@
<reference key="object" ref="265220935"/>
<reference key="parent" ref="83909567"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">141</int>
<reference key="object" ref="604563603"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="254305730"/>
</object>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">142</int>
<reference key="object" ref="254305730"/>
<reference key="parent" ref="604563603"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -1581,6 +1638,9 @@
<string>138.IBPluginDependency</string>
<string>139.IBPluginDependency</string>
<string>14.IBPluginDependency</string>
<string>141.IBPluginDependency</string>
<string>141.IBViewBoundsToFrameTransform</string>
<string>142.IBPluginDependency</string>
<string>15.IBEditorWindowLastContentRect</string>
<string>15.IBPluginDependency</string>
<string>16.IBPluginDependency</string>
@@ -1623,7 +1683,7 @@
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{845, 630}, {400, 254}}</string>
<string>{{511, 548}, {401, 279}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableArray">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1672,6 +1732,11 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAADBcAAAw3QAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{443, 712}, {103, 71}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1735,7 +1800,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">140</int>
<int key="maxID">144</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
+5
View File
@@ -36,6 +36,11 @@
+(BOOL)isStartDiff:(NSString *)line;
+(BOOL)isStartBlock:(NSString *)line;
+(NSArray *)getFilesNames:(NSString *)line;
+(BOOL)isBinaryFile:(NSString *)line;
+(NSString*)mimeTypeForFileName:(NSString*)file;
+(BOOL)isImage:(NSString*)file;
@property(retain) NSMutableArray *groups;
@property(retain) NSString *logFormat;
+41 -19
View File
@@ -181,7 +181,6 @@
- (void)scopeBar:(MGScopeBar *)theScopeBar selectedStateChanged:(BOOL)selected forItem:(NSString *)identifier inGroup:(int)groupNumber
{
NSLog(@"startFile=%@ identifier=%@ groupNumber=%d",startFile,identifier,groupNumber);
if((groupNumber==0) && (startFile!=identifier)){
NSString *path = [NSString stringWithFormat:@"html/views/%@", identifier];
NSString *html = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:path];
@@ -238,11 +237,10 @@
NSArray *lines = [txt componentsSeparatedByString:@"\n"];
NSMutableString *res=[NSMutableString string];
[res appendString:@"<table id='filelist'>"];
int i;
for (i=1; i<[lines count]; i++) {
NSString *line=[lines objectAtIndex:i];
NSArray *fields=[line componentsSeparatedByString:@" "];
NSArray *fileStatus=[[fields objectAtIndex:4] componentsSeparatedByString:@"\t"];
for (NSString *line in lines) {
if([line length]<98) continue;
line=[line substringFromIndex:97];
NSArray *fileStatus=[line componentsSeparatedByString:@"\t"];
NSString *status=[[fileStatus objectAtIndex:0] substringToIndex:1]; // ignore the score
NSString *file=[fileStatus objectAtIndex:1];
NSString *txt=file;
@@ -255,7 +253,6 @@
NSArray *stat=[stats objectForKey:fileName];
NSInteger add=[[stat objectAtIndex:0] integerValue];
NSInteger rem=[[stat objectAtIndex:1] integerValue];
NSInteger tot=add+rem;
[res appendString:@"<tr><td class='name'>"];
[res appendString:[NSString stringWithFormat:@"<a class='%@' href='#%@' representedFile='%@'>%@</a>",status,file,fileName,txt]];
@@ -280,8 +277,8 @@
BOOL inDiff=FALSE;
BOOL inBlock=FALSE;
int l_int,l_line,l_end;
int r_int,r_line,r_end;
int l_line,l_end;
int r_line,r_end;
int i;
for (i=0; i<[lines count]; i++) {
line=[lines objectAtIndex:i];
@@ -297,12 +294,12 @@
NSArray *pos_l=[[pos objectAtIndex:0] componentsSeparatedByString:@","];
NSArray *pos_r=[[pos objectAtIndex:1] componentsSeparatedByString:@","];
l_end=l_line=l_int=abs([[pos_l objectAtIndex:0]integerValue]);
l_end=l_line=abs([[pos_l objectAtIndex:0]integerValue]);
if ([pos_l count]>1) {
l_end=l_line+[[pos_l objectAtIndex:1]integerValue];
}
r_end=r_line=r_int=[[pos_r objectAtIndex:0]integerValue];
r_end=r_line=[[pos_r objectAtIndex:0]integerValue];
if ([pos_r count]>1) {
r_end=r_line+[[pos_r objectAtIndex:1]integerValue];
}
@@ -331,17 +328,19 @@
}else if(inDiff){
[res appendString:[NSString stringWithFormat:@"<p>%@</p>",line]];
if([self isBinaryFile:line]){
NSLog(@"line='%@'",line);
[res appendString:@"</td></tr></thead><tbody>"];
NSArray *files=[self getFilesNames:line];
NSLog(@"files='%@'",files);
if(![[files objectAtIndex:0] isAbsolutePath]){
[res appendString:[NSString stringWithFormat:@"<tr><td colspan='3'>%@</td></tr>",[files objectAtIndex:0]]];
[res appendString:[NSString stringWithFormat:@"<tr><td colspan='3'><img src='GitX://{SHA}:/prev/%@'/></td></tr>",[files objectAtIndex:0]]];
if([GLFileView isImage:[files objectAtIndex:0]]){
[res appendString:[NSString stringWithFormat:@"<tr><td colspan='3'><img src='GitX://{SHA}:/prev/%@'/></td></tr>",[files objectAtIndex:0]]];
}
}
if(![[files objectAtIndex:1] isAbsolutePath]){
[res appendString:[NSString stringWithFormat:@"<tr><td colspan='3'>%@</td></tr>",[files objectAtIndex:1]]];
[res appendString:[NSString stringWithFormat:@"<tr><td colspan='3'><img src='GitX://{SHA}/%@'/></td></tr>",[files objectAtIndex:1]]];
if([GLFileView isImage:[files objectAtIndex:1]]){
[res appendString:[NSString stringWithFormat:@"<tr><td colspan='3'><img src='GitX://{SHA}/%@'/></td></tr>",[files objectAtIndex:1]]];
}
}
}
}
@@ -360,9 +359,8 @@
+(NSArray *)getFilesNames:(NSString *)line
{
NSString *a;
NSString *b;
NSLog(@"line='%@'",line);
NSString *a = nil;
NSString *b = nil;
NSScanner *scanner=[NSScanner scannerWithString:line];
if([scanner scanString:@"Binary files " intoString:NULL]){
[scanner scanUpToString:@" and" intoString:&a];
@@ -375,10 +373,34 @@
if (![b isAbsolutePath]) {
b=[b substringFromIndex:2];
}
return [NSArray arrayWithObjects:a,b,nil];
}
+(NSString*)mimeTypeForFileName:(NSString*)name
{
NSString *mimeType = nil;
NSInteger i=[name rangeOfString:@"." options:NSBackwardsSearch].location;
if(i!=NSNotFound){
NSString *ext=[name substringFromIndex:i+1];
CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (CFStringRef)ext, NULL);
if(UTI){
CFStringRef registeredType = UTTypeCopyPreferredTagWithClass(UTI, kUTTagClassMIMEType);
if(registeredType){
mimeType = NSMakeCollectable(registeredType);
}
CFRelease(UTI);
}
}
return mimeType;
}
+(BOOL)isImage:(NSString*)file
{
NSString *mimeType=[GLFileView mimeTypeForFileName:file];
return (mimeType!=nil) && ([mimeType rangeOfString:@"image/" options:NSCaseInsensitiveSearch].location!=NSNotFound);
}
+(BOOL)isBinaryFile:(NSString *)line
{
return (([line length]>12) && [[line substringToIndex:12] isEqualToString:@"Binary files"]);
+4
View File
@@ -1804,10 +1804,12 @@
GCC_ENABLE_OBJC_GC = required;
GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = DEBUG_BUILD;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_PREPROCESS = YES;
PREBINDING = NO;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
};
name = Debug;
@@ -1821,11 +1823,13 @@
x86_64,
);
GCC_ENABLE_OBJC_GC = required;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_PREFIX_HEADER = $PROJECT_TEMP_DIR/revision;
INFOPLIST_PREPROCESS = YES;
PREBINDING = NO;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
};
name = Release;
+2
View File
@@ -18,6 +18,7 @@
+ (BOOL) confirmPublicGists;
+ (BOOL) isGistPublic;
+ (BOOL)showWhitespaceDifferences;
+ (BOOL)refreshAutomatically;
+ (BOOL)openCurDirOnLaunch;
+ (BOOL)showOpenPanelOnLaunch;
+ (BOOL) shouldCheckoutBranch;
@@ -41,4 +42,5 @@
+ (BOOL)isDialogWarningSuppressedForDialog:(NSString *)dialog;
+ (void)resetAllDialogWarnings;
@end
+17 -8
View File
@@ -17,6 +17,7 @@
#define kConfirmPublicGists @"PBConfirmPublicGists"
#define kPublicGist @"PBGistPublic"
#define kShowWhitespaceDifferences @"PBShowWhitespaceDifferences"
#define kRefreshAutomatically @"PBRefreshAutomatically"
#define kOpenCurDirOnLaunch @"PBOpenCurDirOnLaunch"
#define kShowOpenPanelOnLaunch @"PBShowOpenPanelOnLaunch"
#define kShouldCheckoutBranch @"PBShouldCheckoutBranch"
@@ -28,6 +29,7 @@
#define kHistorySearchMode @"PBHistorySearchMode"
#define kSuppressedDialogWarnings @"Suppressed Dialog Warnings"
@implementation PBGitDefaults
+ (void)initialize
@@ -38,19 +40,21 @@
[defaultValues setObject:[NSNumber numberWithBool:YES]
forKey:kCommitMessageViewHasVerticalLine];
[defaultValues setObject:[NSNumber numberWithBool:YES]
forKey:kEnableGist];
forKey:kEnableGist];
[defaultValues setObject:[NSNumber numberWithBool:YES]
forKey:kEnableGravatar];
forKey:kEnableGravatar];
[defaultValues setObject:[NSNumber numberWithBool:YES]
forKey:kConfirmPublicGists];
forKey:kConfirmPublicGists];
[defaultValues setObject:[NSNumber numberWithBool:NO]
forKey:kPublicGist];
forKey:kPublicGist];
[defaultValues setObject:[NSNumber numberWithBool:YES]
forKey:kShowWhitespaceDifferences];
forKey:kShowWhitespaceDifferences];
[defaultValues setObject:[NSNumber numberWithBool:YES]
forKey:kOpenCurDirOnLaunch];
forKey:kRefreshAutomatically];
[defaultValues setObject:[NSNumber numberWithBool:YES]
forKey:kShowOpenPanelOnLaunch];
forKey:kOpenCurDirOnLaunch];
[defaultValues setObject:[NSNumber numberWithBool:YES]
forKey:kShowOpenPanelOnLaunch];
[defaultValues setObject:[NSNumber numberWithBool:YES]
forKey:kShouldCheckoutBranch];
[defaultValues setObject:[NSNumber numberWithBool:NO]
@@ -90,10 +94,15 @@
return [[NSUserDefaults standardUserDefaults] boolForKey:kPublicGist];
}
+ (BOOL)showWhitespaceDifferences
+ (BOOL) showWhitespaceDifferences
{
return [[NSUserDefaults standardUserDefaults] boolForKey:kShowWhitespaceDifferences];
}
+ (BOOL) refreshAutomatically
{
return [[NSUserDefaults standardUserDefaults] boolForKey:kRefreshAutomatically];
}
+ (BOOL)openCurDirOnLaunch
{
+1 -1
View File
@@ -287,7 +287,7 @@
- (BOOL) haveRefsBeenModified
{
[repository reloadRefs];
//[repository reloadRefs];
NSMutableSet *currentRefSHAs = [NSMutableSet setWithArray:[repository.refs allKeys]];
[currentRefSHAs minusSet:lastRefSHAs];
+1 -1
View File
@@ -146,8 +146,8 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) {
- (void)findInModeScriptCommand:(NSScriptCommand *)command;
-(NSNumber *)countCommintsOf:(NSString *)branchs;
+(bool)isLocalBranch:(NSString *)name;
- (NSMenu *) menu;
+(bool)isLocalBranch:(NSString *)branch branchNameInto:(NSString **)name;
@property (assign) BOOL hasChanged;
@property (readonly) PBGitWindowController *windowController;
+6 -17
View File
@@ -300,10 +300,6 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
PBGitRef *newRef = [PBGitRef refFromString:[components objectAtIndex:0]];
PBGitRevSpecifier *revSpec = [[PBGitRevSpecifier alloc] initWithRef:newRef];
if([PBGitRepository isLocalBranch:[components objectAtIndex:0]]){
[revSpec setAhead:[self countCommintsOf:[NSString stringWithFormat:@"origin..%@",[components objectAtIndex:0]]]];
[revSpec setBehind:[self countCommintsOf:[NSString stringWithFormat:@"%@..origin",[components objectAtIndex:0]]]];
}
[self addBranch:revSpec];
[self addRef:newRef fromParameters:components];
[oldBranches removeObject:revSpec];
@@ -322,21 +318,14 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
[[[self windowController] window] setTitle:[self displayName]];
}
+(bool)isLocalBranch:(NSString *)name
+(bool)isLocalBranch:(NSString *)branch branchNameInto:(NSString **)name
{
NSScanner *scanner=[NSScanner scannerWithString:name];
return [scanner scanString:@"refs/heads/" intoString:NULL];
}
-(NSNumber *)countCommintsOf:(NSString *)branchs
{
NSArray *args = [NSArray arrayWithObjects:@"rev-list", branchs, nil];
NSString *o = [self outputForArguments:args];
if ([o length]==0) {
return NULL;
NSScanner *scanner=[NSScanner scannerWithString:branch];
bool is=[scanner scanString:@"refs/heads/" intoString:NULL];
if(is && (name)){
*name=[branch substringFromIndex:[scanner scanLocation]];
}
NSArray *commits = [o componentsSeparatedByString:@"\n"];
return [NSNumber numberWithInt:[commits count]];
return is;
}
- (void) lazyReload
+7 -1
View File
@@ -11,9 +11,15 @@
@interface PBGitSVBranchItem : PBSourceViewItem {
BOOL isCheckedOut;
NSNumber *behind;
NSNumber *ahead;
}
+ (id)branchItemWithRevSpec:(PBGitRevSpecifier *)revSpecifier;
@property (assign) BOOL isCheckedOut;
@property (assign) NSNumber *behind;
@property (assign) NSNumber *ahead;
@end
+15
View File
@@ -11,6 +11,8 @@
@implementation PBGitSVBranchItem
@synthesize isCheckedOut;
@synthesize behind,ahead;
+ (id)branchItemWithRevSpec:(PBGitRevSpecifier *)revSpecifier
{
@@ -30,4 +32,17 @@
return branchImage;
}
- (NSString *) badge{
NSMutableString *badge=nil;
if(isCheckedOut || ahead || behind){
badge=[NSMutableString string];
if(isCheckedOut) [badge appendString:@""];
if(ahead) [badge appendFormat:@"+%@",ahead];
if(behind) [badge appendFormat:@"-%@",behind];
}
return badge;
}
@end
+3 -1
View File
@@ -11,9 +11,11 @@
@interface PBGitSVRemoteItem : PBSourceViewItem {
BOOL alert;
}
@property (assign) BOOL alert;
+ (id)remoteItemWithTitle:(NSString *)title;
@end
+5
View File
@@ -12,6 +12,7 @@
@implementation PBGitSVRemoteItem
@synthesize alert;
+ (id)remoteItemWithTitle:(NSString *)title
{
@@ -38,4 +39,8 @@
return [PBGitRef refFromString:[kGitXRemoteRefPrefix stringByAppendingString:self.title]];
}
- (NSString *)badge
{
return (alert ? @"!" : nil);
}
@end
+3
View File
@@ -47,6 +47,9 @@
- (void)setHistorySearch:(NSString *)searchString mode:(NSInteger)mode;
-(NSNumber *)countCommintsOf:(NSString *)range;
-(bool)remoteNeedFetch:(NSString *)remote;
@property(readonly) NSMutableArray *items;
@property(readonly) NSView *sourceListControlsView;
@property(readonly) PBGitHistoryController *historyViewController;
+42 -11
View File
@@ -61,6 +61,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged";
historyViewController = [[PBGitHistoryController alloc] initWithRepository:repository superController:superController];
commitViewController = [[PBGitCommitController alloc] initWithRepository:repository superController:superController];
[repository addObserver:self forKeyPath:@"refs" options:0 context:@"updateRefs"];
[repository addObserver:self forKeyPath:@"currentBranch" options:0 context:@"currentBranchChange"];
[repository addObserver:self forKeyPath:@"branches" options:(NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew) context:@"branchesModified"];
[repository addObserver:self forKeyPath:@"stashController.stashes" options:NSKeyValueObservingOptionNew context:kObservingContextStashes];
@@ -96,7 +97,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged";
if ([@"currentBranchChange" isEqualToString:context]) {
[sourceView reloadData];
[self selectCurrentBranch];
} else if ([@"branchesModified" isEqualToString:context]) {
}else if ([@"branchesModified" isEqualToString:context]) {
NSInteger changeKind = [(NSNumber *)[change objectForKey:NSKeyValueChangeKindKey] intValue];
if (changeKind == NSKeyValueChangeInsertion) {
@@ -147,11 +148,49 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged";
[sourceView PBExpandItem:item expandParents:YES];
}
[sourceView reloadData];
} else {
}else if ([@"updateRefs" isEqualToString:context]) {
for(PBGitSVRemoteItem* remote in [remotes children]){
NSLog(@"remote.title=%@",[remote title]);
[remote setAlert:[self remoteNeedFetch:[remote title]]];
}
for(PBGitSVBranchItem* branch in [branches children]){
NSString *bName=[branch title];
[branch setAhead:[self countCommintsOf:[NSString stringWithFormat:@"origin/%@..%@",bName,bName]]];
[branch setBehind:[self countCommintsOf:[NSString stringWithFormat:@"%@..origin/%@",bName,bName]]];
[branch setIsCheckedOut:[branch.revSpecifier isEqual:[repository headRef]]];
}
}else{
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
#pragma mark Badges Methods
-(NSNumber *)countCommintsOf:(NSString *)range
{
NSArray *args = [NSArray arrayWithObjects:@"rev-list", range, nil];
int ret;
NSString *o = [repository outputForArguments:args retValue:&ret];
if ((ret!=0) || ([o length]==0)) {
return NULL;
}
NSArray *commits = [o componentsSeparatedByString:@"\n"];
return [NSNumber numberWithInt:[commits count]];
}
-(bool)remoteNeedFetch:(NSString *)remote
{
int ret;
NSArray *args = [NSArray arrayWithObjects:@"fetch", @"--dry-run", remote, nil];
NSString *o = [repository outputForArguments:args retValue:&ret];
return ((ret==0) && ([o length]!=0));
}
#pragma mark -----
- (PBSourceViewItem *) selectedItem
{
NSInteger index = [sourceView selectedRow];
@@ -284,15 +323,6 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged";
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(PBSourceViewCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(PBSourceViewItem *)item
{
if(item.revSpecifier!=NULL){
cell.isCheckedOut = [item.revSpecifier isEqual:[repository headRef]];
cell.behind=[item.revSpecifier behind];
cell.ahead=[item.revSpecifier ahead];
}else{
cell.behind=nil;
cell.ahead=nil;
}
BOOL showsActionButton = NO;
if ([item respondsToSelector:@selector(showsActionButton)]) {
showsActionButton = [item showsActionButton];
@@ -301,6 +331,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged";
}
cell.showsActionButton = showsActionButton;
[cell setBadge:[item badge]];
[cell setImage:[item icon]];
}
+15 -5
View File
@@ -131,7 +131,9 @@
if(error==nil){
res=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"blame", @"-p", sha, @"--", [self fullPath], nil]];
}else{
*anError = [NSError errorWithDomain:@"blame" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]];
if (anError != NULL) {
*anError = [NSError errorWithDomain:@"blame" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]];
}
}
return res;
@@ -147,7 +149,9 @@
if(error==nil){
res=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"log", [NSString stringWithFormat:@"--pretty=format:%@",format], @"--", [self fullPath], nil]];
}else{
*anError = [NSError errorWithDomain:@"log" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]];
if (anError != NULL) {
*anError = [NSError errorWithDomain:@"log" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]];
}
}
return res;
@@ -178,12 +182,16 @@
res=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff", sha, des,[self fullPath], nil]];
if ([res length]==0) {
NSLog(@"--%d",[res length]);
*anError = [NSError errorWithDomain:@"diff" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"No Diff",NSLocalizedDescriptionKey,nil]];
if (anError != NULL) {
*anError = [NSError errorWithDomain:@"diff" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"No Diff",NSLocalizedDescriptionKey,nil]];
}
}else{
NSLog(@"--%@",[res substringToIndex:80]);
}
}else{
*anError = [NSError errorWithDomain:@"diff" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]];
if (anError != NULL) {
*anError = [NSError errorWithDomain:@"diff" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]];
}
}
return res;
@@ -205,7 +213,9 @@
if(error==nil){
res = [self contents];
}else{
*anError = [NSError errorWithDomain:@"show" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]];
if (anError != NULL) {
*anError = [NSError errorWithDomain:@"show" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:error,NSLocalizedDescriptionKey,nil]];
}
}
return res;
-2
View File
@@ -25,8 +25,6 @@
IBOutlet NSTextField *statusField;
IBOutlet NSProgressIndicator *progressIndicator;
PBViewController* viewController;
IBOutlet NSToolbarItem *terminalItem;
IBOutlet NSToolbarItem *finderItem;
}
+9
View File
@@ -9,6 +9,7 @@
#import "PBGitWindowController.h"
#import "PBGitHistoryController.h"
#import "PBGitCommitController.h"
#import "PBGitDefaults.h"
#import "Terminal.h"
#import "PBCloneRepsitoryToSheet.h"
#import "PBCommitHookFailedSheet.h"
@@ -132,6 +133,14 @@
[[NSAlert alertWithError:error] beginSheetModalForWindow:[self window] modalDelegate:self didEndSelector:nil contextInfo:nil];
}
- (void)windowDidBecomeKey:(NSNotification *)notification
{
if ([PBGitDefaults refreshAutomatically]) {
[contentController refresh:nil];
}
}
- (void)showErrorSheetTitle:(NSString *)title message:(NSString *)message arguments:(NSArray *)arguments output:(NSString *)output
{
NSString *command = [arguments componentsJoinedByString:@" "];
+3 -8
View File
@@ -9,22 +9,17 @@
#import <Cocoa/Cocoa.h>
#import "PBIconAndTextCell.h"
@interface PBSourceViewCell : PBIconAndTextCell {
BOOL isCheckedOut;
NSNumber *behind;
NSNumber *ahead;
BOOL showsActionButton;
BOOL iMouseDownInInfoButton;
BOOL iMouseHoveredInInfoButton;
SEL iInfoButtonAction;
NSString *badge;
}
@property (nonatomic) BOOL showsActionButton;
@property (nonatomic) SEL iInfoButtonAction;
@property (assign) BOOL isCheckedOut;
@property (assign) NSNumber *behind;
@property (assign) NSNumber *ahead;
@property (assign) NSString *badge;
@end
+3 -7
View File
@@ -17,10 +17,10 @@
@implementation PBSourceViewCell
@synthesize iInfoButtonAction;
@synthesize isCheckedOut;
@synthesize behind,ahead;
@synthesize showsActionButton;
@synthesize badge;
# pragma mark context menu delegate methods
- init {
@@ -45,11 +45,7 @@
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)outlineView
{
if(behind || ahead || isCheckedOut){
NSMutableString *badge=[NSMutableString string];
if(isCheckedOut) [badge appendString:@""];
if(ahead) [badge appendFormat:@"+%@",ahead];
if(behind) [badge appendFormat:@"-%@",behind];
if(badge){
NSImage *checkedOutImage = [PBSourceViewBadge badge:badge forCell:self];
NSSize imageSize = [checkedOutImage size];
NSRect imageFrame;
+2
View File
@@ -29,6 +29,8 @@
+ (id)itemWithRevSpec:(PBGitRevSpecifier *)revSpecifier;
+ (id)itemWithTitle:(NSString *)title;
- (NSString *)badge;
- (void)addChild:(PBSourceViewItem *)child;
- (void)removeChild:(PBSourceViewItem *)child;
+5
View File
@@ -110,6 +110,11 @@
return nil;
}
- (NSString *)badge
{
return nil;
}
- (NSImage *) icon
{
return nil;
+1 -1
View File
@@ -37,6 +37,6 @@
- (void)viewLoaded;
- (NSResponder *)firstResponder;
- (IBAction) refresh:(id)sender;
- (IBAction) refresh:(id)sender;
@end
+5 -4
View File
@@ -44,15 +44,16 @@
return nil;
}
- (IBAction) refresh: sender
{
}
// The next methods should be implemented in the subclass if necessary
- (void)updateView
{
}
- (IBAction) refresh:(id)sender
{
return;
}
- (void)viewLoaded
{
}
+256 -256
View File
@@ -1,256 +1,256 @@
/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for more info.
*/
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
/*
* Perform a simple self-test to see if the VM is working
*/
function md5_vm_test()
{
return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length
*/
function core_md5(x, len)
{
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for(var i = 0; i < x.length; i += 16)
{
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return Array(a, b, c, d);
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5_cmn(q, a, b, x, s, t)
{
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t)
{
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t)
{
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t)
{
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t)
{
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
/*
* Calculate the HMAC-MD5, of a key and some data
*/
function core_hmac_md5(key, data)
{
var bkey = str2binl(key);
if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
var ipad = Array(16), opad = Array(16);
for(var i = 0; i < 16; i++)
{
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
return core_md5(opad.concat(hash), 512 + 128);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function bit_rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt));
}
/*
* Convert a string to an array of little-endian words
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
*/
function str2binl(str)
{
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz)
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
return bin;
}
/*
* Convert an array of little-endian words to a string
*/
function binl2str(bin)
{
var str = "";
var mask = (1 << chrsz) - 1;
for(var i = 0; i < bin.length * 32; i += chrsz)
str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
return str;
}
/*
* Convert an array of little-endian words to a hex string.
*/
function binl2hex(binarray)
{
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
}
return str;
}
/*
* Convert an array of little-endian words to a base-64 string
*/
function binl2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for(var i = 0; i < binarray.length * 4; i += 3)
{
var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
| (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
| ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
}
}
return str;
}
/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for more info.
*/
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
/*
* Perform a simple self-test to see if the VM is working
*/
function md5_vm_test()
{
return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length
*/
function core_md5(x, len)
{
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for(var i = 0; i < x.length; i += 16)
{
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return Array(a, b, c, d);
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5_cmn(q, a, b, x, s, t)
{
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t)
{
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t)
{
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t)
{
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t)
{
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
/*
* Calculate the HMAC-MD5, of a key and some data
*/
function core_hmac_md5(key, data)
{
var bkey = str2binl(key);
if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
var ipad = Array(16), opad = Array(16);
for(var i = 0; i < 16; i++)
{
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
return core_md5(opad.concat(hash), 512 + 128);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function bit_rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt));
}
/*
* Convert a string to an array of little-endian words
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
*/
function str2binl(str)
{
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz)
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
return bin;
}
/*
* Convert an array of little-endian words to a string
*/
function binl2str(bin)
{
var str = "";
var mask = (1 << chrsz) - 1;
for(var i = 0; i < bin.length * 32; i += chrsz)
str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
return str;
}
/*
* Convert an array of little-endian words to a hex string.
*/
function binl2hex(binarray)
{
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
}
return str;
}
/*
* Convert an array of little-endian words to a base-64 string
*/
function binl2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for(var i = 0; i < binarray.length * 4; i += 3)
{
var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
| (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
| ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
}
}
return str;
}