changeset 3923:27230c29bfec 0.9.3

fix calculation of new heads added during push with -r fix issue450
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sun, 17 Dec 2006 05:00:22 +0100
parents 5f0e00224cde
children b27f1da6ca88
files mercurial/localrepo.py mercurial/revlog.py tests/test-push-warn tests/test-push-warn.out
diffstat 4 files changed, 30 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sat Dec 16 23:33:24 2006 +0100
+++ b/mercurial/localrepo.py	Sun Dec 17 05:00:22 2006 +0100
@@ -1392,7 +1392,7 @@
                 newheads = list(heads)
                 for r in remote_heads:
                     if r in self.changelog.nodemap:
-                        desc = self.changelog.heads(r)
+                        desc = self.changelog.heads(r, heads)
                         l = [h for h in heads if h in desc]
                         if not l:
                             newheads.append(r)
--- a/mercurial/revlog.py	Sat Dec 16 23:33:24 2006 +0100
+++ b/mercurial/revlog.py	Sun Dec 17 05:00:22 2006 +0100
@@ -717,15 +717,19 @@
         assert heads
         return (orderedout, roots, heads)
 
-    def heads(self, start=None):
+    def heads(self, start=None, stop=None):
         """return the list of all nodes that have no children
 
         if start is specified, only heads that are descendants of
         start will be returned
-
+        if stop is specified, it will consider all the revs from stop
+        as if they had no children
         """
         if start is None:
             start = nullid
+        if stop is None:
+            stop = []
+        stoprevs = dict.fromkeys([self.rev(n) for n in stop])
         startrev = self.rev(start)
         reachable = {startrev: 1}
         heads = {startrev: 1}
@@ -734,10 +738,12 @@
         for r in xrange(startrev + 1, self.count()):
             for p in parentrevs(r):
                 if p in reachable:
-                    reachable[r] = 1
+                    if r not in stoprevs:
+                        reachable[r] = 1
                     heads[r] = 1
-                if p in heads:
+                if p in heads and p not in stoprevs:
                     del heads[p]
+
         return [self.node(r) for r in heads]
 
     def children(self, node):
--- a/tests/test-push-warn	Sat Dec 16 23:33:24 2006 +0100
+++ b/tests/test-push-warn	Sun Dec 17 05:00:22 2006 +0100
@@ -54,4 +54,9 @@
 hg push -f -r 3 -r 4 ../c; echo $?
 hg push -r 5 ../c; echo $?
 
+# issue 450
+hg init ../e
+hg push -r 0 ../e ; echo $?
+hg push -r 1 ../e ; echo $?
+
 exit 0
--- a/tests/test-push-warn.out	Sat Dec 16 23:33:24 2006 +0100
+++ b/tests/test-push-warn.out	Sun Dec 17 05:00:22 2006 +0100
@@ -62,3 +62,17 @@
 adding file changes
 added 1 changesets with 1 changes to 1 files (-1 heads)
 0
+pushing to ../e
+searching for changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+0
+pushing to ../e
+searching for changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+0