src/hg-ssh
changeset 211 0cd59649772c
parent 165 3606d60b07e5
child 212 ab5e0e4f5a0c
equal deleted inserted replaced
208:31e862df1884 211:0cd59649772c
    33 
    33 
    34 from mercurial import dispatch
    34 from mercurial import dispatch
    35 
    35 
    36 import sys, os, os.path
    36 import sys, os, os.path
    37 import base64
    37 import base64
    38 from mercurialserver import ruleset, paths
    38 from mercurialserver import config, ruleset
    39 
    39 
    40 def fail(message):
    40 def fail(message):
    41     sys.stderr.write("mercurial-server: %s\n" % message)
    41     sys.stderr.write("mercurial-server: %s\n" % message)
    42     sys.exit(-1)
    42     sys.exit(-1)
    43 
    43 
    69     if not ruleset.rules.allow(op, branch=None, file=None):
    69     if not ruleset.rules.allow(op, branch=None, file=None):
    70         fail("access denied")
    70         fail("access denied")
    71     checkParents(repo)
    71     checkParents(repo)
    72     return repo
    72     return repo
    73 
    73 
    74 paths.setExePath()
    74 config.setExePath()
    75 
    75 
    76 if len(sys.argv) == 3 and sys.argv[1] == "--base64":
    76 if len(sys.argv) == 3 and sys.argv[1] == "--base64":
    77     ruleset.rules.set(user = base64.b64decode(sys.argv[2]))
    77     ruleset.rules.set(user = base64.b64decode(sys.argv[2]))
    78 elif len(sys.argv) == 2:
    78 elif len(sys.argv) == 2:
    79     ruleset.rules.set(user = sys.argv[1])
    79     ruleset.rules.set(user = sys.argv[1])
    82         % sys.argv)
    82         % sys.argv)
    83 
    83 
    84 # Use a different hgrc for remote pulls - this way you can set
    84 # Use a different hgrc for remote pulls - this way you can set
    85 # up access.py for everything at once without affecting local operations
    85 # up access.py for everything at once without affecting local operations
    86 
    86 
    87 os.environ['HGRCPATH'] = paths.getHgrcPaths()
    87 os.environ['HGRCPATH'] = config.getHgrcPaths()
    88 
    88 
    89 os.chdir(paths.getReposPath())
    89 os.chdir(config.getReposPath())
    90 
    90 
    91 for f in paths.getAccessPaths():
    91 for f in config.getAccessPaths():
    92     if os.path.isfile(f):
    92     if os.path.isfile(f):
    93         ruleset.rules.readfile(f)
    93         ruleset.rules.readfile(f)
    94 
    94 
    95 cmd = os.environ.get('SSH_ORIGINAL_COMMAND', None)
    95 cmd = os.environ.get('SSH_ORIGINAL_COMMAND', None)
    96 if cmd is None:
    96 if cmd is None: