merge with stable
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Tue, 09 Nov 2010 01:33:48 +0900
changeset 12952 f6b88f3bcc03
parent 12948 de6a28ff5ffc (current diff)
parent 12951 101366ad816c (diff)
child 12954 85777aab7e08
merge with stable
--- a/mercurial/graphmod.py	Sun Nov 07 22:03:28 2010 +0900
+++ b/mercurial/graphmod.py	Tue Nov 09 01:33:48 2010 +0900
@@ -32,7 +32,7 @@
     cur = start
     while cur >= stop:
         ctx = repo[cur]
-        parents = [p.rev() for p in ctx.parents() if p.rev() != nullrev]
+        parents = set([p.rev() for p in ctx.parents() if p.rev() != nullrev])
         yield (cur, CHANGESET, ctx, sorted(parents))
         cur -= 1
 
@@ -47,7 +47,7 @@
     count = 0
     while filerev >= 0 and rev > stop:
         fctx = repo.filectx(path, fileid=filerev)
-        parents = [f.linkrev() for f in fctx.parents() if f.path() == path]
+        parents = set([f.linkrev() for f in fctx.parents() if f.path() == path])
         rev = fctx.rev()
         if rev <= start:
             yield (rev, CHANGESET, fctx.changectx(), sorted(parents))
@@ -65,7 +65,7 @@
     include = set(nodes)
     for node in nodes:
         ctx = repo[node]
-        parents = [p.rev() for p in ctx.parents() if p.node() in include]
+        parents = set([p.rev() for p in ctx.parents() if p.node() in include])
         yield (ctx.rev(), CHANGESET, ctx, sorted(parents))
 
 def colored(dag):
--- a/mercurial/revlog.py	Sun Nov 07 22:03:28 2010 +0900
+++ b/mercurial/revlog.py	Tue Nov 09 01:33:48 2010 +0900
@@ -607,8 +607,14 @@
         some rev in revs, i.e., each revision is *not* considered a
         descendant of itself.  Results are ordered by revision number (a
         topological sort)."""
+        first = min(revs)
+        if first == nullrev:
+            for i in self:
+                yield i
+            return
+
         seen = set(revs)
-        for i in xrange(min(revs) + 1, len(self)):
+        for i in xrange(first + 1, len(self)):
             for x in self.parentrevs(i):
                 if x != nullrev and x in seen:
                     seen.add(i)
@@ -869,6 +875,8 @@
         return c
 
     def descendant(self, start, end):
+        if start == nullrev:
+            return True
         for i in self.descendants(start):
             if i == end:
                 return True
--- a/tests/test-convert-hg-startrev.t	Sun Nov 07 22:03:28 2010 +0900
+++ b/tests/test-convert-hg-startrev.t	Tue Nov 09 01:33:48 2010 +0900
@@ -39,13 +39,32 @@
 
 Convert from null revision
 
-  $ hg convert --config convert.hg.startrev=null source empty
-  initializing destination empty repository
+  $ hg convert --config convert.hg.startrev=null source full
+  initializing destination full repository
   scanning source...
   sorting...
   converting...
+  5 0: add a b
+  4 1: add c
+  3 2: copy e from a, change b
+  2 3: change a
+  1 4: merge 2 and 3, copy d from b
+  0 5: change a
 
-  $ glog empty
+  $ glog full
+  o  5 "5: change a" files: a
+  |
+  o    4 "4: merge 2 and 3, copy d from b" files: d e
+  |\
+  | o  3 "3: change a" files: a
+  | |
+  o |  2 "2: copy e from a, change b" files: b e
+  | |
+  o |  1 "1: add c" files: c
+  |/
+  o  0 "0: add a b" files: a b
+  
+  $ rm -Rf full
 
 Convert from zero revision
 
--- a/tests/test-glog.t	Sun Nov 07 22:03:28 2010 +0900
+++ b/tests/test-glog.t	Tue Nov 09 01:33:48 2010 +0900
@@ -887,3 +887,39 @@
   | |  summary:     (33) head
   | |
 
+Do not crash or produce strange graphs if history is buggy
+
+  $ commit 36 "buggy merge: identical parents" 35 35
+  $ hg glog -l5
+  @  changeset:   36:95fa8febd08a
+  |  tag:         tip
+  |  parent:      35:9159c3644c5e
+  |  parent:      35:9159c3644c5e
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:36 1970 +0000
+  |  summary:     (36) buggy merge: identical parents
+  |
+  o  changeset:   35:9159c3644c5e
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     0
+  |
+  o  changeset:   34:fea3ac5810e0
+  |  parent:      32:d06dffa21a31
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:34 1970 +0000
+  |  summary:     (34) head
+  |
+  | o  changeset:   33:68608f5145f9
+  | |  parent:      18:1aa84d96232a
+  | |  user:        test
+  | |  date:        Thu Jan 01 00:00:33 1970 +0000
+  | |  summary:     (33) head
+  | |
+  o |    changeset:   32:d06dffa21a31
+  |\ \   parent:      27:886ed638191b
+  | | |  parent:      31:621d83e11f67
+  | | |  user:        test
+  | | |  date:        Thu Jan 01 00:00:32 1970 +0000
+  | | |  summary:     (32) expand
+  | | |