Rev 1253: Use auth code from client.c. in file:///data/jelmer/bzr-svn/0.4-ra-cext/

Jelmer Vernooij jelmer at samba.org
Sat Jun 21 22:44:05 BST 2008


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

------------------------------------------------------------
revno: 1253
revision-id: jelmer at samba.org-20080621214404-nlo0nm99vm8ju1or
parent: jelmer at samba.org-20080621210709-rige4bhwd07t32gs
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4-ra-cext
timestamp: Sat 2008-06-21 23:44:04 +0200
message:
  Use auth code from client.c.
added:
  ra.h                           ra.h-20080621214350-wlaxxs087eiu02me-1
modified:
  client.c                       client.pyx-20080313235339-wbyjbw2namuiql8f-1
  ra.c                           ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
=== modified file 'client.c'
--- a/client.c	2008-06-21 21:07:09 +0000
+++ b/client.c	2008-06-21 21:44:04 +0000
@@ -24,9 +24,12 @@
 #include <svn_config.h>
 
 #include "util.h"
+#include "ra.h"
 
 PyAPI_DATA(PyTypeObject) Client_Type;
 
+static int client_set_auth(PyObject *self, PyObject *auth, void *closure);
+
 static bool to_opt_revision(PyObject *arg, svn_opt_revision_t *ret)
 {
     if (PyInt_Check(arg)) {
@@ -134,13 +137,13 @@
     svn_client_ctx_t *client;
     apr_pool_t *pool;
     PyObject *callbacks;
+	PyObject *py_auth;
 } ClientObject;
 
 static PyObject *client_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
 {
     ClientObject *ret;
 	PyObject *config = Py_None, *auth = Py_None;
-	apr_array_header_t *auth_providers;
     char *kwnames[] = { "config", "auth", NULL };
     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO", kwnames, &config, &auth))
         return NULL;
@@ -166,18 +169,8 @@
 		return NULL;
 	}
 
-	if (auth != Py_None) {
-		PyErr_SetString(PyExc_NotImplementedError, "custom auth not supported yet");
-		return NULL;
-	}
-
-    auth_providers = apr_array_make(ret->pool, 0, 4);
-	if (auth_providers == NULL) {
-		PyErr_NoMemory();
-		return NULL;
-	}
-	svn_auth_open(&ret->client->auth_baton, auth_providers, ret->pool);
-
+	ret->py_auth = NULL;
+	client_set_auth((PyObject *)ret, auth, NULL);
     return (PyObject *)ret;
 }
 
@@ -187,6 +180,7 @@
 	if (client->client->log_msg_func2 != NULL) {
 		Py_DECREF((PyObject *)client->client->log_msg_baton2);
 	}
+	Py_XDECREF(client->py_auth);
     apr_pool_destroy(client->pool);
 	PyObject_Del(self);
 }
@@ -217,6 +211,31 @@
     return 0;
 }
 
+static int client_set_auth(PyObject *self, PyObject *auth, void *closure)
+{
+	ClientObject *client = (ClientObject *)self;
+	apr_array_header_t *auth_providers;
+
+	Py_XDECREF(client->py_auth);
+
+	if (auth == Py_None) {
+		auth_providers = apr_array_make(client->pool, 0, 4);
+		if (auth_providers == NULL) {
+			PyErr_NoMemory();
+			return 1;
+		}
+		svn_auth_open(&client->client->auth_baton, auth_providers, client->pool);
+	} else {
+		client->client->auth_baton = ((AuthObject *)auth)->auth_baton;
+	}
+
+	client->py_auth = auth;
+	Py_INCREF(auth);
+
+	return 0;
+}
+
+
 static PyObject *client_add(PyObject *self, PyObject *args, PyObject *kwargs)
 {
     char *path; 
@@ -575,6 +594,7 @@
 
 static PyGetSetDef client_getset[] = {
 	{ "log_msg_func", client_get_log_msg_func, client_set_log_msg_func, NULL },
+	{ "auth", NULL, client_set_auth, NULL },
 	{ NULL, }
 };
 

=== modified file 'ra.c'
--- a/ra.c	2008-06-21 20:44:24 +0000
+++ b/ra.c	2008-06-21 21:44:04 +0000
@@ -26,22 +26,15 @@
 
 #include "editor.h"
 #include "util.h"
+#include "ra.h"
 
 static PyObject *busy_exc;
 
 PyAPI_DATA(PyTypeObject) Reporter_Type;
 PyAPI_DATA(PyTypeObject) RemoteAccess_Type;
-PyAPI_DATA(PyTypeObject) Auth_Type;
 PyAPI_DATA(PyTypeObject) AuthProvider_Type;
 PyAPI_DATA(PyTypeObject) TxDeltaWindowHandler_Type;
 
-typedef struct {
-	PyObject_HEAD
-    svn_auth_baton_t *auth_baton;
-    apr_pool_t *pool;
-    PyObject *providers;
-} AuthObject;
-
 static svn_error_t *py_commit_callback(const svn_commit_info_t *commit_info, void *baton, apr_pool_t *pool)
 {
 	PyObject *fn = (PyObject *)baton, *ret;
@@ -1666,4 +1659,8 @@
     PyModule_AddIntConstant(mod, "DIRENT_TIME", SVN_DIRENT_TIME);
     PyModule_AddIntConstant(mod, "DIRENT_LAST_AUTHOR", SVN_DIRENT_LAST_AUTHOR);
     PyModule_AddIntConstant(mod, "DIRENT_ALL", SVN_DIRENT_ALL);
+
+#ifdef SVN_VER_REVISION
+	PyModule_AddIntConstant(mod, "SVN_REVISION", SVN_VER_REVISION);
+#endif
 }

=== added file 'ra.h'
--- a/ra.h	1970-01-01 00:00:00 +0000
+++ b/ra.h	2008-06-21 21:44:04 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright © 2008 Jelmer Vernooij <jelmer at samba.org>
+ * -*- coding: utf-8 -*-
+ *
+ * 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
+ */
+
+#ifndef _BZR_SVN_RA_H_
+#define _BZR_SVN_RA_H_
+
+PyAPI_DATA(PyTypeObject) Auth_Type;
+
+typedef struct {
+	PyObject_HEAD
+    svn_auth_baton_t *auth_baton;
+    apr_pool_t *pool;
+    PyObject *providers;
+} AuthObject;
+
+#endif /* _BZR_SVN_RA_H_ */




More information about the bazaar-commits mailing list