Rev 3515: we can't trust the numbering for branches that we had to prune, in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/lazy_revno
John Arbash Meinel
john at arbash-meinel.com
Wed Aug 6 18:56:24 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/lazy_revno
------------------------------------------------------------
revno: 3515
revision-id: john at arbash-meinel.com-20080806175607-po8br94kwbhnywwc
parent: john at arbash-meinel.com-20080806042659-d3zew8kqrs6shjmp
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: lazy_revno
timestamp: Wed 2008-08-06 12:56:07 -0500
message:
we can't trust the numbering for branches that we had to prune,
so don't cache them (they will be generated on demand later).
-------------- next part --------------
=== modified file 'bzrlib/graph.py'
--- a/bzrlib/graph.py 2008-08-06 04:26:59 +0000
+++ b/bzrlib/graph.py 2008-08-06 17:56:07 +0000
@@ -1977,6 +1977,9 @@
# At this point we should have a dict with all interesting revisions,
# and some external references, cull the externals
+ # TODO: We might also want to _prune_tails (from bzrlib.merge),
+ # to remove more nodes that don't effect our numbering, and whose
+ # numbers we cannot trust.
culled_parent_map = {}
for revision_id, parent_ids in interesting_parent_map.iteritems():
culled_parent_map[revision_id] = [p for p in parent_ids
@@ -1990,6 +1993,11 @@
# 1, rather than descended_from
real_dotted_revno = ((dotted_revno[0] + mainline_revno - 1,)
+ dotted_revno[1:])
+ if dotted_revno[0] == 0:
+ # TODO: We can't strictly trust branches that come in from
+ # another source.
+ continue
+ import pdb; pdb.set_trace()
node = self._get_node(rev_id)
if node.dotted_revno is not None:
if real_dotted_revno != node.dotted_revno:
@@ -1998,6 +2006,7 @@
else:
node.dotted_revno = real_dotted_revno
+
def collapse_linear_regions(parent_map):
"""Collapse regions of the graph that are 'linear'.
=== modified file 'bzrlib/tests/test_graph.py'
--- a/bzrlib/tests/test_graph.py 2008-08-06 04:26:59 +0000
+++ b/bzrlib/tests/test_graph.py 2008-08-06 17:56:07 +0000
@@ -643,9 +643,9 @@
# |/| |
# d | |
# |\:/
-# | z # z merges y
-# |/:
-# e |
+# | z # z merges y, this also prevents y (descended from c) from
+# |/: # being trivially discovered (you have to walk a non descendent
+# e | # to find the descendent.)
# | |
# f |
# |\|
@@ -1701,6 +1701,12 @@
ms_ancestry = dict(ancestry)
for rev_id, parent_ids in ancestry.iteritems():
ms_ancestry[rev_id] = [p for p in parent_ids if p in ms_ancestry]
+ merge_sorted_revnos = dict((rev_id, revno)
+ for seq_num, rev_id, depth, revno, eom
+ in tsort.merge_sort(ms_ancestry,
+ tip_revision,
+ None,
+ generate_revno=True))
for (seq_num, rev_id, depth, ms_dotted_revno,
end_of_merge) in tsort.merge_sort(ms_ancestry, tip_revision, None,
generate_revno=True):
@@ -1764,6 +1770,20 @@
def test_get_dotted_revno_leapfrogging(self):
self.assertAllDottedRevno(leapfrogging, 'l')
+ def test_get_dotted_revno_with_ghost(self):
+ alt_with_ghost = dict(with_ghost)
+ # assertAllDottedRevno expects NULL_REVISION to not be in the ancestry
+ # map, as it adds another revision to everything.
+ # However, this only accidentally succeeds because we prune 'g' from
+ # the ancestry because it is a ghost. So it never gets numbered. If we
+ # fake it with 'g':(), then it fails because it cannot find a mainline.
+ alt_with_ghost.pop(NULL_REVISION)
+ self.assertAllDottedRevno(alt_with_ghost, 'a')
+ self.assertAllDottedRevno(alt_with_ghost, 'c')
+
+ def test_get_dotted_revno_with_shortcut(self):
+ self.assertAllDottedRevno(shortcut_extra_root, 'f')
+
def test__step_mainline_node(self):
mapper = self.make_mapper(with_tail, 'l')
node = mapper._get_node('l')
@@ -1998,6 +2018,11 @@
'Incorrect descended from for rev_id %r: (%s != %s)'
% (rev_id, descended_from, node.descended_from))
+ def test_cached_numbering_crossing_branches(self):
+ mapper = self.make_mapper(crossing_branches, 'h')
+ self.assertEqual((5, 1, 2), mapper.get_dotted_revno('z'))
+ self.assertEqual((3, 1, 2), mapper.get_dotted_revno('o'))
+
class TestCollapseLinearRegions(tests.TestCase):
More information about the bazaar-commits
mailing list