~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/fileservice_lib/action.py

  • Committer: Matt Giuca
  • Date: 2009-12-15 01:52:56 UTC
  • Revision ID: matt.giuca@gmail.com-20091215015256-6ynee77rnicszula
Minor comment fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
# action=svnupdate: Bring a file up to date with the head revision.
92
92
#       path:   The path to the file to be updated. Only one file may be
93
93
#               specified.
 
94
#       revision: The revision number to update to. If not provided this
 
95
#               defaults to HEAD.
94
96
#
95
97
# action=svnpublish: Set the "published" flag on a file to True.
96
98
#       path:   The path to the file to be published. Can be specified
119
121
#       path:   The path to the directory to be checked (under the IVLE
120
122
#               repository base).
121
123
#
 
124
# action=svncleanup: Recursively clean up the working copy, removing locks,
 
125
#   resuming unfinished operations, etc.
 
126
#       path:   The path to the directory to be cleaned
 
127
#
122
128
# TODO: Implement the following actions:
123
129
#   svnupdate (done?)
124
130
# TODO: Implement ZIP unpacking in putfiles (done?).
611
617
def action_svnupdate(req, fields):
612
618
    """Performs a "svn update" to each file specified.
613
619
 
614
 
    Reads fields: 'path'
 
620
    Reads fields: 'path' and 'revision'
615
621
    """
616
622
    path = fields.getfirst('path')
 
623
    revision = fields.getfirst('revision')
617
624
    if path is None:
618
625
        raise ActionError("Required field missing")
 
626
    if revision is None:
 
627
        revision = pysvn.Revision( pysvn.opt_revision_kind.head )
 
628
    else:
 
629
        try:
 
630
            revision = pysvn.Revision(pysvn.opt_revision_kind.number,
 
631
                    int(revision))
 
632
        except ValueError, e:
 
633
            raise ActionError("Bad revision number: '%s'"%revision,)
619
634
    path = actionpath_to_local(req, path)
620
635
 
621
636
    try:
622
 
        svnclient.update(path, recurse=True)
 
637
        svnclient.update(path, recurse=True, revision=revision)
623
638
    except pysvn.ClientError, e:
624
639
        raise ActionError(str(e))
625
640
 
761
776
            raise util.IVLEError(404, 'The specified repository path does not exist')
762
777
        else:
763
778
            raise ActionError(str(e[0]))
764
 
            
 
779
 
 
780
 
 
781
def action_svncleanup(req, fields):
 
782
    """Recursively clean up the working copy, removing locks, resuming 
 
783
    unfinished operations, etc.
 
784
        path:   The path to be cleaned"""
 
785
 
 
786
    path = fields.getfirst('path')
 
787
    if path is None:
 
788
        raise ActionError("Required field missing")
 
789
    path = actionpath_to_local(req, path)
 
790
 
 
791
    try:
 
792
        svnclient.cleanup(path)
 
793
    except pysvn.ClientError, e:
 
794
        raise ActionError(str(e))
 
795
 
765
796
 
766
797
# Table of all action functions #
767
798
# Each function has the interface f(req, fields).
787
818
    "svncheckout" : action_svncheckout,
788
819
    "svnrepomkdir" : action_svnrepomkdir,
789
820
    "svnrepostat" : action_svnrepostat,
 
821
    "svncleanup" : action_svncleanup,
790
822
}