104
104
# action=svnupdate: Bring a file up to date with the head revision.
105
# path: The path to the file to be updated. Can be specified multiple
105
# path: The path to the file to be updated. Only one file may be
108
# action=svnpublish: Set the "published" flag on a file to True.
109
# path: The path to the file to be published. Can be specified
112
# action=svnunpublish: Set the "published" flag on a file to False.
113
# path: The path to the file to be unpublished. Can be specified
108
116
# action=svncommit: Commit a file(s) or directory(s) to the repository.
109
117
# path: The path to the file or directory to be committed. Can be
281
289
Reads fields: 'path', 'data' (file upload)
291
# Important: Data is "None" if the file submitted is empty.
283
292
path = fields.getfirst('path')
284
293
data = fields.getfirst('data')
285
if path is None or data is None:
286
295
raise ActionError("Required field missing")
287
296
path = actionpath_to_local(req, path)
290
300
# Copy the contents of file object 'data' to the path 'path'
292
302
dest = open(path, 'wb')
293
shutil.copyfileobj(data, dest)
304
shutil.copyfileobj(data, dest)
295
306
raise ActionError("Could not write to target file")
427
438
except pysvn.ClientError:
428
439
raise ActionError("One or more files could not be reverted")
441
def action_svnpublish(req, fields):
442
"""Sets svn property "ivle:published" on each file specified.
443
Should only be called on directories (only effective on directories
448
paths = fields.getlist('path')
449
paths = map(lambda path: actionpath_to_local(req, path), paths)
453
# Note: Property value doesn't matter
454
svnclient.propset("ivle:published", "", path, recurse=False)
455
except pysvn.ClientError:
456
raise ActionError("One or more files could not be updated")
458
def action_svnunpublish(req, fields):
459
"""Deletes svn property "ivle:published" on each file specified.
463
paths = fields.getlist('path')
464
paths = map(lambda path: actionpath_to_local(req, path), paths)
468
svnclient.propdel("ivle:published", path, recurse=False)
469
except pysvn.ClientError:
470
raise ActionError("One or more files could not be updated")
430
472
def action_svncommit(req, fields):
431
473
"""Performs a "svn commit" to each file specified.
457
499
"svnadd" : action_svnadd,
458
500
"svnupdate" : action_svnupdate,
459
501
"svnrevert" : action_svnrevert,
502
"svnpublish" : action_svnpublish,
503
"svnunpublish" : action_svnunpublish,
460
504
"svncommit" : action_svncommit,