Rev 1475: Use VirtualVersionedFiles implementation from Bazaar. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk
Jelmer Vernooij
jelmer at samba.org
Thu Jul 17 13:53:00 BST 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/trunk
------------------------------------------------------------
revno: 1475
revision-id: jelmer at samba.org-20080717125257-wb8ihlyhw96shmup
parent: jelmer at samba.org-20080716145324-8drjvzg48qem4udt
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Thu 2008-07-17 14:52:57 +0200
message:
Use VirtualVersionedFiles implementation from Bazaar.
modified:
tests/test_versionedfiles.py test_versionedfiles.-20080626153242-v0c6uolklpux67a1-1
versionedfiles.py versionedfiles.py-20080626134117-j8g0ntz1pj228iox-1
=== modified file 'tests/test_versionedfiles.py'
--- a/tests/test_versionedfiles.py 2008-07-03 17:39:58 +0000
+++ b/tests/test_versionedfiles.py 2008-07-17 12:52:57 +0000
@@ -18,8 +18,7 @@
from bzrlib.tests import TestCase
from bzrlib.plugins.svn.versionedfiles import (SvnTexts, VirtualRevisionTexts,
- VirtualInventoryTexts, VirtualSignatureTexts,
- VirtualVersionedFiles)
+ VirtualInventoryTexts, VirtualSignatureTexts)
class BasicSvnTextsTests:
@@ -44,35 +43,6 @@
self.texts = SvnTexts(self)
-class VirtualTextsTests(TestCase,BasicSvnTextsTests):
- def get_parent_map(self, keys):
- return DictParentsProvider(self.parent_map).get_parent_map(keys)
-
- def get_lines(self, key):
- (k,) = key
- if not k in self.lines:
- return None
- return self.lines[k]
-
- def test_get_parent_map(self):
- self.parent_map = {"G": ("A", "B")}
- self.assertEquals({("G",): (("A",),("B",))}, self.texts.get_parent_map([("G",)]))
-
- def test_get_sha1s(self):
- self.lines = {"A": ["FOO"]}
- self.assertEquals({("A",): osutils.sha_strings(["FOO"])},
- self.texts.get_sha1s([("A",), ("B",)]))
-
- def test_get_record_stream(self):
- self.lines = {"A": ["FOO"]}
- it = self.texts.get_record_stream([("A",)], "unordered", True)
- record = it.next()
- self.assertEquals("FOO", record.get_bytes_as("fulltext"))
-
- def setUp(self):
- self.texts = VirtualVersionedFiles(self.get_parent_map, self.get_lines)
-
-
class VirtualRevisionTextsTests(TestCase,BasicSvnTextsTests):
def setUp(self):
self.texts = VirtualRevisionTexts(self)
=== modified file 'versionedfiles.py'
--- a/versionedfiles.py 2008-07-03 17:39:58 +0000
+++ b/versionedfiles.py 2008-07-17 12:52:57 +0000
@@ -15,7 +15,7 @@
from bzrlib import debug, osutils, urlutils
from bzrlib.trace import mutter
-from bzrlib.versionedfile import FulltextContentFactory, VersionedFiles, AbsentContentFactory
+from bzrlib.versionedfile import FulltextContentFactory, VersionedFiles, AbsentContentFactory, VirtualVersionedFiles
from bzrlib.plugins.svn.core import SubversionException
from bzrlib.plugins.svn.errors import ERR_FS_NOT_FILE
@@ -73,48 +73,6 @@
# TODO: annotate, get_sha1s, iter_lines_added_or_present_in_keys, keys
-class VirtualVersionedFiles(VersionedFiles):
- def mutter(self, text, *args):
- if "virtualvf" in debug.debug_flags:
- mutter(text, *args)
-
- def __init__(self, get_parent_map, get_lines):
- self._get_parent_map = get_parent_map
- self._get_lines = get_lines
-
- def check(self, progressbar=None):
- return True
-
- def add_mpdiffs(self, records):
- raise NotImplementedError(self.add_mpdiffs)
-
- def get_parent_map(self, keys):
- self.mutter("get_parent_map(%r)" % keys)
- return dict([((k,), tuple([(p,) for p in v])) for k,v in self._get_parent_map([k for (k,) in keys]).iteritems()])
-
- def get_sha1s(self, keys):
- self.mutter("get_sha1s(%r)" % keys)
- ret = {}
- for (k,) in keys:
- lines = self._get_lines(k)
- if lines is not None:
- assert isinstance(lines, list)
- ret[(k,)] = osutils.sha_strings(lines)
- return ret
-
- def get_record_stream(self, keys, ordering, include_delta_closure):
- self.mutter("get_record_stream(%r)" % keys)
- for (k,) in list(keys):
- lines = self._get_lines(k)
- if lines is not None:
- assert isinstance(lines, list)
- yield FulltextContentFactory((k,), None,
- sha1=osutils.sha_strings(lines),
- text=''.join(lines))
- else:
- yield AbsentContentFactory((k,))
-
-
class VirtualRevisionTexts(VirtualVersionedFiles):
"""Virtual revisions backend."""
def __init__(self, repository):
More information about the bazaar-commits
mailing list