Commits

Jens Alfke committed 7f420b0

Fix issue #11: mangled revision graph after pull, causing infinite loop.

Comments (0)

Files changed (2)

Source/HgLogOperation.m

     if( revNo < 0 )
         return nil;
     NSArray *revs = _repository.revisions;
-    if( revNo < revs.count )
-        return [revs objectAtIndex: revNo];
-    else
-        return [_revsByNumber objectForKey: [NSNumber numberWithInt: revNo]];
+    if( revNo < revs.count ) {
+        HgRevision *rev = [revs objectAtIndex: revNo];
+        if (!rev.isUncommitted)
+            return rev;
+    }
+    return [_revsByNumber objectForKey: [NSNumber numberWithInt: revNo]];
 }
 
 

Source/HgRevision.m

 //
 
 #import "HgRevision.h"
+#import "HgUncommittedRevision.h"
 #import "HgDir.h"
 #import "HgRepository.h"
 #import "HgLogOperation.h"
 
 @synthesize repository=_repository, localNumber=_localNumber, identifier=_identifier;
 @synthesize comment=_comment, author=_author, email=_email, date=_date;
-@synthesize parent=_parent, parent2=_parent2;
 
 - (NSArray*) parents
 {
 }
 
 
+#if 0
+//@synthesize parent=_parent, parent2=_parent2;
+#else // add some sanity checks (see issue #11)
+- (HgRevision*) parent  {return _parent;}
+- (HgRevision*) parent2 {return _parent2;}
+
+- (void) setParent: (HgRevision*)parent {
+    if (parent != _parent) {
+        if (parent) {
+            NSParameterAssert(parent!=self);
+            NSParameterAssert(parent!=_parent2);
+            NSParameterAssert(!parent.isUncommitted);
+        }
+        [_parent release];
+        _parent = [parent retain];
+    }
+}
+
+- (void) setParent2: (HgRevision*)parent {
+    if (parent != _parent2) {
+        if (parent) {
+            NSParameterAssert(parent!=self);
+            NSParameterAssert(parent!=_parent);
+            NSParameterAssert(!parent.isUncommitted);
+        }
+        [_parent2 release];
+        _parent2 = [parent retain];
+    }
+}
+#endif
+
+
 - (BOOL) descendsFrom: (HgRevision*)ancestor
 {
     for( HgRevision *rev=self; rev; rev=rev->_parent ) {