Rev 102: merge versionedfiles support. in http://people.samba.org/bzr/jelmer/bzr-git/trunk

Jelmer Vernooij jelmer at samba.org
Fri Aug 29 16:01:44 BST 2008


At http://people.samba.org/bzr/jelmer/bzr-git/trunk

------------------------------------------------------------
revno: 102
revision-id: jelmer at samba.org-20080829150142-6kgyszl86htv9wyq
parent: jelmer at samba.org-20080827200352-ydtmy25urabkcikh
parent: jelmer at samba.org-20080829145637-f7z73y580w4ztcym
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Fri 2008-08-29 17:01:42 +0200
message:
  merge versionedfiles support.
removed:
  tests/test_versionedfiles.py   test_versionedfiles.-20080626153242-v0c6uolklpux67a1-1
  versionedfiles.py              versionedfiles.py-20080626134117-j8g0ntz1pj228iox-1
added:
  foreign/.bzrignore             bzrignore-20080829145519-ui1mi6gzh50ol7wv-1
  foreign/TODO                   todo-20080829114504-q5cgsdfdxefd6paf-1
  foreign/test_versionedfiles.py test_versionedfiles.-20080829145632-midkv3h7msuyoibq-1
  foreign/versionedfiles.py      versionedfiles.py-20080829145632-midkv3h7msuyoibq-2
modified:
  tests/__init__.py              __init__.py-20070202180350-njrb42t7fnv35d1k-2
    ------------------------------------------------------------
    revno: 0.1.5
    revision-id: jelmer at samba.org-20080829145637-f7z73y580w4ztcym
    parent: jelmer at samba.org-20080829114507-49rej6wo95z5c001
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: trunk
    timestamp: Fri 2008-08-29 16:56:37 +0200
    message:
      Import virtual versionedfiles code.
    added:
      .bzrignore                     bzrignore-20080829145519-ui1mi6gzh50ol7wv-1
      test_versionedfiles.py         test_versionedfiles.-20080829145632-midkv3h7msuyoibq-1
      versionedfiles.py              versionedfiles.py-20080829145632-midkv3h7msuyoibq-2
    ------------------------------------------------------------
    revno: 0.1.4
    revision-id: jelmer at samba.org-20080829114507-49rej6wo95z5c001
    parent: jelmer at samba.org-20080827194301-mok29r5330g0boex
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: trunk
    timestamp: Fri 2008-08-29 13:45:07 +0200
    message:
      Import TODO.
    added:
      TODO                           todo-20080829114504-q5cgsdfdxefd6paf-1
=== added file 'foreign/.bzrignore'
--- a/foreign/.bzrignore	1970-01-01 00:00:00 +0000
+++ b/foreign/.bzrignore	2008-08-29 14:56:37 +0000
@@ -0,0 +1,1 @@
+_trial_temp

=== added file 'foreign/TODO'
--- a/foreign/TODO	1970-01-01 00:00:00 +0000
+++ b/foreign/TODO	2008-08-29 11:45:07 +0000
@@ -0,0 +1,3 @@
+- Import VirtualRevisionTexts, VirtualInventoryTexts, VirtualSignatureTexts
+- Import dpush command
+- Import CommitBuilder-based fetcher

=== added file 'foreign/test_versionedfiles.py'
--- a/foreign/test_versionedfiles.py	1970-01-01 00:00:00 +0000
+++ b/foreign/test_versionedfiles.py	2008-08-29 14:56:37 +0000
@@ -0,0 +1,77 @@
+# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer at samba.org>
+ 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from bzrlib import osutils
+from bzrlib.tests import TestCase
+
+from versionedfiles import (VirtualRevisionTexts, VirtualInventoryTexts, 
+                            VirtualSignatureTexts)
+
+
+class BasicTextsTests:
+    def test_add_lines(self):
+        self.assertRaises(NotImplementedError, 
+                self.texts.add_lines, "foo", [], [])
+
+    def test_add_mpdiffs(self):
+        self.assertRaises(NotImplementedError, 
+                self.texts.add_mpdiffs, [])
+
+    def test_check(self):
+        self.assertTrue(self.texts.check())
+
+    def test_insert_record_stream(self):
+        self.assertRaises(NotImplementedError, self.texts.insert_record_stream,
+                          [])
+
+
+class VirtualRevisionTextsTests(TestCase, BasicTextsTests):
+    def _make_parents_provider(self):
+        return self
+
+    def setUp(self):
+        self.texts = VirtualRevisionTexts(self)
+
+    def get_parent_map(self, keys):
+        raise NotImplementedError
+
+
+class VirtualInventoryTextsTests(TestCase, BasicTextsTests):
+    def _make_parents_provider(self):
+        return self
+
+    def get_inventory_xml(self, key):
+        return "FOO"
+
+    def get_parent_map(self, keys):
+        return {("A",): (("B",))}
+
+    def setUp(self):
+        self.texts = VirtualInventoryTexts(self)
+
+    def test_get_sha1s(self):
+        self.assertEquals({("A",): osutils.sha_strings(["FOO"])}, self.texts.get_sha1s([("A",)]))
+
+
+class VirtualSignatureTextsTests(TestCase, BasicTextsTests):
+    def _make_parents_provider(self):
+        return self
+
+    def setUp(self):
+        self.texts = VirtualSignatureTexts(self)
+
+    def get_parent_map(self, keys):
+        raise NotImplementedError
+

=== added file 'foreign/versionedfiles.py'
--- a/foreign/versionedfiles.py	1970-01-01 00:00:00 +0000
+++ b/foreign/versionedfiles.py	2008-08-29 14:56:37 +0000
@@ -0,0 +1,56 @@
+# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer at samba.org>
+ 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from bzrlib import osutils, urlutils
+from bzrlib.versionedfile import FulltextContentFactory, VersionedFiles, VirtualVersionedFiles
+
+from cStringIO import StringIO
+
+
+class VirtualRevisionTexts(VirtualVersionedFiles):
+    """Virtual revisions backend."""
+    def __init__(self, repository):
+        self.repository = repository
+        super(VirtualRevisionTexts, self).__init__(self.repository._make_parents_provider().get_parent_map, self.get_lines)
+
+    def get_lines(self, key):
+        return osutils.split_lines(self.repository.get_revision_xml(key))
+
+    # TODO: annotate, iter_lines_added_or_present_in_keys, keys
+
+
+class VirtualInventoryTexts(VirtualVersionedFiles):
+    """Virtual inventories backend."""
+    def __init__(self, repository):
+        self.repository = repository
+        super(VirtualInventoryTexts, self).__init__(self.repository._make_parents_provider().get_parent_map, self.get_lines)
+
+    def get_lines(self, key):
+        return osutils.split_lines(self.repository.get_inventory_xml(key))
+
+    # TODO: annotate, iter_lines_added_or_present_in_keys, keys
+
+
+class VirtualSignatureTexts(VirtualVersionedFiles):
+    """Virtual signatures backend."""
+    def __init__(self, repository):
+        self.repository = repository
+        super(VirtualSignatureTexts, self).__init__(self.repository._make_parents_provider().get_parent_map, self.get_lines)
+
+    def get_lines(self, key):
+        return osutils.split_lines(self.repository.get_signature_text(key))
+
+    # TODO: annotate, iter_lines_added_or_present_in_keys, keys
+

=== modified file 'tests/__init__.py'
--- a/tests/__init__.py	2008-08-23 13:12:10 +0000
+++ b/tests/__init__.py	2008-08-29 15:01:42 +0000
@@ -233,7 +233,6 @@
         'test_repository',
         'test_ids',
         'test_blackbox',
-        'test_versionedfiles',
         ]
     testmod_names = ['%s.%s' % (__name__, t) for t in testmod_names]
     suite.addTests(loader.loadTestsFromModuleNames(testmod_names))

=== removed file 'tests/test_versionedfiles.py'
--- a/tests/test_versionedfiles.py	2008-08-23 11:34:36 +0000
+++ b/tests/test_versionedfiles.py	1970-01-01 00:00:00 +0000
@@ -1,83 +0,0 @@
-# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer at samba.org>
- 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from bzrlib import osutils
-from bzrlib.graph import DictParentsProvider
-from bzrlib.tests import TestCase
-
-from bzrlib.plugins.git.versionedfiles import (SvnTexts, VirtualRevisionTexts, 
-                                               VirtualInventoryTexts, VirtualSignatureTexts)
-
-
-class BasicSvnTextsTests:
-    def test_add_lines(self):
-        self.assertRaises(NotImplementedError, 
-                self.texts.add_lines, "foo", [], [])
-
-    def test_add_mpdiffs(self):
-        self.assertRaises(NotImplementedError, 
-                self.texts.add_mpdiffs, [])
-
-    def test_check(self):
-        self.assertTrue(self.texts.check())
-
-    def test_insert_record_stream(self):
-        self.assertRaises(NotImplementedError, self.texts.insert_record_stream,
-                          [])
-
-
-class SvnTextsTests(TestCase,BasicSvnTextsTests):
-    def setUp(self):
-        self.texts = SvnTexts(self)
-
-
-class VirtualRevisionTextsTests(TestCase,BasicSvnTextsTests):
-    def _make_parents_provider(self):
-        return self
-
-    def setUp(self):
-        self.texts = VirtualRevisionTexts(self)
-
-    def get_parent_map(self, keys):
-        raise NotImplementedError
-
-
-class VirtualInventoryTextsTests(TestCase,BasicSvnTextsTests):
-    def _make_parents_provider(self):
-        return self
-
-    def get_inventory_xml(self, key):
-        return "FOO"
-
-    def get_parent_map(self, keys):
-        return {("A",): (("B",))}
-
-    def setUp(self):
-        self.texts = VirtualInventoryTexts(self)
-
-    def test_get_sha1s(self):
-        self.assertEquals({("A",): osutils.sha_strings(["FOO"])}, self.texts.get_sha1s([("A",)]))
-
-
-class VirtualSignatureTextsTests(TestCase,BasicSvnTextsTests):
-    def _make_parents_provider(self):
-        return self
-
-    def setUp(self):
-        self.texts = VirtualSignatureTexts(self)
-
-    def get_parent_map(self, keys):
-        raise NotImplementedError
-

=== removed file 'versionedfiles.py'
--- a/versionedfiles.py	2008-08-23 13:14:41 +0000
+++ b/versionedfiles.py	1970-01-01 00:00:00 +0000
@@ -1,116 +0,0 @@
-# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer at samba.org>
- 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from bzrlib import debug, osutils, urlutils
-from bzrlib.trace import mutter
-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
-
-from cStringIO import StringIO
-
-class SvnTexts(VersionedFiles):
-    """Subversion texts backend."""
-
-    def __init__(self, repository):
-        self.repository = repository
-
-    def check(self, progressbar=None):
-        return True
-
-    def add_mpdiffs(self, records):
-        raise NotImplementedError(self.add_mpdiffs)
-
-    def get_record_stream(self, keys, ordering, include_delta_closure):
-        # TODO: there may be valid text revisions that only exist as 
-        # ghosts in the repository itself. This function will 
-        # not be able to report them.
-        # TODO: Sort keys by file id and issue just one get_file_revs() call 
-        # per file-id ?
-        for (fileid, revid) in list(keys):
-            (branch, revnum, mapping) = self.repository.lookup_revision_id(revid)
-            map = self.repository.get_fileid_map(revnum, branch, mapping)
-            # Unfortunately, the map is the other way around
-            lines = None
-            for k,(v,ck) in map.items():
-                if v == fileid:
-                    try:
-                        stream = StringIO()
-                        self.repository.transport.get_file(urlutils.join(branch, k), stream, revnum)
-                        lines = stream.readlines()
-                    except SubversionException, (_, num):
-                        if num == ERR_FS_NOT_FILE:
-                            lines = []
-                        else:
-                            raise
-                    break
-            if lines is None:
-                raise Exception("Inconsistent key specified: (%r,%r)" % (fileid, revid))
-            yield FulltextContentFactory((fileid,revid), None, 
-                        sha1=osutils.sha_strings(lines),
-                        text=''.join(lines))
-
-    def get_parent_map(self, keys):
-        invs = {}
-
-        # First, figure out the revision number/path
-        ret = {}
-        for (fileid, revid) in keys:
-            # FIXME: Evil hack
-            ret[(fileid, revid)] = None
-        return ret
-
-    # TODO: annotate, get_sha1s, iter_lines_added_or_present_in_keys, keys
-
-
-class VirtualRevisionTexts(VirtualVersionedFiles):
-    """Virtual revisions backend."""
-    def __init__(self, repository):
-        self.repository = repository
-        super(VirtualRevisionTexts, self).__init__(self.repository._make_parents_provider().get_parent_map, self.get_lines)
-
-    def get_lines(self, key):
-        return osutils.split_lines(self.repository.get_revision_xml(key))
-
-    def keys(self):
-        return [(revid,) for revid in self.repository.all_revision_ids()]
-
-    # TODO: annotate, iter_lines_added_or_present_in_keys, keys
-
-
-class VirtualInventoryTexts(VirtualVersionedFiles):
-    """Virtual inventories backend."""
-    def __init__(self, repository):
-        self.repository = repository
-        super(VirtualInventoryTexts, self).__init__(self.repository._make_parents_provider().get_parent_map, self.get_lines)
-
-    def get_lines(self, key):
-        return osutils.split_lines(self.repository.get_inventory_xml(key))
-
-    # TODO: annotate, iter_lines_added_or_present_in_keys, keys
-
-
-class VirtualSignatureTexts(VirtualVersionedFiles):
-    """Virtual signatures backend."""
-    def __init__(self, repository):
-        self.repository = repository
-        super(VirtualSignatureTexts, self).__init__(self.repository._make_parents_provider().get_parent_map, self.get_lines)
-
-    def get_lines(self, key):
-        return osutils.split_lines(self.repository.get_signature_text(key))
-
-    # TODO: annotate, iter_lines_added_or_present_in_keys, keys
-




More information about the bazaar-commits mailing list