revlog: fix descendants() if nullrev is in revs stable
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Sun, 07 Nov 2010 18:23:48 +0900
branchstable
changeset 12950 2405b4a5964a
parent 12949 6878eaa5a40d
child 12951 101366ad816c
revlog: fix descendants() if nullrev is in revs We were not returning the correct result if nullrev was in revs, as we are checking parent(currentrev) != nullrev before yielding currentrev test-convert-hg-startrev was wrong: if we start converting from rev -1 and onwards, all the descendants of -1 (full repo) should be converted.
mercurial/revlog.py
tests/test-convert-hg-startrev.t
--- a/mercurial/revlog.py	Sun Nov 07 18:16:07 2010 +0900
+++ b/mercurial/revlog.py	Sun Nov 07 18:23: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)
--- a/tests/test-convert-hg-startrev.t	Sun Nov 07 18:16:07 2010 +0900
+++ b/tests/test-convert-hg-startrev.t	Sun Nov 07 18:23: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