Prechádzať zdrojové kódy

Merge tag 'upstream/0.10.1' into debian

Upstream version 0.10.1
Jelmer Vernooij 10 rokov pred
rodič
commit
de3633ae15

+ 1 - 0
MANIFEST.in

@@ -4,6 +4,7 @@ include README.md
 include Makefile
 include COPYING
 include HACKING
+include setup.cfg
 include dulwich/stdint.h
 recursive-include docs conf.py *.txt Makefile make.bat
 recursive-include examples *.py

+ 8 - 0
NEWS

@@ -1,3 +1,11 @@
+0.10.1  2015-03-25
+
+ BUG FIXES
+
+  * Return `ApplyDeltaError` when encountering delta errors
+    in both C extensions and native delta application code.
+    (Jelmer Vernooij, #259)
+
 0.10.0	2015-03-22
 
  BUG FIXES

+ 1 - 1
PKG-INFO

@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: dulwich
-Version: 0.10.0
+Version: 0.10.1a
 Summary: Python Git Library
 Home-page: https://samba.org/~jelmer/dulwich
 Author: Jelmer Vernooij

+ 1 - 1
dulwich.egg-info/PKG-INFO

@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: dulwich
-Version: 0.10.0
+Version: 0.10.1a
 Summary: Python Git Library
 Home-page: https://samba.org/~jelmer/dulwich
 Author: Jelmer Vernooij

+ 1 - 1
dulwich/__init__.py

@@ -21,4 +21,4 @@
 
 """Python implementation of the Git file formats and protocols."""
 
-__version__ = (0, 10, 0)
+__version__ = (0, 10, 1)

+ 15 - 4
dulwich/_pack.c

@@ -20,6 +20,8 @@
 #include <Python.h>
 #include <stdint.h>
 
+static PyObject *PyExc_ApplyDeltaError = NULL;
+
 static int py_is_sha(PyObject *sha)
 {
 	if (!PyString_CheckExact(sha))
@@ -103,7 +105,7 @@ static PyObject *py_apply_delta(PyObject *self, PyObject *args)
 	index = 0;
 	src_size = get_delta_header_size(delta, &index, delta_len);
 	if (src_size != src_buf_len) {
-		PyErr_Format(PyExc_ValueError, 
+		PyErr_Format(PyExc_ApplyDeltaError,
 					 "Unexpected source buffer size: %lu vs %d", src_size, src_buf_len);
 		Py_DECREF(py_src_buf);
 		Py_DECREF(py_delta);
@@ -155,7 +157,7 @@ static PyObject *py_apply_delta(PyObject *self, PyObject *args)
 			index += cmd;
 			dest_size -= cmd;
 		} else {
-			PyErr_SetString(PyExc_ValueError, "Invalid opcode 0");
+			PyErr_SetString(PyExc_ApplyDeltaError, "Invalid opcode 0");
 			Py_DECREF(ret);
 			Py_DECREF(py_delta);
 			Py_DECREF(py_src_buf);
@@ -166,13 +168,13 @@ static PyObject *py_apply_delta(PyObject *self, PyObject *args)
 	Py_DECREF(py_delta);
 
 	if (index != delta_len) {
-		PyErr_SetString(PyExc_ValueError, "delta not empty");
+		PyErr_SetString(PyExc_ApplyDeltaError, "delta not empty");
 		Py_DECREF(ret);
 		return NULL;
 	}
 
 	if (dest_size != 0) {
-		PyErr_SetString(PyExc_ValueError, "dest size incorrect");
+		PyErr_SetString(PyExc_ApplyDeltaError, "dest size incorrect");
 		Py_DECREF(ret);
 		return NULL;
 	}
@@ -240,6 +242,15 @@ static PyMethodDef py_pack_methods[] = {
 void init_pack(void)
 {
 	PyObject *m;
+	PyObject *errors_module;
+
+	errors_module = PyImport_ImportModule("dulwich.errors");
+	if (errors_module == NULL)
+		return;
+
+	PyExc_ApplyDeltaError = PyObject_GetAttrString(errors_module, "ApplyDeltaError");
+	if (PyExc_ApplyDeltaError == NULL)
+		return;
 
 	m = Py_InitModule3("_pack", py_pack_methods, NULL);
 	if (m == NULL)

+ 1 - 1
dulwich/tests/test_diff_tree.py

@@ -96,7 +96,7 @@ class TreeChangesTest(DiffTestCase):
     def assertMergeFails(self, merge_entries, name, mode, sha):
         t = Tree()
         t[name] = (mode, sha)
-        self.assertRaises(TypeError, merge_entries, '', t, t)
+        self.assertRaises((TypeError, ValueError), merge_entries, '', t, t)
 
     def _do_test_merge_entries(self, merge_entries):
         blob_a1 = make_object(Blob, data=b'a1')

+ 2 - 4
dulwich/tests/test_object_store.py

@@ -32,9 +32,7 @@ from dulwich.errors import (
     )
 from dulwich.objects import (
     sha_to_hex,
-    object_class,
     Blob,
-    Tag,
     Tree,
     TreeEntry,
     )
@@ -237,7 +235,7 @@ class MemoryObjectStoreTests(ObjectStoreTests, TestCase):
 
         f = BytesIO()
         entries = build_pack(f, [], store=o)
-        self.assertEquals([], entries)
+        self.assertEqual([], entries)
         o.add_thin_pack(f.read, None)
 
 
@@ -353,7 +351,7 @@ class DiskObjectStoreTests(PackBasedObjectStoreTests, TestCase):
 
         f = BytesIO()
         entries = build_pack(f, [], store=o)
-        self.assertEquals([], entries)
+        self.assertEqual([], entries)
         o.add_thin_pack(f.read, None)
 
 

+ 3 - 2
dulwich/tests/test_pack.py

@@ -28,6 +28,7 @@ import tempfile
 import zlib
 
 from dulwich.errors import (
+    ApplyDeltaError,
     ChecksumMismatch,
     )
 from dulwich.file import (
@@ -193,10 +194,10 @@ class TestPackDeltas(TestCase):
 
     def test_dest_overflow(self):
         self.assertRaises(
-            ValueError,
+            ApplyDeltaError,
             apply_delta, 'a'*0x10000, '\x80\x80\x04\x80\x80\x04\x80' + 'a'*0x10000)
         self.assertRaises(
-            ValueError,
+            ApplyDeltaError,
             apply_delta, '', '\x00\x80\x02\xb0\x11\x11')
 
 

+ 3 - 3
dulwich/tests/test_porcelain.py

@@ -661,13 +661,13 @@ class ReceivePackTests(PorcelainTestCase):
 class BranchListTests(PorcelainTestCase):
 
     def test_standard(self):
-        self.assertEquals(set([]), set(porcelain.branch_list(self.repo)))
+        self.assertEqual(set([]), set(porcelain.branch_list(self.repo)))
 
     def test_new_branch(self):
         [c1] = build_commit_graph(self.repo.object_store, [[1]])
         self.repo["HEAD"] = c1.id
         porcelain.branch_create(self.repo, "foo")
-        self.assertEquals(
+        self.assertEqual(
             set(["master", "foo"]),
             set(porcelain.branch_list(self.repo)))
 
@@ -686,7 +686,7 @@ class BranchCreateTests(PorcelainTestCase):
         [c1] = build_commit_graph(self.repo.object_store, [[1]])
         self.repo["HEAD"] = c1.id
         porcelain.branch_create(self.repo, "foo")
-        self.assertEquals(
+        self.assertEqual(
             set(["master", "foo"]),
             set(porcelain.branch_list(self.repo)))
 

+ 1 - 1
setup.py

@@ -8,7 +8,7 @@ except ImportError:
     from distutils.core import setup, Extension
 from distutils.core import Distribution
 
-dulwich_version_string = '0.10.0'
+dulwich_version_string = '0.10.1a'
 
 include_dirs = []
 # Windows MSVC support