hash_lock_tokens = NULL;
} else {
Py_ssize_t idx = 0;
+ char *key, *val;
PyObject *k, *v;
hash_lock_tokens = apr_hash_make(pool);
while (PyDict_Next(lock_tokens, &idx, &k, &v)) {
- if (!PyBytes_Check(k)) {
- PyErr_SetString(PyExc_TypeError, "token not bytes");
+ key = py_object_to_svn_string(k, pool);
+ if (key == NULL) {
goto fail_prep;
}
- apr_hash_set(hash_lock_tokens, PyBytes_AsString(k),
- PyBytes_Size(k), PyBytes_AsString(v));
+ val = apr_pmemdup(pool, PyBytes_AsString(v), PyBytes_Size(v));
+ apr_hash_set(hash_lock_tokens, key, strlen(key), val);
}
}
self.client_set_prop("checkout/bar", "svn:keywords", "Id\n")
self.client_commit("checkout", "foo")
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)
- if wc.api_version() < (1, 6):
- self.assertRaises(NotImplementedError, stream.read)
- else:
- self.assertTrue(stream.read().startswith(b"My id: $Id: "))
+ stream = adm.translated_stream('checkout/bar', 'checkout/bar', wc.TRANSLATE_TO_NF)
+ body = stream.read()
+ self.assertTrue(body.startswith(b"My id: $Id: "), body)
def test_text_modified(self):
self.make_client("repos", "checkout")
self.assertEqual("bar", bar.name)
self.assertEqual(NODE_FILE, bar.kind)
self.assertEqual(wc.SCHEDULE_NORMAL, bar.schedule)
- self.assertIn(bar.checksum, (None, hashlib.md5('blala').hexdigest()))
+ self.assertIn(bar.checksum, (None, hashlib.md5(b'blala').hexdigest()))
self.assertEqual(1, bar.cmt_rev)
self.assertEqual(1, bar.revision)
if (PyDict_SetItem(py_props, py_key, py_val) != 0) {
Py_DECREF(py_key);
Py_DECREF(py_val);
- Py_DECREF(py_props);
- apr_pool_destroy(pool);
- return NULL;
+ goto fail_item;
}
Py_DECREF(py_key);
Py_DECREF(py_val);
while (PyDict_Next(py_props, &idx, &k, &v)) {
char *key, *val;
- Py_ssize_t key_size, val_size;
- if (PyUnicode_Check(k)) {
- k = PyUnicode_AsUTF8String(k);
- } else {
- Py_INCREF(k);
- }
+ Py_ssize_t val_size;
- if (!PyBytes_Check(k)) {
- PyErr_SetString(PyExc_TypeError,
- "property name should be unicode or byte string");
- Py_DECREF(k);
+ key = py_object_to_svn_string(k, pool);
+ if (key == NULL) {
return NULL;
}
Py_INCREF(v);
}
- if (PyBytes_AsStringAndSize(k, &key, &key_size) == -1) {
- PyErr_SetString(PyExc_TypeError,
- "property key should be unicode or byte string");
- Py_DECREF(k);
- Py_DECREF(v);
- return NULL;
- }
-
if (PyBytes_AsStringAndSize(v, &val, &val_size) == -1) {
PyErr_SetString(PyExc_TypeError,
"property value should be unicode or byte string");
- Py_DECREF(k);
- Py_DECREF(v);
return NULL;
}
val_string = svn_string_ncreate(val, val_size, pool);
- apr_hash_set(hash_props, key, key_size, val_string);
- Py_DECREF(k);
+
Py_DECREF(v);
+
+ apr_hash_set(hash_props, key, strlen(key), val_string);
}
return hash_props;
{ "get_ancestry", (PyCFunction)get_ancestry, METH_VARARGS,
"S.get_ancestry(path) -> (url, rev)" },
{ "maybe_set_repos_root", (PyCFunction)maybe_set_repos_root, METH_VARARGS, "S.maybe_set_repos_root(path, repos)" },
- { "add_repos_file", (PyCFunction)add_repos_file, METH_KEYWORDS,
+ { "add_repos_file", (PyCFunction)add_repos_file, METH_KEYWORDS|METH_VARARGS,
"S.add_repos_file(dst_path, new_base_contents, new_contents, new_base_props, new_props, copyfrom_url=None, copyfrom_rev=-1, notify_func=None)" },
{ "mark_missing_deleted", (PyCFunction)mark_missing_deleted, METH_VARARGS,
"S.mark_missing_deleted(path)" },