144
144
from ivle import (util, studpath, zip)
145
145
from ivle.fileservice_lib.exceptions import WillNotOverwrite
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)
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
153
167
svnclient.exception_style = 0 # Simple (string) exceptions
155
169
DEFAULT_LOGMESSAGE = "No log message supplied."
718
732
url = ivle.conf.svn_addr + "/" + urllib.quote(paths[0])
719
733
local_path = actionpath_to_local(req, str(paths[1]))
735
svnclient.callback_get_login = get_login
721
736
svnclient.checkout(url, local_path, recurse=True)
722
737
except pysvn.ClientError, e:
723
738
raise ActionError(str(e))
730
745
path = fields.getfirst('path')
731
746
logmsg = fields.getfirst('logmsg')
732
url = ivle.conf.svn_addr + "/" + urllib.quote(path)
747
url = ivle.conf.svn_addr + "/" + path
749
svnclient.callback_get_login = get_login
734
750
svnclient.mkdir(url, log_message=logmsg)
735
751
except pysvn.ClientError, e:
736
752
raise ActionError(str(e))
743
759
Reads fields: 'path'
745
761
path = fields.getfirst('path')
746
url = ivle.conf.svn_addr + "/" + urllib.quote(path)
762
url = ivle.conf.svn_addr + "/" + path
747
763
svnclient.exception_style = 1
766
svnclient.callback_get_login = get_login
750
767
info = svnclient.info2(url,
751
768
revision=pysvn.Revision(pysvn.opt_revision_kind.head))[0][1]
752
769
return {'svnrevision': info['rev'].number