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

« back to all changes in this revision

Viewing changes to www/apps/fileservice/action.py

  • Committer: mattgiuca
  • Date: 2008-01-10 07:34:54 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:167
fileservice: Added actions svnupdate and svnrevert.

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
# TODO: Implement the following actions:
116
116
#   putfiles, svnrevert, svnupdate, svncommit
117
117
# TODO: Implement ZIP unpacking in putfile and putfiles.
 
118
# TODO: svnupdate needs a digest to tell the user the files that were updated.
 
119
#   This can be implemented by some message passing between action and
 
120
#   listing, and having the digest included in the listing. (Problem if
 
121
#   the listing is not a directory, but we could make it an error to do an
 
122
#   update if the path is not a directory).
118
123
 
119
124
import os
120
125
import shutil
384
389
def action_svnadd(req, fields):
385
390
    """Performs a "svn add" to each file specified.
386
391
 
387
 
    Reads fields: 'path'
 
392
    Reads fields: 'path' (multiple)
388
393
    """
389
394
    paths = fields.getlist('path')
390
395
    paths = map(lambda path: actionpath_to_local(req, path), paths)
394
399
    except pysvn.ClientError:
395
400
        raise ActionError("One or more files could not be added")
396
401
 
 
402
def action_svnupdate(req, fields):
 
403
    """Performs a "svn update" to each file specified.
 
404
 
 
405
    Reads fields: 'path'
 
406
    """
 
407
    path = fields.getfirst('path')
 
408
    if path is None:
 
409
        raise ActionError("Required field missing")
 
410
    path = actionpath_to_local(req, path)
 
411
 
 
412
    try:
 
413
        svnclient.update(path, recurse=True)
 
414
    except pysvn.ClientError:
 
415
        raise ActionError("One or more files could not be updated")
 
416
 
 
417
def action_svnrevert(req, fields):
 
418
    """Performs a "svn revert" to each file specified.
 
419
 
 
420
    Reads fields: 'path' (multiple)
 
421
    """
 
422
    paths = fields.getlist('path')
 
423
    paths = map(lambda path: actionpath_to_local(req, path), paths)
 
424
 
 
425
    try:
 
426
        svnclient.revert(paths, recurse=True)
 
427
    except pysvn.ClientError:
 
428
        raise ActionError("One or more files could not be reverted")
 
429
 
397
430
# Table of all action functions #
398
431
# Each function has the interface f(req, fields).
399
432
 
407
440
    "paste" : action_paste,
408
441
 
409
442
    "svnadd" : action_svnadd,
 
443
    "svnupdate" : action_svnupdate,
 
444
    "svnrevert" : action_svnrevert,
410
445
}