Commits

Jens Alfke committed d3c6eb4

* Fix incompatibility with hg 1.5.
* Add some error handling to HgRepository.
* Force 4-char indentation on all source files.
* Stop building the BWToolkit IB plugin, which we don't need.

Comments (0)

Files changed (3)

Murky.xcodeproj/project.pbxproj

 			remoteGlobalIDString = 53DF68FD067E5B5A0090B5B0;
 			remoteInfo = BWToolkitFramework;
 		};
-		733DC59D10FC6D320009CD00 /* PBXContainerItemProxy */ = {
+		27AF15471152882200BBA2B7 /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
 			containerPortal = 27874BFF10FBCE3800F0B178 /* BWToolkit.xcodeproj */;
 			proxyType = 1;
-			remoteGlobalIDString = 53DF6901067E5B8E0090B5B0;
-			remoteInfo = All;
+			remoteGlobalIDString = 53DF68FC067E5B5A0090B5B0 /* BWToolkitFramework */;
+			remoteInfo = BWToolkitFramework;
 		};
 /* End PBXContainerItemProxy section */
 
 				277C50920C55BCB800E60690 /* MercurialApp.m */,
 				27C657A70FAEA82300CFB909 /* MainMenu.xib */,
 			);
+			indentWidth = 4;
 			name = "User Interface";
 			path = Source;
 			sourceTree = "<group>";
 				27D124F50C8F501B0075446A /* URLFormatter.m */,
 				32CA4F630368D1EE00C91783 /* Murky_Prefix.pch */,
 			);
+			indentWidth = 4;
 			name = Support;
 			path = Source;
 			sourceTree = "<group>";
 				275938710C9321CF0088FFF4 /* HgProject.h */,
 				275938720C9321CF0088FFF4 /* HgProject.m */,
 			);
+			indentWidth = 4;
 			name = Model;
 			path = Source;
 			sourceTree = "<group>";
 			buildRules = (
 			);
 			dependencies = (
-				733DC59E10FC6D320009CD00 /* PBXTargetDependency */,
+				27AF15481152882200BBA2B7 /* PBXTargetDependency */,
 			);
 			name = Murky;
 			productInstallPath = "$(HOME)/Applications";
 /* End PBXSourcesBuildPhase section */
 
 /* Begin PBXTargetDependency section */
-		733DC59E10FC6D320009CD00 /* PBXTargetDependency */ = {
+		27AF15481152882200BBA2B7 /* PBXTargetDependency */ = {
 			isa = PBXTargetDependency;
-			name = All;
-			targetProxy = 733DC59D10FC6D320009CD00 /* PBXContainerItemProxy */;
+			name = BWToolkitFramework;
+			targetProxy = 27AF15471152882200BBA2B7 /* PBXContainerItemProxy */;
 		};
 /* End PBXTargetDependency section */
 

Source/HgLogOperation.m

 
 - (BOOL) _parseFullXML
 {
-    // workaround for xml.style not emitting its footer:
     NSMutableData *xmlData = [self.outputData mutableCopy];
-    [xmlData appendData: [@"</repository>" dataUsingEncoding: NSUTF8StringEncoding]];
+  
+    // workaround for xml.style not emitting its footer in hg versions earlier than 1.5:
+    static const char* const kFooter = "</repository>";
+    size_t length = xmlData.length, footerLength = strlen(kFooter);
+    if (length < footerLength 
+            || memcmp((char*)xmlData.bytes + length - footerLength, kFooter, footerLength) != 0) {
+        LogTo(HgLog, @"Working around missing XML footer in log output");
+        [xmlData appendBytes: kFooter length: footerLength];
+    }
         
     // Parse XML output:
     NSError *error = nil;
                                                        error: &error];
     if( ! xml ) {
         [xmlData writeToFile: @"/tmp/Murky.out" options: 0 error: nil];
-        return [self makeError: @"HgLogOperation couldn't parse XML: %@",error];
+        Warn(@"HgLogOperation couldn't parse 'hg log' output (see /tmp/Murky.out): %@", error);
+        return [self makeError: @"HgLogOperation couldn't parse 'hg log' output:\n%@",error];
     }
     NSXMLElement *root = xml.rootElement;
     

Source/HgRepository.m

                                                                    mode: mode];
         if( curTip >= 0 )
             op.range = NSMakeRange(curTip+1, tip-curTip); // only need to ask about the new revisions
-        if( ! [op run] )
+        if( ! [op run] ) {
+            //FIX: It's bad design to pop up UI from within model code. Especially a blocking alert!
+            // But it's important to notify the user if the 'hg log' failed. Probably the best solution
+            // is to add a 'delegate' property that can be notified of errors.
+            [NSApp presentError: op.error];
             return NO;
+        }
         Assert([[op.revisions objectAtIndex: 0] localNumber]==curTip+1,
                   @"Unexpected revision numbers from log: expected starting %u, got %u", 
                   curTip+1, [[op.revisions objectAtIndex: 0] localNumber]);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.