264
264
except shutil.Error:
265
265
raise ActionError("Could not move the file specified")
267
def svn_movefile(req, frompath, topath, copy=False):
268
"""Performs an svn move, resolving filenames, checking for any errors,
269
and throwing ActionErrors if necessary. Can also be used to do a copy
272
frompath and topath are straight paths from the client. Will be checked.
274
if frompath is None or topath is None:
275
raise ActionError("Required field missing")
276
frompath = actionpath_to_local(req, frompath)
277
topath = actionpath_to_local(req, topath)
278
if not os.path.exists(frompath):
279
raise ActionError("The source file does not exist")
280
if os.path.exists(topath):
281
if frompath == topath:
282
raise ActionError("Source and destination are the same")
283
raise ActionError("A file already exists with that name")
287
svnclient.copy(frompath, topath)
289
svnclient.move(frompath, topath)
291
raise ActionError("Could not move the file specified")
292
except pysvn.ClientError:
293
raise ActionError("Could not move the file specified")
269
298
def action_delete(req, fields):
445
474
files = fields.getlist('file')
446
475
if dst is None or src is None or mode is None:
447
476
raise ActionError("Required field missing")
453
raise ActionError("Invalid mode (must be 'copy' or 'move')")
454
478
dst_local = actionpath_to_local(req, dst)
455
479
if not os.path.isdir(dst_local):
456
480
raise ActionError("dst is not a directory")
465
489
# The destination is found by taking just the basename of the file
466
490
topath = os.path.join(dst, os.path.basename(file))
468
movefile(req, frompath, topath, copy)
493
movefile(req, frompath, topath, True)
495
movefile(req, frompath, topath, False)
496
elif mode == "svncopy":
497
svn_movefile(req, frompath, topath, True)
498
elif mode == "svnmove":
499
svn_movefile(req, frompath, topath, False)
501
raise ActionError("Invalid mode (must be '(svn)copy' or '(svn)move')")
469
502
except ActionError, message:
470
503
# Store the error for later; we want to copy as many as possible
471
504
if errormsg is None:
710
743
raise util.IVLEError(404, 'The specified repository path does not exist')
712
745
raise ActionError(str(e[0]))
714
748
# Table of all action functions #
715
749
# Each function has the interface f(req, fields).