110
110
# path: The [repository] path to the file or directory to be
113
# action=svnrepomkdir: Create a directory in a repository (not WC).
114
# path: The path to the directory to be created (under the IVLE
116
# logmsg: Text of the log message.
118
# action=svnrepostat: Check if a path exists in a repository (not WC).
119
# path: The path to the directory to be checked (under the IVLE
122
113
# TODO: Implement the following actions:
123
114
# svnupdate (done?)
124
115
# TODO: Implement ZIP unpacking in putfiles (done?).
268
def action_delete(req, fields):
259
def action_remove(req, fields):
260
# TODO: Do an SVN rm if the file is versioned.
269
261
# TODO: Disallow removal of student's home directory
270
262
"""Removes a list of files or directories.
549
541
except pysvn.ClientError, e:
550
542
raise ActionError(str(e))
552
def action_svnremove(req, fields):
553
"""Performs a "svn remove" on each file specified.
555
Reads fields: 'path' (multiple)
557
paths = fields.getlist('path')
558
paths = map(lambda path: actionpath_to_local(req, path), paths)
561
svnclient.remove(paths, force=True)
562
except pysvn.ClientError, e:
563
raise ActionError(str(e))
565
544
def action_svnupdate(req, fields):
566
545
"""Performs a "svn update" to each file specified.
577
556
except pysvn.ClientError, e:
578
557
raise ActionError(str(e))
580
def action_svnresolved(req, fields):
581
"""Performs a "svn resolved" to each file specified.
585
path = fields.getfirst('path')
587
raise ActionError("Required field missing")
588
path = actionpath_to_local(req, path)
591
svnclient.resolved(path, recurse=True)
592
except pysvn.ClientError, e:
593
raise ActionError(str(e))
595
559
def action_svnrevert(req, fields):
596
560
"""Performs a "svn revert" to each file specified.
661
625
raise ActionError(str(e))
663
627
def action_svncheckout(req, fields):
664
"""Performs a "svn checkout" of the first path into the second path.
628
"""Performs a "svn checkout" of each path specified.
666
630
Reads fields: 'path' (multiple)
668
632
paths = fields.getlist('path')
669
633
if len(paths) != 2:
670
634
raise ActionError("usage: svncheckout url local-path")
671
url = conf.svn_addr + "/" + paths[0]
635
url = conf.svn_addr + "/" + login + "/" + paths[0]
672
636
local_path = actionpath_to_local(req, str(paths[1]))
674
638
svnclient.callback_get_login = get_login
676
640
except pysvn.ClientError, e:
677
641
raise ActionError(str(e))
679
def action_svnrepomkdir(req, fields):
680
"""Performs a "svn mkdir" on a path under the IVLE SVN root.
684
path = fields.getfirst('path')
685
logmsg = fields.getfirst('logmsg')
686
url = conf.svn_addr + "/" + path
688
svnclient.callback_get_login = get_login
689
svnclient.mkdir(url, log_message=logmsg)
690
except pysvn.ClientError, e:
691
raise ActionError(str(e))
693
def action_svnrepostat(req, fields):
694
"""Discovers whether a path exists in a repo under the IVLE SVN root.
698
path = fields.getfirst('path')
699
url = conf.svn_addr + "/" + path
700
svnclient.exception_style = 1
703
svnclient.callback_get_login = get_login
705
except pysvn.ClientError, e:
706
# Error code 170000 means ENOENT in this revision.
707
if e[1][0][1] == 170000:
708
raise util.IVLEError(404, 'The specified repository path does not exist')
710
raise ActionError(str(e[0]))
712
643
# Table of all action functions #
713
644
# Each function has the interface f(req, fields).
715
646
actions_table = {
716
"delete" : action_delete,
647
"remove" : action_remove,
717
648
"move" : action_move,
718
649
"mkdir" : action_mkdir,
719
650
"putfile" : action_putfile,
723
654
"unpublish" : action_unpublish,
725
656
"svnadd" : action_svnadd,
726
"svnremove" : action_svnremove,
727
657
"svnupdate" : action_svnupdate,
728
"svnresolved" : action_svnresolved,
729
658
"svnrevert" : action_svnrevert,
730
659
"svnpublish" : action_svnpublish,
731
660
"svnunpublish" : action_svnunpublish,
732
661
"svncommit" : action_svncommit,
733
662
"svncheckout" : action_svncheckout,
734
"svnrepomkdir" : action_svnrepomkdir,
735
"svnrepostat" : action_svnrepostat,