src/hg-ssh
changeset 304 6e575b602d2b
parent 303 3f9f247b72bd
child 305 bf58227c168a
equal deleted inserted replaced
303:3f9f247b72bd 304:6e575b602d2b
    16 
    16 
    17 # enable importing on demand to reduce startup time
    17 # enable importing on demand to reduce startup time
    18 from mercurial import demandimport; demandimport.enable()
    18 from mercurial import demandimport; demandimport.enable()
    19 
    19 
    20 from mercurial import dispatch
    20 from mercurial import dispatch
       
    21 
       
    22 try:
       
    23     from dispatch import request
       
    24 except ImportError:
       
    25     request = list
    21 
    26 
    22 import sys, os, os.path
    27 import sys, os, os.path
    23 import base64
    28 import base64
    24 from mercurialserver import config, ruleset
    29 from mercurialserver import config, ruleset
    25 
    30 
    81     fail("direct logins on the hg account prohibited")
    86     fail("direct logins on the hg account prohibited")
    82 elif cmd.startswith('hg -R ') and cmd.endswith(' serve --stdio'):
    87 elif cmd.startswith('hg -R ') and cmd.endswith(' serve --stdio'):
    83     repo = getrepo("read", cmd[6:-14])
    88     repo = getrepo("read", cmd[6:-14])
    84     if not os.path.isdir(repo + "/.hg"):
    89     if not os.path.isdir(repo + "/.hg"):
    85         fail("no such repository %s" % repo)
    90         fail("no such repository %s" % repo)
    86     dispatch.dispatch(['-R', repo, 'serve', '--stdio'])
    91     dispatch.dispatch(request(['-R', repo, 'serve', '--stdio']))
    87 elif cmd.startswith('hg init '):
    92 elif cmd.startswith('hg init '):
    88     repo = getrepo("init", cmd[8:])
    93     repo = getrepo("init", cmd[8:])
    89     if os.path.exists(repo):
    94     if os.path.exists(repo):
    90         fail("%s exists" % repo)
    95         fail("%s exists" % repo)
    91     d = os.path.dirname(repo)
    96     d = os.path.dirname(repo)
    92     if d != "" and not os.path.isdir(d):
    97     if d != "" and not os.path.isdir(d):
    93         os.makedirs(d)
    98         os.makedirs(d)
    94     dispatch.dispatch(['init', repo])
    99     dispatch.dispatch(request(['init', repo]))
    95 else:
   100 else:
    96     fail("illegal command %r" % cmd)
   101     fail("illegal command %r" % cmd)