Rev 2976: Change (without backwards compatibility) the in http://people.ubuntu.com/~robertc/baz2.0/iter-lines
Robert Collins
robertc at robertcollins.net
Fri Nov 9 17:53:16 GMT 2007
At http://people.ubuntu.com/~robertc/baz2.0/iter-lines
------------------------------------------------------------
revno: 2976
revision-id:robertc at robertcollins.net-20071109175031-agaiy6530rvbprmb
parent: pqm at pqm.ubuntu.com-20071107140948-l3p8njdhgwstdkri
committer: Robert Collins <robertc at robertcollins.net>
branch nick: iter-lines
timestamp: Sat 2007-11-10 04:50:31 +1100
message:
Change (without backwards compatibility) the
iter_lines_added_or_present_in_versions VersionedFile API to yield the
text version that each line is being returned from. This is useful for
reconcile in determining what inventories reference what texts.
(Robert Collins)
modified:
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/test_knit.py test_knit.py-20051212171302-95d4c00dd5f11f2b
bzrlib/tests/test_versionedfile.py test_versionedfile.py-20060222045249-db45c9ed14a1c2e5
bzrlib/weave.py knit.py-20050627021749-759c29984154256b
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py 2007-10-26 08:56:09 +0000
+++ b/bzrlib/knit.py 2007-11-09 17:50:31 +0000
@@ -1117,8 +1117,11 @@
line_iterator = self.factory.get_fulltext_content(data)
else:
line_iterator = self.factory.get_linedelta_content(data)
+ # XXX: It might be more efficient to yield (version_id,
+ # line_iterator) in the future. However for now, this is a simpler
+ # change to integrate into the rest of the codebase. RBC 20071110
for line in line_iterator:
- yield line
+ yield line, version_id
pb.update('Walking content.', total, total)
=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py 2007-11-07 13:10:37 +0000
+++ b/bzrlib/repofmt/pack_repo.py 2007-11-09 17:50:31 +0000
@@ -708,7 +708,7 @@
"""Copy knit nodes between packs.
:param output_lines: Return lines present in the copied data as
- an iterator.
+ an iterator of line,version_id.
"""
pb = ui.ui_factory.nested_progress_bar()
try:
@@ -762,7 +762,7 @@
else:
line_iterator = factory.get_linedelta_content(content)
for line in line_iterator:
- yield line
+ yield line, key[-1]
else:
# check the header only
df, _ = knit_data._parse_record_header(key[-1], raw_data)
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2007-10-31 22:33:53 +0000
+++ b/bzrlib/repository.py 2007-11-09 17:50:31 +0000
@@ -1061,7 +1061,7 @@
This performs the translation of xml lines to revision ids.
- :param line_iterator: An iterator of lines
+ :param line_iterator: An iterator of lines, origin_version_id
:param revision_ids: The revision ids to filter for. This should be a
set or other type which supports efficient __contains__ lookups, as
the revision id from each parsed line will be looked up in the
@@ -1091,7 +1091,7 @@
search = self._file_ids_altered_regex.search
unescape = _unescape_xml
setdefault = result.setdefault
- for line in line_iterator:
+ for line, version_id in line_iterator:
match = search(line)
if match is None:
continue
@@ -1115,6 +1115,8 @@
unescape_revid_cache[revision_id] = unescaped
revision_id = unescaped
+ # once data is all ensured-consistent; then this is
+ # if revision_id == version_id
if revision_id in revision_ids:
try:
file_id = unescape_fileid_cache[file_id]
=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py 2007-10-17 09:39:41 +0000
+++ b/bzrlib/tests/test_knit.py 2007-11-09 17:50:31 +0000
@@ -1406,7 +1406,7 @@
self.assertEqual(
[('readv', 'id.knit', [(0, 87), (87, 89)], False, None)],
instrumented_t._activity)
- self.assertEqual(['text\n', 'text2\n'], results)
+ self.assertEqual([('text\n', 'base'), ('text2\n', 'base2')], results)
def test_create_empty_annotated(self):
k1 = self.make_test_knit(True)
=== modified file 'bzrlib/tests/test_versionedfile.py'
--- a/bzrlib/tests/test_versionedfile.py 2007-10-17 09:39:41 +0000
+++ b/bzrlib/tests/test_versionedfile.py 2007-11-09 17:50:31 +0000
@@ -560,18 +560,14 @@
['base\n', 'lancestor\n', 'otherchild\n'])
def iter_with_versions(versions, expected):
# now we need to see what lines are returned, and how often.
- lines = {'base\n':0,
- 'lancestor\n':0,
- 'rancestor\n':0,
- 'child\n':0,
- 'otherchild\n':0,
- }
+ lines = {}
progress = InstrumentedProgress()
# iterate over the lines
- for line in vf.iter_lines_added_or_present_in_versions(versions,
+ for line in vf.iter_lines_added_or_present_in_versions(versions,
pb=progress):
+ lines.setdefault(line, 0)
lines[line] += 1
- if []!= progress.updates:
+ if []!= progress.updates:
self.assertEqual(expected, progress.updates)
return lines
lines = iter_with_versions(['child', 'otherchild'],
@@ -579,8 +575,8 @@
('Walking content.', 1, 2),
('Walking content.', 2, 2)])
# we must see child and otherchild
- self.assertTrue(lines['child\n'] > 0)
- self.assertTrue(lines['otherchild\n'] > 0)
+ self.assertTrue(lines[('child\n', 'child')] > 0)
+ self.assertTrue(lines[('otherchild\n', 'otherchild')] > 0)
# we dont care if we got more than that.
# test all lines
@@ -591,11 +587,11 @@
('Walking content.', 4, 5),
('Walking content.', 5, 5)])
# all lines must be seen at least once
- self.assertTrue(lines['base\n'] > 0)
- self.assertTrue(lines['lancestor\n'] > 0)
- self.assertTrue(lines['rancestor\n'] > 0)
- self.assertTrue(lines['child\n'] > 0)
- self.assertTrue(lines['otherchild\n'] > 0)
+ self.assertTrue(lines[('base\n', 'base')] > 0)
+ self.assertTrue(lines[('lancestor\n', 'lancestor')] > 0)
+ self.assertTrue(lines[('rancestor\n', 'rancestor')] > 0)
+ self.assertTrue(lines[('child\n', 'child')] > 0)
+ self.assertTrue(lines[('otherchild\n', 'otherchild')] > 0)
def test_add_lines_with_ghosts(self):
# some versioned file formats allow lines to be added with parent
=== modified file 'bzrlib/weave.py'
--- a/bzrlib/weave.py 2007-10-05 05:52:45 +0000
+++ b/bzrlib/weave.py 2007-11-09 17:50:31 +0000
@@ -463,9 +463,9 @@
# properly, we do not filter down to that
# if inserted not in version_ids: continue
if line[-1] != '\n':
- yield line + '\n'
+ yield line + '\n', inserted
else:
- yield line
+ yield line, inserted
def _walk_internal(self, version_ids=None):
"""Helper method for weave actions."""
More information about the bazaar-commits
mailing list