144
144
from ivle import (util, studpath, zip)
145
145
from ivle.fileservice_lib.exceptions import WillNotOverwrite
149
def get_login(_realm, existing_login, _may_save):
150
"""Callback function used by pysvn for authentication.
151
realm, existing_login, _may_save: The 3 arguments passed by pysvn to
153
The following has been determined empirically, not from docs:
154
existing_login will be the name of the user who owns the process on
155
the first attempt, "" on subsequent attempts. We use this fact.
157
# Only provide credentials on the _first_ attempt.
158
# If we're being asked again, then it means the credentials failed for
159
# some reason and we should just fail. (This is not desirable, but it's
160
# better than being asked an infinite number of times).
161
return (existing_login != "", str(ivle.conf.login),
162
str(ivle.conf.svn_pass), True)
164
# Make a Subversion client object
165
svnclient = pysvn.Client()
166
svnclient.callback_get_login = get_login
149
# Make a Subversion client object (which will log in with this user's
150
# credentials, upon request)
151
svnclient = ivle.svn.create_auth_svn_client(username=ivle.conf.login,
152
password=ivle.conf.svn_pass)
167
153
svnclient.exception_style = 0 # Simple (string) exceptions
169
155
DEFAULT_LOGMESSAGE = "No log message supplied."
732
718
url = ivle.conf.svn_addr + "/" + urllib.quote(paths[0])
733
719
local_path = actionpath_to_local(req, str(paths[1]))
735
svnclient.callback_get_login = get_login
736
721
svnclient.checkout(url, local_path, recurse=True)
737
722
except pysvn.ClientError, e:
738
723
raise ActionError(str(e))
745
730
path = fields.getfirst('path')
746
731
logmsg = fields.getfirst('logmsg')
747
url = ivle.conf.svn_addr + "/" + path
732
url = ivle.conf.svn_addr + "/" + urllib.quote(path)
749
svnclient.callback_get_login = get_login
750
734
svnclient.mkdir(url, log_message=logmsg)
751
735
except pysvn.ClientError, e:
752
736
raise ActionError(str(e))
759
743
Reads fields: 'path'
761
745
path = fields.getfirst('path')
762
url = ivle.conf.svn_addr + "/" + path
746
url = ivle.conf.svn_addr + "/" + urllib.quote(path)
763
747
svnclient.exception_style = 1
766
svnclient.callback_get_login = get_login
767
750
info = svnclient.info2(url,
768
751
revision=pysvn.Revision(pysvn.opt_revision_kind.head))[0][1]
769
752
return {'svnrevision': info['rev'].number