contrib/hg-ssh
changeset 38109 666d90ace0bb
parent 38107 44ef9bb7ccd9
child 43659 99e231afc29c
equal deleted inserted replaced
38108:e69628f36196 38109:666d90ace0bb
    37 # enable importing on demand to reduce startup time
    37 # enable importing on demand to reduce startup time
    38 import hgdemandimport ; hgdemandimport.enable()
    38 import hgdemandimport ; hgdemandimport.enable()
    39 
    39 
    40 from mercurial import (
    40 from mercurial import (
    41     dispatch,
    41     dispatch,
       
    42     pycompat,
    42     ui as uimod,
    43     ui as uimod,
    43 )
    44 )
    44 
    45 
    45 def main():
    46 def main():
    46     # Prevent insertion/deletion of CRs
    47     # Prevent insertion/deletion of CRs
    67 
    68 
    68     if cmdargv[:2] == ['hg', '-R'] and cmdargv[3:] == ['serve', '--stdio']:
    69     if cmdargv[:2] == ['hg', '-R'] and cmdargv[3:] == ['serve', '--stdio']:
    69         path = cmdargv[2]
    70         path = cmdargv[2]
    70         repo = os.path.normpath(os.path.join(cwd, os.path.expanduser(path)))
    71         repo = os.path.normpath(os.path.join(cwd, os.path.expanduser(path)))
    71         if repo in allowed_paths:
    72         if repo in allowed_paths:
    72             cmd = [b'-R', repo, b'serve', b'--stdio']
    73             cmd = [b'-R', pycompat.fsencode(repo), b'serve', b'--stdio']
    73             req = dispatch.request(cmd)
    74             req = dispatch.request(cmd)
    74             if readonly:
    75             if readonly:
    75                 if not req.ui:
    76                 if not req.ui:
    76                     req.ui = uimod.ui.load()
    77                     req.ui = uimod.ui.load()
    77                 req.ui.setconfig(b'hooks', b'pretxnopen.hg-ssh',
    78                 req.ui.setconfig(b'hooks', b'pretxnopen.hg-ssh',