todispatch unnecessary
authorPaul Crowley <paul@lshift.net>
Fri, 20 Feb 2009 11:15:21 +0000
changeset 43 0a7fc4652793
parent 42 0e77495e91e2
child 44 cf851f3ddf16
todispatch unnecessary
src/hg-ssh
--- a/src/hg-ssh	Fri Feb 20 11:10:34 2009 +0000
+++ b/src/hg-ssh	Fri Feb 20 11:15:21 2009 +0000
@@ -48,17 +48,17 @@
         fail("Disallowing path: %s" % path)
     return path
 
-def get_cmd(rules, cmd):
+def try_cmd(rules, cmd):
     if cmd.startswith('hg -R ') and cmd.endswith(' serve --stdio'):
         repo = getpath(cmd[6:-14])
         if rules.allow("read", repo=repo):
             os.environ["HG_REPO_PATH"] = repo
-            return ['-R', repo, 'serve', '--stdio']
+            dispatch.dispatch(['-R', repo, 'serve', '--stdio'])
     elif cmd.startswith('hg init '):
         repo = getpath(cmd[8:])
         if rules.allow("init", repo=repo):
             os.environ["HG_REPO_PATH"] = repo
-            return ['init', repo]
+            dispatch.dispatch(['init', repo])
     fail("Illegal command %r" % cmd)
 
 #logfile = open("/tmp/hg-ssh.%d.txt" % os.getpid(), "w")
@@ -71,7 +71,5 @@
 rules = ruleset.rules_from_env()
 rules.set(user = getpath(os.environ['REMOTE_USER']))
 rules.set(branch = None, file = None)
-todispatch = get_cmd(rules, 
-    os.environ.get('SSH_ORIGINAL_COMMAND', '?'))
-dispatch.dispatch(todispatch)
+try_cmd(rules, os.environ.get('SSH_ORIGINAL_COMMAND', '?'))