Rev 1251: use own delta implementation. in file:///data/jelmer/bzr-svn/0.4-ra-cext/

Jelmer Vernooij jelmer at samba.org
Sat Jun 21 21:50:14 BST 2008


At file:///data/jelmer/bzr-svn/0.4-ra-cext/

------------------------------------------------------------
revno: 1251
revision-id: jelmer at samba.org-20080621205013-3uf156ai3y84hl8n
parent: jelmer at samba.org-20080621204702-ki86mzo0xn0x433m
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4-ra-cext
timestamp: Sat 2008-06-21 22:50:13 +0200
message:
  use own delta implementation.
removed:
  delta.py                       delta.py-20080617225125-jeg43afui0czkuwk-1
added:
  delta.py                       delta.py-20080316001917-xyng7m3jlxvdc4c9-1
=== added file 'delta.py'
--- a/delta.py	1970-01-01 00:00:00 +0000
+++ b/delta.py	2008-06-21 20:50:13 +0000
@@ -0,0 +1,42 @@
+# Copyright (C) 2005-2006 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+"""Subversion delta operations."""
+
+def apply_txdelta_handler(sbuf, target_stream):
+    def apply_window(window):
+        (sview_offset, sview_len, tview_len, src_ops, ops, new_data) = window
+        sview = sbuf[sview_offset:sview_offset+sview_len]
+        tview = txdelta_apply_ops(src_ops, ops, new_data, sview)
+        assert len(tview) == tview_len
+        target_stream.write(tview)
+    return apply_window
+
+
+def txdelta_apply_ops(src_ops, ops, new_data, sview):
+    tview = ""
+    for (action, offset, length) in ops:
+        if action == 0:
+            # Copy from source area.
+            tview += sview[offset:offset+length]
+        elif action == 1:
+            for i in xrange(length):
+                tview += tview[offset+i]
+        elif action == 2:
+            tview += new_data[offset:offset+length]
+        else:
+            raise Exception("Invalid delta instruction code")
+
+    return tview

=== removed file 'delta.py'
--- a/delta.py	2008-06-19 13:58:42 +0000
+++ b/delta.py	1970-01-01 00:00:00 +0000
@@ -1,46 +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/>.
-
-# Deal with Subversion 1.5 and the patched Subversion 1.4 (which are 
-# slightly different).
-
-from cStringIO import StringIO
-import svn.delta
-
-if getattr(svn.delta, 'tx_invoke_window_handler', None):
-    def apply_txdelta_handler(sbuf, target_stream):
-        src_stream = StringIO(sbuf)
-        assert getattr(src_stream, 'read', None) is not None
-        assert getattr(target_stream, 'write', None) is not None
-        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 getattr(src_stream, 'read', None) is not None
-        assert getattr(target_stream, 'write', None) is not None
-        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
-




More information about the bazaar-commits mailing list