Various fixes for running on svn 1.5.
authorJelmer Vernooij <jelmer@jelmer.uk>
Tue, 22 May 2018 21:25:27 +0000 (22:25 +0100)
committerJelmer Vernooij <jelmer@jelmer.uk>
Tue, 22 May 2018 21:25:27 +0000 (22:25 +0100)
subvertpy/properties.py
subvertpy/ra_svn.py
subvertpy/repos.c
subvertpy/tests/test_marshall.py
subvertpy/tests/test_repos.py
subvertpy/tests/test_subr.py
subvertpy/tests/test_wc.py
subvertpy/util.c
subvertpy/wc_adm.c

index 567f60cce2b8c0ceeb686a676cae3d15d6857124..8f256f5fe26054b43c816b83d60ab35ed2d6a601 100644 (file)
@@ -85,10 +85,10 @@ def parse_externals_description(base_url, val):
     def is_url(u):
         return ("://" in u)
     ret = {}
-    for l in val.splitlines():
-        if l == "" or l[0] == "#":
+    for line in val.splitlines():
+        if line == "" or line[0] == "#":
             continue
-        pts = l.rsplit(None, 3)
+        pts = line.rsplit(None, 3)
         if len(pts) == 4:
             if pts[0] == "-r":  # -r X URL DIR
                 revno = int(pts[1])
@@ -137,8 +137,8 @@ def parse_mergeinfo_property(text):
     :param text: Property contents
     """
     ret = {}
-    for l in text.splitlines():
-        (path, ranges) = l.rsplit(":", 1)
+    for line in text.splitlines():
+        (path, ranges) = line.rsplit(":", 1)
         assert path.startswith("/")
         ret[path] = []
         for range in ranges.split(","):
index 3e61e283834d80003514f4310a774ee4371a1e50..af6f2f1416db623542dc5ff673bd08081ecefd0f 100644 (file)
@@ -745,7 +745,7 @@ class SVNClient(SVNConnection):
             self.send_msg([literal("switch"), args])
             self._recv_ack()
             return Reporter(self, update_editor)
-        except:
+        except BaseException:
             self.busy = False
             raise
 
@@ -766,7 +766,7 @@ class SVNClient(SVNConnection):
             self.send_msg([literal("update"), args])
             self._recv_ack()
             return Reporter(self, update_editor)
-        except:
+        except BaseException:
             self.busy = False
             raise
 
@@ -787,7 +787,7 @@ class SVNClient(SVNConnection):
             self.send_msg([literal("diff"), args])
             self._recv_ack()
             return Reporter(self, diff_editor)
-        except:
+        except BaseException:
             self.busy = False
             raise
 
index 43279683a3bb6db529c1e93c3b42c433d3a48978..61006ab81674ebc1da6eff45bdf64257439c5f29 100644 (file)
@@ -511,9 +511,11 @@ static svn_error_t *py_pack_notify(void *baton, apr_int64_t shard, svn_fs_pack_n
        Py_DECREF(ret);
        return NULL;
 }
+#endif
 
 static PyObject *repos_pack(RepositoryObject *self, PyObject *args)
 {
+#if ONLY_SINCE_SVN(1, 6)
        apr_pool_t *temp_pool;
        PyObject *notify_func = Py_None;
        if (!PyArg_ParseTuple(args, "|O", &notify_func))
@@ -527,8 +529,11 @@ static PyObject *repos_pack(RepositoryObject *self, PyObject *args)
        apr_pool_destroy(temp_pool);
 
        Py_RETURN_NONE;
-}
+#else
+       PyErr_SetString(PyExc_NotImplementedError, "pack_fs is only supported in Subversion >= 1.6");
+    return NULL;
 #endif
+}
 
 static PyMethodDef repos_methods[] = {
        { "load_fs", (PyCFunction)repos_load_fs, METH_VARARGS|METH_KEYWORDS, NULL },
@@ -536,9 +541,7 @@ static PyMethodDef repos_methods[] = {
        { "has_capability", (PyCFunction)repos_has_capability, METH_VARARGS, NULL },
        { "verify_fs", (PyCFunction)repos_verify, METH_VARARGS,
                "S.verify_repos(feedback_stream, start_revnum, end_revnum)" },
-#if ONLY_SINCE_SVN(1, 6)
        { "pack_fs", (PyCFunction)repos_pack, METH_VARARGS, NULL },
-#endif
        { NULL, }
 };
 
index 751276f2258956646e5b1c91c56eb779e2c0aa10..47d659dcc0ed90a17ba9257b2af74beab2497241 100644 (file)
@@ -28,20 +28,20 @@ from subvertpy.tests import TestCase
 class TestMarshalling(TestCase):
 
     def test_literal_txt(self):
-        l = literal("foo")
-        self.assertEqual("foo", l.txt)
+        line = literal("foo")
+        self.assertEqual("foo", line.txt)
 
     def test_literal_str(self):
-        l = literal("foo bar")
-        self.assertEqual("foo bar", l.__str__())
+        line = literal("foo bar")
+        self.assertEqual("foo bar", line.__str__())
 
     def test_literal_rep(self):
-        l = literal("foo bar")
-        self.assertEqual("foo bar", l.__repr__())
+        line = literal("foo bar")
+        self.assertEqual("foo bar", line.__repr__())
 
     def test_marshall_error(self):
-        e = MarshallError("bla bla")
-        self.assertEqual("bla bla", e.__str__())
+        err = MarshallError("bla bla")
+        self.assertEqual("bla bla", err.__str__())
 
     def test_marshall_int(self):
         self.assertEqual(b"1 ", marshall(1))
index ed5f2067fa2a2fba5030e7bac1815bdad8de734c..d748df91c397b4c3e7f5c7eae3156fb0ffc1a7be 100644 (file)
@@ -117,7 +117,10 @@ class TestRepository(TestCaseInTempDir):
 
     def test_pack_fs(self):
         r = repos.create(os.path.join(self.test_dir, "foo"))
-        r.pack_fs()
+        if repos.api_version() < (1, 6):
+            self.assertRaises(NotImplementedError, r.pack_fs)
+        else:
+            r.pack_fs()
 
     def test_paths_changed(self):
         repos.create(os.path.join(self.test_dir, "foo"))
index b80290f04541f70aa50310b21655446524c83f59..a7c517ddea304ebfff795224d7abd15edfefb29d 100644 (file)
@@ -24,7 +24,7 @@ class UriCanonicalizeTests(TestCase):
 
     def test_canonicalize(self):
         self.assertEqual(
-                'https://www.example.com',
+                'https://www.example.com/',
                 uri_canonicalize('https://www.example.com/'))
         self.assertEqual(
                 'https://www.example.com(bla)',
index ca46fec287b4be819e22a1cfeda4f8544e4f2746..b236dea089ecb47debb344f1c76b69698fe6ec52 100644 (file)
@@ -160,7 +160,10 @@ class AdmObjTests(SubversionTestCase):
         adm = wc.Adm(None, "checkout", True)
         path = os.path.join(self.test_dir, "checkout/bar")
         stream = adm.translated_stream(path, path, wc.TRANSLATE_TO_NF)
-        self.assertTrue(stream.read().startswith(b"My id: $Id: "))
+        if wc.api_version() < (1, 6):
+            self.assertRaises(NotImplementedError, stream.read)
+        else:
+            self.assertTrue(stream.read().startswith(b"My id: $Id: "))
 
     def test_text_modified(self):
         self.make_client("repos", "checkout")
@@ -323,6 +326,11 @@ class AdmObjTests(SubversionTestCase):
 
 class ContextTests(SubversionTestCase):
 
+    def setUp(self):
+        super(ContextTests, self).setUp()
+        if wc.api_version() < (1, 7):
+            self.skipTest("context API not available on Subversion < 1.7")
+
     def test_create(self):
         context = wc.Context()
         self.assertIsInstance(context, wc.Context)
index d7dadd3f85451ddc752bdc2ebc2d432ff4b65852..2700c65e03c54b49d40e41119a12f0d434a11845 100644 (file)
@@ -47,7 +47,7 @@ const char *
 svn_uri_canonicalize(const char *uri,
                      apr_pool_t *result_pool)
 {
-       return svn_path_canonicalize(uri, result_pool);
+       return svn_path_uri_from_iri(uri, result_pool);
 }
 
 const char *
index ab8cf3066951153ebbd7bf1c39710cf77af63586..437a544256b8dd83959ea7c8d43cbc4ebbba088a 100644 (file)
@@ -2007,6 +2007,10 @@ static PyObject *py_entry(const svn_wc_entry_t *entry)
 {
        EntryObject *ret;
 
+       if (entry == NULL) {
+               Py_RETURN_NONE;
+       }
+
        ret = PyObject_New(EntryObject, &Entry_Type);
        if (ret == NULL)
                return NULL;