263
263
except shutil.Error:
264
264
raise ActionError("Could not move the file specified")
266
def svn_movefile(req, frompath, topath, copy=False):
267
"""Performs an svn move, resolving filenames, checking for any errors,
268
and throwing ActionErrors if necessary. Can also be used to do a copy
271
frompath and topath are straight paths from the client. Will be checked.
273
if frompath is None or topath is None:
274
raise ActionError("Required field missing")
275
frompath = actionpath_to_local(req, frompath)
276
topath = actionpath_to_local(req, topath)
277
if not os.path.exists(frompath):
278
raise ActionError("The source file does not exist")
279
if os.path.exists(topath):
280
if frompath == topath:
281
raise ActionError("Source and destination are the same")
282
raise ActionError("A file already exists with that name")
286
svnclient.copy(frompath, topath)
288
svnclient.move(frompath, topath)
290
raise ActionError("Could not move the file specified")
291
except pysvn.ClientError:
292
raise ActionError("Could not move the file specified")
268
297
def action_delete(req, fields):
444
473
files = fields.getlist('file')
445
474
if dst is None or src is None or mode is None:
446
475
raise ActionError("Required field missing")
452
raise ActionError("Invalid mode (must be 'copy' or 'move')")
453
477
dst_local = actionpath_to_local(req, dst)
454
478
if not os.path.isdir(dst_local):
455
479
raise ActionError("dst is not a directory")
464
488
# The destination is found by taking just the basename of the file
465
489
topath = os.path.join(dst, os.path.basename(file))
467
movefile(req, frompath, topath, copy)
492
movefile(req, frompath, topath, True)
494
movefile(req, frompath, topath, False)
495
elif mode == "svncopy":
496
svn_movefile(req, frompath, topath, True)
497
elif mode == "svnmove":
498
svn_movefile(req, frompath, topath, False)
500
raise ActionError("Invalid mode (must be '(svn)copy' or '(svn)move')")
468
501
except ActionError, message:
469
502
# Store the error for later; we want to copy as many as possible
470
503
if errormsg is None:
709
742
raise util.IVLEError(404, 'The specified repository path does not exist')
711
744
raise ActionError(str(e[0]))
713
747
# Table of all action functions #
714
748
# Each function has the interface f(req, fields).