[PATCH 2 of 2 STABLE] revlog: fix descendants() if nullrev is in revs

Nicolas Dumazet nicdumz at gmail.com
Sun Nov 7 06:06:42 CST 2010


# HG changeset patch
# User Nicolas Dumazet <nicdumz.commits at gmail.com>
# Date 1289121828 -32400
# Branch stable
# Node ID 6f5498bfa7e5dd80cc29521d7fce95c6c5465650
# Parent  eef3494b814709d36f7ba25cdb4b127701552856
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.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -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)
diff --git a/tests/test-convert-hg-startrev.t b/tests/test-convert-hg-startrev.t
--- a/tests/test-convert-hg-startrev.t
+++ b/tests/test-convert-hg-startrev.t
@@ -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
 


More information about the Mercurial-devel mailing list