Rev 6037: Code was relying on an empty parent map to yield an empty search. in http://bazaar.launchpad.net/~jameinel/bzr/2.4-too-much-walking-388269

John Arbash Meinel john at arbash-meinel.com
Wed Aug 24 09:02:00 UTC 2011


At http://bazaar.launchpad.net/~jameinel/bzr/2.4-too-much-walking-388269

------------------------------------------------------------
revno: 6037
revision-id: john at arbash-meinel.com-20110824090144-udyd40lmdlcwssyv
parent: john at arbash-meinel.com-20110818132927-7tapdcou1aeu05ij
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.4-too-much-walking-388269
timestamp: Wed 2011-08-24 11:01:44 +0200
message:
  Code was relying on an empty parent map to yield an empty search.
  Makes sense to me.
-------------- next part --------------
=== modified file 'bzrlib/graph.py'
--- a/bzrlib/graph.py	2011-08-17 13:02:37 +0000
+++ b/bzrlib/graph.py	2011-08-24 09:01:44 +0000
@@ -2005,6 +2005,9 @@
     :param tip_keys: the revision_ids that we are searching
     :param depth: How far back to walk.
     """
+    if not parent_map:
+        # No search to send, because we haven't done any searching yet.
+        return [], [], 0
     heads = _find_possible_heads(parent_map, tip_keys, depth)
     s, found_heads = _run_search(parent_map, heads, set(tip_keys))
     _, start_keys, exclude_keys, key_count = s.get_result().get_recipe()

=== modified file 'bzrlib/tests/test_graph.py'
--- a/bzrlib/tests/test_graph.py	2011-08-11 15:30:30 +0000
+++ b/bzrlib/tests/test_graph.py	2011-08-24 09:01:44 +0000
@@ -1796,6 +1796,9 @@
         self.assertEqual((sorted(start_keys), sorted(stop_keys), key_count),
                          (sorted(start), sorted(stop), count))
 
+    def test_empty_ancestry(self):
+        self.assertSearchResult([], [], 0, {}, (), ['tip-rev-id'], 10)
+
     def test_ancestry_1(self):
         self.assertSearchResult(['rev4'], ['rev1'], 4,
                                 ancestry_1, (), ['rev1'], 10)

=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py	2011-07-15 08:25:00 +0000
+++ b/bzrlib/tests/test_remote.py	2011-08-24 09:01:44 +0000
@@ -2103,8 +2103,8 @@
         parents = repo.get_parent_map([rev_id])
         self.assertEqual(
             [('call_with_body_bytes_expecting_body',
-              'Repository.get_parent_map', ('quack/', 'include-missing:',
-              rev_id), '\n\n0'),
+              'Repository.get_parent_map',
+              ('quack/', 'include-missing:', rev_id), '\n\n0'),
              ('disconnect medium',),
              ('call_expecting_body', 'Repository.get_revision_graph',
               ('quack/', ''))],



More information about the bazaar-commits mailing list