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

« back to all changes in this revision

Viewing changes to ivle/fileservice_lib/action.py

  • Committer: William Grant
  • Date: 2010-02-23 08:48:09 UTC
  • mfrom: (1673 trunk)
  • mto: This revision was merged to the branch mainline in revision 1674.
  • Revision ID: grantw@unimelb.edu.au-20100223084809-du6dvsxrjhw15ytr
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
#       revision: The revision number to update to. If not provided this
95
95
#               defaults to HEAD.
96
96
#
97
 
# action=svnpublish: Set the "published" flag on a file to True.
98
 
#       path:   The path to the file to be published. Can be specified
99
 
#               multiple times.
100
 
#
101
 
# action=svnunpublish: Set the "published" flag on a file to False.
102
 
#       path:   The path to the file to be unpublished. Can be specified
103
 
#               multiple times.
104
 
#
105
97
# action=svncommit: Commit a file(s) or directory(s) to the repository.
106
98
#       path:   The path to the file or directory to be committed. Can be
107
99
#               specified multiple times. Directories are committed
580
572
    Reads fields: 'path' (multiple)
581
573
    """
582
574
    paths = fields.getlist('path')
583
 
    paths = map(lambda path: actionpath_to_local(req, path), paths)
 
575
    paths = map(lambda path: actionpath_to_local(req, path).decode('utf-8'),
 
576
                paths)
584
577
 
585
578
    try:
586
579
        svnclient.add(paths, recurse=True, force=True)
593
586
    Reads fields: 'path' (multiple)
594
587
    """
595
588
    paths = fields.getlist('path')
596
 
    paths = map(lambda path: actionpath_to_local(req, path), paths)
 
589
    paths = map(lambda path: actionpath_to_local(req, path).decode('utf-8'),
 
590
                paths)
597
591
 
598
592
    try:
599
593
        svnclient.remove(paths, force=True)
617
611
                    int(revision))
618
612
        except ValueError, e:
619
613
            raise ActionError("Bad revision number: '%s'"%revision,)
620
 
    path = actionpath_to_local(req, path)
 
614
    path = actionpath_to_local(req, path).decode('utf-8')
621
615
 
622
616
    try:
623
617
        svnclient.update(path, recurse=True, revision=revision)
632
626
    path = fields.getfirst('path')
633
627
    if path is None:
634
628
        raise ActionError("Required field missing")
635
 
    path = actionpath_to_local(req, path)
 
629
    path = actionpath_to_local(req, path).decode('utf-8')
636
630
 
637
631
    try:
638
632
        svnclient.resolved(path, recurse=True)
645
639
    Reads fields: 'path' (multiple)
646
640
    """
647
641
    paths = fields.getlist('path')
648
 
    paths = map(lambda path: actionpath_to_local(req, path), paths)
 
642
    paths = map(lambda path: actionpath_to_local(req, path).decode('utf-8'),
 
643
                paths)
649
644
 
650
645
    try:
651
646
        svnclient.revert(paths, recurse=True)
652
647
    except pysvn.ClientError, e:
653
648
        raise ActionError(str(e))
654
649
 
655
 
def action_svnpublish(req, fields):
656
 
    """Sets svn property "ivle:published" on each file specified.
657
 
    Should only be called on directories (only effective on directories
658
 
    anyway).
659
 
 
660
 
    Reads fields: 'path'
661
 
 
662
 
    XXX Currently unused by the client (calls action_publish instead, which
663
 
    has a completely different publishing model).
664
 
    """
665
 
    paths = fields.getlist('path')
666
 
    if len(paths):
667
 
        paths = map(lambda path: actionpath_to_local(req, path), paths)
668
 
    else:
669
 
        paths = [studpath.to_home_path(req.path)]
670
 
 
671
 
    try:
672
 
        for path in paths:
673
 
            # Note: Property value doesn't matter
674
 
            svnclient.propset("ivle:published", "", path, recurse=False)
675
 
    except pysvn.ClientError, e:
676
 
        raise ActionError("Directory could not be published")
677
 
 
678
 
def action_svnunpublish(req, fields):
679
 
    """Deletes svn property "ivle:published" on each file specified.
680
 
 
681
 
    Reads fields: 'path'
682
 
 
683
 
    XXX Currently unused by the client (calls action_unpublish instead, which
684
 
    has a completely different publishing model).
685
 
    """
686
 
    paths = fields.getlist('path')
687
 
    paths = map(lambda path: actionpath_to_local(req, path), paths)
688
 
 
689
 
    try:
690
 
        for path in paths:
691
 
            svnclient.propdel("ivle:published", path, recurse=False)
692
 
    except pysvn.ClientError, e:
693
 
        raise ActionError("Directory could not be unpublished")
694
 
 
695
650
def action_svncommit(req, fields):
696
651
    """Performs a "svn commit" to each file specified.
697
652
 
698
653
    Reads fields: 'path' (multiple), 'logmsg' (optional)
699
654
    """
700
655
    paths = fields.getlist('path')
701
 
    paths = map(lambda path: actionpath_to_local(req, str(path)), paths)
702
 
    logmsg = str(fields.getfirst('logmsg', DEFAULT_LOGMESSAGE))
 
656
    if len(paths):
 
657
        paths = map(lambda path:actionpath_to_local(req,path).decode('utf-8'),
 
658
                    paths)
 
659
    else:
 
660
        paths = [studpath.to_home_path(req.path).decode('utf-8')]
 
661
    logmsg = str(fields.getfirst('logmsg',
 
662
                 DEFAULT_LOGMESSAGE)).decode('utf-8')
703
663
    if logmsg == '': logmsg = DEFAULT_LOGMESSAGE
704
664
 
705
665
    try:
717
677
        raise ActionError("usage: svncheckout url local-path")
718
678
    url = ivle.conf.svn_addr + "/" + urllib.quote(paths[0])
719
679
    local_path = actionpath_to_local(req, str(paths[1]))
 
680
    url = url.decode('utf-8')
 
681
    local_path = local_path.decode('utf-8')
720
682
    try:
721
683
        svnclient.checkout(url, local_path, recurse=True)
722
684
    except pysvn.ClientError, e:
729
691
    """
730
692
    path = fields.getfirst('path')
731
693
    logmsg = fields.getfirst('logmsg')
732
 
    url = ivle.conf.svn_addr + "/" + urllib.quote(path)
 
694
    url = (ivle.conf.svn_addr + "/" + urllib.quote(path)).decode('utf-8')
733
695
    try:
734
696
        svnclient.mkdir(url, log_message=logmsg)
735
697
    except pysvn.ClientError, e:
743
705
    Reads fields: 'path'
744
706
    """
745
707
    path = fields.getfirst('path')
746
 
    url = ivle.conf.svn_addr + "/" + urllib.quote(path)
 
708
    url = (ivle.conf.svn_addr + "/" + urllib.quote(path)).decode('utf-8')
747
709
    svnclient.exception_style = 1
748
710
 
749
711
    try:
769
731
    path = fields.getfirst('path')
770
732
    if path is None:
771
733
        raise ActionError("Required field missing")
772
 
    path = actionpath_to_local(req, path)
 
734
    path = actionpath_to_local(req, path).decode('utf-8')
773
735
 
774
736
    try:
775
737
        svnclient.cleanup(path)
795
757
    "svnupdate" : action_svnupdate,
796
758
    "svnresolved" : action_svnresolved,
797
759
    "svnrevert" : action_svnrevert,
798
 
    "svnpublish" : action_svnpublish,
799
 
    "svnunpublish" : action_svnunpublish,
800
760
    "svncommit" : action_svncommit,
801
761
    "svncheckout" : action_svncheckout,
802
762
    "svnrepomkdir" : action_svnrepomkdir,