Rev 4103: (andrew) Fix a bug with how PendingAncestryResult.get_keys handles in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Mar 10 05:28:27 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4103
revision-id: pqm at pqm.ubuntu.com-20090310052823-5h4znt0j8j5ak38o
parent: pqm at pqm.ubuntu.com-20090310033520-f2ynw0fprjw433m2
parent: andrew.bennetts at canonical.com-20090310044122-lqeuw5oippsifwd8
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2009-03-10 05:28:23 +0000
message:
(andrew) Fix a bug with how PendingAncestryResult.get_keys handles
NULL_REVISION.
modified:
bzrlib/graph.py graph_walker.py-20070525030359-y852guab65d4wtn0-1
bzrlib/tests/test_graph.py test_graph_walker.py-20070525030405-enq4r60hhi9xrujc-1
------------------------------------------------------------
revno: 4098.1.3
revision-id: andrew.bennetts at canonical.com-20090310044122-lqeuw5oippsifwd8
parent: andrew.bennetts at canonical.com-20090310024415-3fl3ie61atq39c81
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: fix-pending-ancestry-keys
timestamp: Tue 2009-03-10 14:41:22 +1000
message:
Fix 'trailing' whitespace (actually just a blank line between methods).
modified:
bzrlib/graph.py graph_walker.py-20070525030359-y852guab65d4wtn0-1
------------------------------------------------------------
revno: 4098.1.2
revision-id: andrew.bennetts at canonical.com-20090310024415-3fl3ie61atq39c81
parent: andrew.bennetts at canonical.com-20090310004352-n8vsp6nql9anl2g6
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: fix-pending-ancestry-keys
timestamp: Tue 2009-03-10 12:44:15 +1000
message:
Fix 'trailing' whitespace (actually just a blank line in an indented docstring).
modified:
bzrlib/graph.py graph_walker.py-20070525030359-y852guab65d4wtn0-1
------------------------------------------------------------
revno: 4098.1.1
revision-id: andrew.bennetts at canonical.com-20090310004352-n8vsp6nql9anl2g6
parent: pqm at pqm.ubuntu.com-20090309084556-9i2m12qlud2qcrtw
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: fix-pending-ancestry-keys
timestamp: Tue 2009-03-10 10:43:52 +1000
message:
Fix a bug with how PendingAncestryResult.get_keys handles NULL_REVISION.
modified:
bzrlib/graph.py graph_walker.py-20070525030359-y852guab65d4wtn0-1
bzrlib/tests/test_graph.py test_graph_walker.py-20070525030405-enq4r60hhi9xrujc-1
=== modified file 'bzrlib/graph.py'
--- a/bzrlib/graph.py 2009-03-06 18:55:15 +0000
+++ b/bzrlib/graph.py 2009-03-10 04:41:22 +0000
@@ -1516,13 +1516,17 @@
raise NotImplementedError(self.get_recipe)
def get_keys(self):
- """See SearchResult.get_keys."""
- keys = [key for (key, parents) in
- self.repo.get_graph().iter_ancestry(self.heads)]
- if keys[-1] != 'null:':
- raise AssertionError(
- "Ancestry ends with %r, not null." % (keys[-1],))
- del keys[-1]
+ """See SearchResult.get_keys.
+
+ Returns all the keys for the ancestry of the heads, excluding
+ NULL_REVISION.
+ """
+ return self._get_keys(self.repo.get_graph())
+
+ def _get_keys(self, graph):
+ NULL_REVISION = revision.NULL_REVISION
+ keys = [key for (key, parents) in graph.iter_ancestry(self.heads)
+ if key != NULL_REVISION]
return keys
=== modified file 'bzrlib/tests/test_graph.py'
--- a/bzrlib/tests/test_graph.py 2009-03-06 08:13:23 +0000
+++ b/bzrlib/tests/test_graph.py 2009-03-10 00:43:52 +0000
@@ -1543,3 +1543,15 @@
par = _mod_graph.PendingAncestryResult(['rev-2'], repo)
self.assertEqual(set(['rev-1', 'rev-2']), set(par.get_keys()))
+ def test_get_keys_excludes_null(self):
+ # Make a 'graph' with an iter_ancestry that returns NULL_REVISION
+ # somewhere other than the last element, which can happen in real
+ # ancestries.
+ class StubGraph(object):
+ def iter_ancestry(self, keys):
+ return [(NULL_REVISION, ()), ('foo', (NULL_REVISION,))]
+ par = _mod_graph.PendingAncestryResult(['rev-3'], None)
+ par_keys = par._get_keys(StubGraph())
+ # Only the non-null keys from the ancestry appear.
+ self.assertEqual(set(['foo']), set(par_keys))
+
More information about the bazaar-commits
mailing list