Rev 1240: Move delta operations to separate file. in http://people.samba.org/bzr/jelmer/bzr-svn/0.4/

Jelmer Vernooij jelmer at samba.org
Tue Jun 17 23:52:35 BST 2008


At http://people.samba.org/bzr/jelmer/bzr-svn/0.4/

------------------------------------------------------------
revno: 1240
revision-id: jelmer at samba.org-20080617225233-2b79ggobt2sc0qet
parent: jelmer at samba.org-20080617223119-ub4cxwjhnya05p5n
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Wed 2008-06-18 00:52:33 +0200
message:
  Move delta operations to separate file.
added:
  delta.py                       delta.py-20080617225125-jeg43afui0czkuwk-1
modified:
  fetch.py                       fetch.py-20060625004942-x2lfaib8ra707a8p-1
  format.py                      format.py-20070917005147-94kb7zysotf82kqw-1
  mapping3/__init__.py           __init__.py-20080502174630-9324zh25kka98vlw-1
  ra.py                          ra.py-20080615005305-t5221niknu8rm6bt-1
  tests/test_branch.py           test_branch.py-20060508162215-74ffeb5d608f8e20
  tests/test_checkout.py         test_checkout.py-20070101154110-eevkc29qj0q7udz5-1
  tree.py                        tree.py-20060624222557-dudlwqcmkf22lt2s-1
  workingtree.py                 workingtree.py-20060306120941-b083cb0fdd4a69de
=== added file 'delta.py'
--- a/delta.py	1970-01-01 00:00:00 +0000
+++ b/delta.py	2008-06-17 22:52:33 +0000
@@ -0,0 +1,46 @@
+# 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/>.
+
+# Deal with Subversion 1.5 and the patched Subversion 1.4 (which are 
+# slightly different).
+
+from cStringIO import StringIO
+import svn.delta
+
+if hasattr(svn.delta, 'tx_invoke_window_handler'):
+    def apply_txdelta_handler(sbuf, target_stream):
+        src_stream = StringIO(sbuf)
+        assert hasattr(src_stream, 'read')
+        assert hasattr(target_stream, 'write')
+        window_handler, baton = svn.delta.tx_apply(src_stream, target_stream, 
+                                                   None)
+
+        def wrapper(window):
+            window_handler(window, baton)
+
+        return wrapper
+else:
+    def apply_txdelta_handler(sbuf, target_stream):
+        src_stream = StringIO(sbuf)
+        assert hasattr(src_stream, 'read')
+        assert hasattr(target_stream, 'write')
+        ret = svn.delta.svn_txdelta_apply(src_stream, target_stream, None)
+
+        def wrapper(window):
+            svn.delta.invoke_txdelta_window_handler(
+                ret[1], window, ret[2])
+
+        return wrapper
+

=== modified file 'fetch.py'
--- a/fetch.py	2008-06-17 21:03:10 +0000
+++ b/fetch.py	2008-06-17 22:52:33 +0000
@@ -28,6 +28,7 @@
 import svn.delta
 
 from bzrlib.plugins.svn import properties
+from bzrlib.plugins.svn.delta import apply_txdelta_handler
 from bzrlib.plugins.svn.errors import InvalidFileName
 from bzrlib.plugins.svn.logwalker import lazy_dict
 from bzrlib.plugins.svn.mapping import (SVN_PROP_BZR_MERGE, 
@@ -38,7 +39,7 @@
                      parse_revision_metadata)
 from bzrlib.plugins.svn.repository import SvnRepository, SvnRepositoryFormat
 from bzrlib.plugins.svn.svk import SVN_PROP_SVK_MERGE
-from bzrlib.plugins.svn.tree import (apply_txdelta_handler, parse_externals_description, 
+from bzrlib.plugins.svn.tree import (parse_externals_description, 
                   inventory_add_external)
 
 
@@ -390,8 +391,7 @@
             "base checksum mismatch: %r != %r" % (base_checksum, 
                                                   actual_checksum))
         self.file_stream = StringIO()
-        return apply_txdelta_handler(StringIO(self.file_data), 
-                                     self.file_stream)
+        return apply_txdelta_handler(self.file_data, self.file_stream)
 
     def _store_file(self, file_id, lines, parents):
         raise NotImplementedError(self._store_file)

=== modified file 'format.py'
--- a/format.py	2008-06-17 22:31:19 +0000
+++ b/format.py	2008-06-17 22:52:33 +0000
@@ -65,10 +65,10 @@
         return format
 
     def _open(self, transport):
-        from bzrlib.plugins.svn import core
+        from bzrlib.plugins.svn.core import SubversionException
         try: 
             return remote.SvnRemoteAccess(transport, self)
-        except core.SubversionException, (_, num):
+        except SubversionException, (_, num):
             if num == errors.ERR_RA_DAV_REQUEST_FAILED:
                 raise bzr_errors.NotBranchError(transport.base)
             raise
@@ -114,12 +114,12 @@
 
     @classmethod
     def probe_transport(klass, transport):
-        import svn
         from bzrlib.transport.local import LocalTransport
+        from svn import wc
         format = klass()
 
         if isinstance(transport, LocalTransport) and \
-            transport.has(svn.wc.get_adm_dir()):
+            transport.has(wc.get_adm_dir()):
             return format
 
         raise bzr_errors.NotBranchError(path=transport.base)

=== modified file 'mapping3/__init__.py'
--- a/mapping3/__init__.py	2008-06-17 22:21:30 +0000
+++ b/mapping3/__init__.py	2008-06-17 22:52:33 +0000
@@ -16,6 +16,7 @@
 from bzrlib import osutils, ui
 from bzrlib.errors import InvalidRevisionId
 from bzrlib.trace import mutter
+
 from bzrlib.plugins.svn import mapping, properties
 from bzrlib.plugins.svn.core import SubversionException, NODE_DIR
 from bzrlib.plugins.svn.errors import ERR_FS_NOT_DIRECTORY, ERR_FS_NOT_FOUND, ERR_RA_DAV_PATH_NOT_FOUND
@@ -117,11 +118,9 @@
 
 
 def set_property_scheme(repository, scheme):
-    def done(revmetadata, pool):
-        pass
     editor = repository.transport.get_commit_editor(
             {properties.PROP_REVISION_LOG: "Updating branching scheme for Bazaar."},
-            done, None, False)
+            None, None, False)
     root = editor.open_root()
     root.change_prop(SVN_PROP_BZR_BRANCHING_SCHEME, 
             "".join(map(lambda x: x+"\n", scheme.branch_list)).encode("utf-8"))

=== modified file 'ra.py'
--- a/ra.py	2008-06-17 22:21:30 +0000
+++ b/ra.py	2008-06-17 22:52:33 +0000
@@ -338,6 +338,10 @@
         return svn.ra.rev_proplist(self._ra, revnum, None)
 
     def get_commit_editor(self, revprops, done_cb=None, lock_token=None, keep_locks=False):
+        def dummy_done(meta, pool):
+            pass
+        if done_cb is None:
+            done_cb = dummy_done
         self._mark_busy()
         try:
             if hasattr(svn.ra, 'get_commit_editor3'):

=== modified file 'tests/test_branch.py'
--- a/tests/test_branch.py	2008-06-05 03:29:15 +0000
+++ b/tests/test_branch.py	2008-06-17 22:52:33 +0000
@@ -596,7 +596,6 @@
         repos_url = self.make_repository('d')
 
         dc = self.commit_editor(repos_url)
-
         dc.add_dir("trunk")
         dc.add_file("trunk/hosts")
         dc.done()

=== modified file 'tests/test_checkout.py'
--- a/tests/test_checkout.py	2008-06-05 03:39:17 +0000
+++ b/tests/test_checkout.py	2008-06-17 22:52:33 +0000
@@ -29,10 +29,10 @@
 class TestWorkingTreeFormat(TestCase):
     def setUp(self):
         super(TestWorkingTreeFormat, self).setUp()
-        self.format = SvnWorkingTreeFormat()
+        self.format = SvnWorkingTreeFormat(4)
 
     def test_get_format_desc(self):
-        self.assertEqual("Subversion Working Copy", 
+        self.assertEqual("Subversion Working Copy Version 4", 
                          self.format.get_format_description())
 
     def test_initialize(self):

=== modified file 'tree.py'
--- a/tree.py	2008-06-17 22:31:19 +0000
+++ b/tree.py	2008-06-17 22:52:33 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005-2006 Jelmer Vernooij <jelmer at samba.org>
+# Copyright (C) 2005-2008 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
@@ -18,17 +18,18 @@
 from bzrlib import osutils, urlutils
 from bzrlib.branch import Branch
 from bzrlib.inventory import Inventory, InventoryDirectory, TreeReference
-
 from bzrlib.revision import CURRENT_REVISION
 from bzrlib.trace import mutter
 from bzrlib.revisiontree import RevisionTree
 
+from bzrlib.plugins.svn.delta import apply_txdelta_handler
+
 import os
 import md5
 from cStringIO import StringIO
 import urllib
 
-import svn.wc, svn.delta
+import svn.wc
 
 from bzrlib.plugins.svn import errors, properties, core
 
@@ -96,33 +97,6 @@
     inv.add(ie)
 
 
-# Deal with Subversion 1.5 and the patched Subversion 1.4 (which are 
-# slightly different).
-
-if hasattr(svn.delta, 'tx_invoke_window_handler'):
-    def apply_txdelta_handler(src_stream, target_stream):
-        assert hasattr(src_stream, 'read')
-        assert hasattr(target_stream, 'write')
-        window_handler, baton = svn.delta.tx_apply(src_stream, target_stream, 
-                                                   None)
-
-        def wrapper(window):
-            window_handler(window, baton)
-
-        return wrapper
-else:
-    def apply_txdelta_handler(src_stream, target_stream):
-        assert hasattr(src_stream, 'read')
-        assert hasattr(target_stream, 'write')
-        ret = svn.delta.svn_txdelta_apply(src_stream, target_stream, None)
-
-        def wrapper(window):
-            svn.delta.invoke_txdelta_window_handler(
-                ret[1], window, ret[2])
-
-        return wrapper
-
-
 class SvnRevisionTree(RevisionTree):
     """A tree that existed in a historical Subversion revision."""
     def __init__(self, repository, revision_id):
@@ -146,14 +120,12 @@
         return osutils.split_lines(self.file_data[file_id])
 
 
-class TreeBuildEditor(svn.delta.Editor):
+class TreeBuildEditor:
     """Builds a tree given Subversion tree transform calls."""
     def __init__(self, tree):
         self.tree = tree
         self.repository = tree._repository
         self.last_revnum = {}
-        self.dir_revnum = {}
-        self.dir_ignores = {}
 
     def set_target_revision(self, revnum):
         self.revnum = revnum
@@ -173,15 +145,13 @@
         return file_id
 
     def change_dir_prop(self, id, name, value, pool):
-        if name == properties.PROP_ENTRY_COMMITTED_REV:
-            self.dir_revnum[id] = int(value)
-        elif name == properties.PROP_IGNORE:
-            self.dir_ignores[id] = value
-        elif name in (properties.PROP_ENTRY_COMMITTED_DATE,
-                      properties.PROP_ENTRY_LAST_AUTHOR,
-                      properties.PROP_ENTRY_LOCK_TOKEN,
-                      properties.PROP_ENTRY_UUID,
-                      properties.PROP_EXECUTABLE):
+        if name in (properties.PROP_ENTRY_COMMITTED_DATE,
+                    properties.PROP_ENTRY_LAST_AUTHOR,
+                    properties.PROP_ENTRY_LOCK_TOKEN,
+                    properties.PROP_ENTRY_COMMITTED_REV,
+                    properties.PROP_ENTRY_UUID,
+                    properties.PROP_IGNORE,
+                    properties.PROP_EXECUTABLE):
             pass
         elif name.startswith(properties.PROP_WC_PREFIX):
             pass
@@ -215,8 +185,7 @@
         return path
 
     def close_dir(self, id):
-        if id in self.tree._inventory and self.dir_ignores.has_key(id):
-            self.tree._inventory[id].ignores = self.dir_ignores[id]
+        pass
 
     def close_file(self, path, checksum):
         file_id, revision_id = self.tree.id_map[path]
@@ -258,7 +227,7 @@
 
     def apply_textdelta(self, file_id, base_checksum):
         self.file_stream = StringIO()
-        return apply_txdelta_handler(StringIO(""), self.file_stream)
+        return apply_txdelta_handler("", self.file_stream)
 
 
 class SvnBasisTree(RevisionTree):

=== modified file 'workingtree.py'
--- a/workingtree.py	2008-06-17 22:31:19 +0000
+++ b/workingtree.py	2008-06-17 22:52:33 +0000
@@ -72,7 +72,8 @@
 class SvnWorkingTree(WorkingTree):
     """WorkingTree implementation that uses a Subversion Working Copy for storage."""
     def __init__(self, bzrdir, local_path, branch):
-        self._format = SvnWorkingTreeFormat()
+        version = wc.check_wc(local_path)
+        self._format = SvnWorkingTreeFormat(version)
         self.basedir = local_path
         assert isinstance(self.basedir, unicode)
         self.bzrdir = bzrdir
@@ -700,16 +701,19 @@
 
 class SvnWorkingTreeFormat(WorkingTreeFormat):
     """Subversion working copy format."""
+    def __init__(self, version):
+        self.version = version
+
     def __get_matchingbzrdir(self):
         return SvnWorkingTreeDirFormat()
 
     _matchingbzrdir = property(__get_matchingbzrdir)
 
     def get_format_description(self):
-        return "Subversion Working Copy"
+        return "Subversion Working Copy Version %d" % self.version
 
     def get_format_string(self):
-        return "Subversion Working Copy Format"
+        raise NotImplementedError
 
     def initialize(self, a_bzrdir, revision_id=None):
         raise NotImplementedError(self.initialize)




More information about the bazaar-commits mailing list