Rev 3057: Special case Graph.heads() for NULL_REVISION rather than is_ancestor. in http://bzr.arbash-meinel.com/branches/bzr/0.93-dev/pull_set_last_revision_info_172970

John Arbash Meinel john at arbash-meinel.com
Sat Dec 1 01:12:54 GMT 2007


At http://bzr.arbash-meinel.com/branches/bzr/0.93-dev/pull_set_last_revision_info_172970

------------------------------------------------------------
revno: 3057
revision-id:john at arbash-meinel.com-20071201011228-3aqhvy1wtc305nn4
parent: john at arbash-meinel.com-20071130232718-9e3thvmobvj799br
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: pull_set_last_revision_info_172970
timestamp: Fri 2007-11-30 19:12:28 -0600
message:
  Special case Graph.heads() for NULL_REVISION rather than is_ancestor.
modified:
  bzrlib/graph.py                graph_walker.py-20070525030359-y852guab65d4wtn0-1
  bzrlib/tests/test_graph.py     test_graph_walker.py-20070525030405-enq4r60hhi9xrujc-1
-------------- next part --------------
=== modified file 'bzrlib/graph.py'
--- a/bzrlib/graph.py	2007-11-30 15:20:15 +0000
+++ b/bzrlib/graph.py	2007-12-01 01:12:28 +0000
@@ -242,6 +242,11 @@
             order if they need it.
         """
         candidate_heads = set(keys)
+        if revision.NULL_REVISION in candidate_heads:
+            # NULL_REVISION is only a head if it is the only entry
+            candidate_heads.remove(revision.NULL_REVISION)
+            if not candidate_heads:
+                return set([revision.NULL_REVISION])
         if len(candidate_heads) < 2:
             return candidate_heads
         searchers = dict((c, self._make_breadth_first_searcher([c]))
@@ -348,13 +353,6 @@
         smallest number of parent looksup to determine the ancestral
         relationship between N revisions.
         """
-        if revision.is_null(candidate_ancestor):
-            return True
-        if revision.is_null(candidate_descendant):
-            # if candidate_descendant is NULL_REVISION, then only
-            # candidate_ancestor == NULL_REVISION is an ancestor, but we've
-            # already handled that case.
-            return False
         return set([candidate_descendant]) == self.heads(
             [candidate_ancestor, candidate_descendant])
 

=== modified file 'bzrlib/tests/test_graph.py'
--- a/bzrlib/tests/test_graph.py	2007-11-22 22:33:27 +0000
+++ b/bzrlib/tests/test_graph.py	2007-12-01 01:12:28 +0000
@@ -373,7 +373,7 @@
         self.assertEqual(set(['rev1']), graph.heads(('rev1', 'null:')))
 
     def test_heads_one(self):
-        # A single node will alwaya be a head
+        # A single node will always be a head
         graph = self.make_graph(ancestry_1)
         self.assertEqual(set(['null:']), graph.heads(['null:']))
         self.assertEqual(set(['rev1']), graph.heads(['rev1']))



More information about the bazaar-commits mailing list