Rev 4450: Revert the debugging code, change the api a little bit. in http://bazaar.launchpad.net/~jameinel/bzr/1.17-annotate-bug387952
John Arbash Meinel
john at arbash-meinel.com
Tue Jun 16 22:17:33 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/1.17-annotate-bug387952
------------------------------------------------------------
revno: 4450
revision-id: john at arbash-meinel.com-20090616211728-3z22kmrhmw62bf8k
parent: john at arbash-meinel.com-20090616205420-ybtug18izm8g6wmp
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.17-annotate-bug387952
timestamp: Tue 2009-06-16 16:17:28 -0500
message:
Revert the debugging code, change the api a little bit.
Using the 'exact match' shortcut speeds up 'annotate bzrlib/builtins.py'
from about 8s to 7s.
-------------- next part --------------
=== modified file 'bzrlib/annotate.py'
--- a/bzrlib/annotate.py 2009-06-16 20:54:20 +0000
+++ b/bzrlib/annotate.py 2009-06-16 21:17:28 +0000
@@ -39,8 +39,6 @@
from bzrlib.revision import CURRENT_REVISION, Revision
-_counters = [0, 0, 0, 0, 0, 0, 0]
-
def annotate_file(branch, rev_id, file_id, verbose=False, full=False,
to_file=None, show_ids=False):
"""Annotate file_id at revision rev_id in branch.
@@ -400,14 +398,13 @@
last_child_idx = child_idx + match_len
-def _resolve_matching_region(output_lines, annotated_match_subset,
- right_parent_subset, heads_provider,
- new_revision_id):
- _counters[0] += 1
- _counters[1] += len(annotated_match_subset)
- # Shortcut the case when the two sides match exactly
+def _resolve_matching_region(output_lines, annotated_lines, new_idx,
+ right_parent_lines, parent_idx,
+ match_len, new_revision_id, heads_provider):
+ annotated_match_subset = annotated_lines[new_idx:new_idx + match_len]
+ right_parent_subset = right_parent_lines[parent_idx:parent_idx + match_len]
if annotated_match_subset == right_parent_subset:
- _counters[2] += 1
+ # Shortcut the case when the two sides match exactly
output_lines.extend(annotated_match_subset)
return
append = output_lines.append
@@ -418,24 +415,20 @@
assert new_line[1] == right_line[1]
if new_line[0] == right_line[0]:
# These have identical annotations, just go with it
- _counters[3] += 1
append(new_line)
elif new_line[0] == new_revision_id:
# the new annotation claims 'this' modified it, but it just simply
# comes from the right parent
- _counters[4] += 1
append(right_line)
else:
# Both new and right parent lay claim to this line, resolve
if heads_provider is None:
append((new_revision_id, right_line[1]))
else:
- _counters[5] += 1
heads = heads_provider.heads((new_line[0], right_line[0]))
if len(heads) == 1:
for head in heads:
break
- _counters[6] += 1
append((head, new_line[1]))
else:
# Both claim different origins, get a stable result.
@@ -478,12 +471,9 @@
# annotation, and what the current annotated_lines claims is the
# annotation
# Note that 'new_revision_id' is always superseded by annotated_lines
- annotated_match_subset = annotated_lines[new_idx:new_idx + match_len]
- right_parent_subset = right_parent_lines[parent_idx:parent_idx +
- match_len]
- _resolve_matching_region(lines, annotated_match_subset,
- right_parent_subset, heads_provider,
- new_revision_id)
+ _resolve_matching_region(lines, annotated_lines, new_idx,
+ right_parent_lines, parent_idx,
+ match_len, new_revision_id, heads_provider)
last_parent_idx = parent_idx + match_len
last_new_idx = new_idx + match_len
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2009-06-16 20:54:20 +0000
+++ b/bzrlib/builtins.py 2009-06-16 21:17:28 +0000
@@ -4269,8 +4269,6 @@
wt.unlock()
else:
branch.unlock()
- from bzrlib.annotate import _counters
- sys.stderr.write('%s\n' % (_counters,))
class cmd_re_sign(Command):
More information about the bazaar-commits
mailing list