Rev 75: Pull out some of the functionality into a helper in http://bzr.arbash-meinel.com/plugins/history_db
John Arbash Meinel
john at arbash-meinel.com
Fri Apr 9 20:58:23 BST 2010
At http://bzr.arbash-meinel.com/plugins/history_db
------------------------------------------------------------
revno: 75
revision-id: john at arbash-meinel.com-20100409195807-21yviuv01nps0od1
parent: john at arbash-meinel.com-20100409183653-wodbju2xhh3eq90s
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: history_db
timestamp: Fri 2010-04-09 14:58:07 -0500
message:
Pull out some of the functionality into a helper
should make things clearer.
-------------- next part --------------
=== modified file 'history_db.py'
--- a/history_db.py 2010-04-09 18:36:53 +0000
+++ b/history_db.py 2010-04-09 19:58:07 +0000
@@ -25,6 +25,7 @@
import time
from bzrlib import (
+ lru_cache,
revision,
static_tuple,
trace,
@@ -91,13 +92,14 @@
self._branch_tip_rev_id = a_branch.last_revision()
self._branch_tip_key = (self._branch_tip_rev_id,)
self._graph = None
- self._ensure_graph()
+ if not self._incremental:
+ self._ensure_graph()
self._rev_id_to_db_id = {}
self._db_id_to_rev_id = {}
self._stats = defaultdict(lambda: 0)
# A cache of entries in the dotted_revno table
# TODO: This would probably be better as an LRU cache
- self._dotted_revno_cache = {}
+ self._dotted_revno_cache = lru_cache.LRUCache(10000)
# Map child_id => [parent_db_ids]
self._db_parent_map = {}
@@ -217,7 +219,7 @@
self._db_conn.commit()
pb.finished()
- def _import_tip(self, tip_revision_id, suppress_progress_and_commit=False):
+ def _get_merge_sorted_tip(self, tip_revision_id):
if self._incremental:
self._update_ancestry(tip_revision_id)
self._ensure_revisions([tip_revision_id])
@@ -265,6 +267,10 @@
assert self._is_imported(actual_node.key[0])
else:
merge_sorted = self._graph.merge_sort((tip_revision_id,))
+ return merge_sorted
+
+ def _import_tip(self, tip_revision_id, suppress_progress_and_commit=False):
+ merge_sorted = self._get_merge_sorted_tip(tip_revision_id)
try:
if suppress_progress_and_commit:
pb = None
=== modified file 'test_importer.py'
--- a/test_importer.py 2010-04-09 17:01:57 +0000
+++ b/test_importer.py 2010-04-09 19:58:07 +0000
@@ -353,9 +353,8 @@
self.F_id: ((1,2,2), 0, 1),
self.G_id: ((3,), 0, 0),
}, inc_merger._imported_dotted_revno)
- self.assertEqual({(1,2,1): self.E_id, (1,2,2): self.F_id,
- (3,): self.G_id,
- }, inc_merger._dotted_to_db_id)
+ self.assertEqual(set([(1,2,1), (1,2,2), (3,)]),
+ inc_merger._known_dotted)
# At this point, B_id isn't in _imported_dotted_revno, so we loop to
# ensure we have enough dotted_revno data
inc_merger._ensure_lh_parent_info()
@@ -406,10 +405,8 @@
self.F_id: ((1,2,2), 0, 1),
self.G_id: ((3,), 0, 0),
}, inc_merger._imported_dotted_revno)
- self.assertEqual({(1,1,1): self.B_id, (1,1,2): self.C_id,
- (2,): self.D_id, (1,2,1): self.E_id,
- (1,2,2): self.F_id, (3,): self.G_id,
- }, inc_merger._dotted_to_db_id)
+ self.assertEqual(set([(1,1,1), (1,1,2), (2,), (1,2,1), (1,2,2), (3,)]),
+ inc_merger._known_dotted)
def test__split_gdfo_handles_mainline_tip(self):
b = self.make_branch_with_simple_history()
More information about the bazaar-commits
mailing list