
import generate as gen
import parse

commands = {}

def cmd_func(name):
    def _cmd_func(f):
        commands.setdefault(name, f)
        return f
    return _cmd_func

@cmd_func('get-latest-rev')
def get_latest_rev(url, repos, args):
    return "%s %s" % (gen.success('( )', gen.string('')),
                      gen.success('12'))

@cmd_func('check-path')
def check_path(url_base, repos, args):
    url = url_base
    rev = None

    path = parse.string(args[0])
    if len(path) > 0:
        url = '/'.join((url_base, path))

    if len(args) > 1:
        rev = int(args[1][0])

    ref, path = repos.parse_url(url)

    print "ref: %s" % ref
    print "path: %s" % path
    print "rev: %s" % rev

    if ref is None or path == '':
        type = 'dir'
    else:
        type = repos.svn_node_kind(url, rev)

    return "%s %s" % (gen.success('( )', gen.string('')),
                      gen.success(type))

def handle_command(url, msg, repos):
    command = msg[0]
    args = msg [1]

    if command not in commands:
        return gen.error(210001, "Unknown command '%s'" % command)

    return commands[command](url, repos, args)

@@ -908,16 +908,727 @@
 type))%0A%0A
+@cmd_func('get-dir')%0Adef get_dir(url_base, repos, args):%0A    url = url_base%0A    rev = None%0A%0A    path = parse.string(args.pop(0))%0A    if len(path) %3E 0:%0A        url = '/'.join((url_base, path))%0A%0A    arg = args.pop(0)%0A    if isinstance(arg, list):%0A        rev = int(arg%5B0%5D)%0A        arg = args.pop(0)%0A%0A    want_props = parse.bool(arg)%0A%0A    want_contents = parse.bool(args.pop(0))%0A%0A    fields = %5B%5D%0A    if len(args) %3E 0:%0A        fields = args%5B0%5D%0A%0A    ref, path = repos.parse_url(url)%0A%0A    print %22ref: %25s%22 %25 ref%0A    print %22path: %25s%22 %25 path%0A    print %22rev: %25s%22 %25 rev%0A    print %22want_props: %25s%22 %25 want_props%0A    print %22want_contents: %25s%22 %25 want_contents%0A    print %22fields: %25s%22 %25 fields%0A%0A    return gen.error(12, 'pah')%0A%0A
 def hand

Add beginnings of get-dir command