Commits

Jens Alfke committed 80efc51

* Fixed HgRepository to work correctly in a newly-created repository with no committed revisions.
* In rev log display, don't link to email addr unless it contains an '@' sign.

Comments (0)

Files changed (4)

Add a comment to this file

English.lproj/InfoPlist.strings

Binary file modified.

Resources/Info.plist

 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>
-	<string>0.5</string>
+	<string>0.5++</string>
 	<key>CFBundleGetInfoString</key>
-	<string>0.5; © Jens Alfke, 2008-2009</string>
+	<string>0.5++; © Jens Alfke, 2008-2009</string>
 	<key>NSMainNibFile</key>
 	<string>MainMenu</string>
 	<key>NSPrincipalClass</key>

Source/HgRepository.m

 }    
 
 
+/** Returns the local revision number of the tip, or NSNotFound if there are no revisions */
 - (int) _getTip
 {
     NSArray *revs = [self _getRevNumbers: @"tip"];
     if( revs.count > 1 )
         return [[revs objectAtIndex: 0] intValue];
     else
-        return -1;
+        return NSNotFound;
 }
 
 
+/** Gets the parent(s) of the current revision. Returns NO on failure.
+    *outRev2 will be -1 unless the current revision is a merge.
+    *outRev1 will be -1 if the repository is new and has no committed revisions yet. */
 - (BOOL) _getParent1: (int*)outRev1 parent2: (int*)outRev2
 {
     *outRev1 = *outRev2 = -1;
             str = [revs objectAtIndex: 1];
             if( str.length > 0 )
                 *outRev2 = str.intValue;
-            return YES;
         }
+        return YES;
     }
     return NO;
 }    
 
     // Run "hg tip" to get tip revision number:
     int tip = [self _getTip];
-    if( tip<0 )
+    if( tip==NSNotFound )
         return NO;
     
-    int curTip = _revisions.count>0 ?self.tipRevision.localNumber :-1;
+    HgRevision *tipRevision = self.tipRevision;
+    int curTip = tipRevision ?tipRevision.localNumber :-1;
     if( tip != curTip ) {
         // Revisions have changed!
-        LogTo(HgRepository,@"Tip changed from %i to %i ... updating revisions", curTip,tip);
+        LogTo(HgRepository,@"_checkRevisions: Tip changed from %i to %i ... updating revisions", curTip,tip);
 
         // Run "hg log" to get all revisions of this repository:
         if (!_revisions)
         
     } else if( curRevNo != _uncommittedRevision.parent.localNumber || curParent2 != parent2) {
         // A different revision is current; or the parents have changed
+        LogTo(HgRepository, @"_checkRevisions: Current revision changed to %i/%i", curRevNo,curParent2);
         [self willChangeValueForKey: @"revisions"];
-        _currentRevision = [_revisions objectAtIndex: curRevNo];
+        _currentRevision = curRevNo>=0 ?[_revisions objectAtIndex: curRevNo] :nil;
         _uncommittedRevision.parent = _currentRevision;
         _uncommittedRevision.parent2 = curParent2>=0 ?[_revisions objectAtIndex: curParent2] :nil;
+        if (_revisions.count==0)
+            _revisions = $array(_uncommittedRevision);
         [self didChangeValueForKey: @"revisions"];
         [self _checkWorkingTree: &error];
         return YES;
+    } else {
+        LogTo(HgRepository,@"_checkRevisions: No change");
     }
     return NO;
 }

Source/HgRevision.m

     }
     
     NSURL *email = nil;
-    if (self.email) {
+    if ([self.email rangeOfString: @"@"].length > 0) {
         NSString *name = [self.repository.name stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
         email = [NSURL URLWithString: $sprintf(@"mailto:%@?subject=Re:%%20%@",
                  self.email, name)];
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.