Rev 3: Use pb.note() and add a bit more logging. in http://bzr.arbash-meinel.com/plugins/test_graph
John Arbash Meinel
john at arbash-meinel.com
Tue Dec 11 01:39:14 GMT 2007
At http://bzr.arbash-meinel.com/plugins/test_graph
------------------------------------------------------------
revno: 3
revision-id:john at arbash-meinel.com-20071211013859-953i0nvxzf5fo5iy
parent: john at arbash-meinel.com-20071210210105-afwkl4a38ikmbtzr
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: test_graph
timestamp: Mon 2007-12-10 19:38:59 -0600
message:
Use pb.note() and add a bit more logging.
modified:
graph_testing.py graph_testing.py-20071210194758-1pwa1q7e3wnjf418-2
-------------- next part --------------
=== modified file 'graph_testing.py'
--- a/graph_testing.py 2007-12-10 21:01:05 +0000
+++ b/graph_testing.py 2007-12-11 01:38:59 +0000
@@ -22,6 +22,7 @@
branch,
errors,
tsort,
+ ui,
)
@@ -45,11 +46,16 @@
comes first.)
"""
interesting = []
- for seq_num, revision_id, depth, eom in tsort.merge_sort(self.rev_graph,
- last_revision):
- parent_ids = self.rev_graph[revision_id]
- if len(parent_ids) > 1:
- interesting.append(revision_id)
+ pb = ui.ui_factory.nested_progress_bar()
+ try:
+ for seq_num, revision_id, depth, eom in tsort.merge_sort(self.rev_graph,
+ last_revision):
+ pb.update('finding interesting', seq_num, len(self.rev_graph))
+ parent_ids = self.rev_graph[revision_id]
+ if len(parent_ids) > 1:
+ interesting.append(revision_id)
+ finally:
+ pb.finished()
self.interesting = interesting
def get_ancestry_for_interesting(self):
@@ -57,9 +63,15 @@
ancestries = {}
# We go in reverse order, so that we will tend to find the ancestries in
# the map
- for interesting_id in reversed(self.interesting):
+ pb = ui.ui_factory.nested_progress_bar()
+ cache_hit = 0
+ cache_miss = 0
+ for idx, interesting_id in enumerate(reversed(self.interesting)):
+ pb.update('finding ancestries', idx, len(self.interesting))
needed_ids = list(self.rev_graph[interesting_id]) + [interesting_id]
for revision_id in needed_ids:
+ if revision_id in ancestries:
+ continue
ancestry = set([revision_id])
needed = set([revision_id])
while needed:
@@ -68,17 +80,23 @@
ancestry.update(parent_ids)
for parent_id in parent_ids:
if parent_id in ancestries:
+ cache_hit += 1
ancestry.update(ancestries[parent_id])
else: # We need to probe in this direction
+ cache_miss += 1
needed.add(parent_id)
ancestries[revision_id] = ancestry
+ pb.finished()
+ pb.note('Cache hit: %d, miss: %d', cache_hit, cache_miss)
self.ancestries = ancestries
def time_functions(self, a_branch):
if self.hold_graph:
graph = a_branch.repository.get_graph()
- for revision_id in reversed(self.interesting):
+ pb = ui.ui_factory.nested_progress_bar()
+ for idx, revision_id in enumerate(reversed(self.interesting)):
+ pb.update('processing', idx, len(self.interesting))
parent_ids = self.rev_graph[revision_id]
a_branch.lock_read()
try:
@@ -90,12 +108,10 @@
finally:
a_branch.unlock()
self.head_times[revision_id] = t_heads
- parent_id_set = set(parent_ids)
- if heads != parent_id_set:
- if heads.issubset(parent_ids):
- print 'heads() is subset for: %s' % (revision_id,)
- else:
- print 'heads() mismatch for: %s' % (revision_id,)
+ if heads != set(parent_ids) and heads != set(parent_ids[1:]):
+ # We frequently have nodes that are merged back into their
+ # base, but the rest should be rare
+ pb.note('heads() mismatch for: %s', revision_id)
self.invalid_heads.add(revision_id)
a_branch.lock_read()
@@ -119,7 +135,7 @@
for parent_id in parent_ids:
left, right = graph.find_difference(revision_id, parent_id)
if right != set():
- print 'found unmerged nodes for:\n %s\nand %s' % (
+ pb.note('found unmerged nodes for:\n %s\nand %s',
revision_id, parent_id)
t_trivial_diff = time.clock() - t_start
finally:
@@ -145,13 +161,14 @@
left_correct = left == (left_ancestry - right_ancestry)
right_correct = right == (right_ancestry - left_ancestry)
if not left_correct and not right_correct:
- print 'left and right incorrect for: %s' % (revision_id,)
+ pb.note('left and right incorrect for: %s', revision_id)
elif not left_correct:
- print 'left incorrect for: %s' % (revision_id,)
+ pb.note('left incorrect for: %s', revision_id)
elif not right_correct:
- print 'right incorrect for: %s' % (revision_id,)
+ pb.note('right incorrect for: %s', revision_id)
if not left_correct or not right_correct:
self.invalid_diffs.add(revision_id)
+ pb.finished()
def get_statistics(self, times):
min_time = None
@@ -184,7 +201,9 @@
the_branch.lock_read()
try:
last_revision = the_branch.last_revision()
+ print 'getting revision_graph'
rev_graph = the_branch.repository.get_revision_graph(last_revision)
+ print 'getting rev_id map'
rev_id_map = the_branch.get_revision_id_to_revno_map()
finally:
the_branch.unlock()
More information about the bazaar-commits
mailing list