src/hg-ssh
branchdebian
changeset 277 265b258904d2
parent 275 2e781d52f76e
child 303 3f9f247b72bd
equal deleted inserted replaced
261:b6e65bddda7c 277:265b258904d2
    32     if tail.startswith("."):
    32     if tail.startswith("."):
    33         fail("paths cannot contain dot file components")
    33         fail("paths cannot contain dot file components")
    34     if head:
    34     if head:
    35         checkDots(head)
    35         checkDots(head)
    36 
    36 
    37 def checkParents(path):
       
    38     path = os.path.dirname(path)
       
    39     if path == "":
       
    40         return
       
    41     if os.path.exists(path + "/.hg"):
       
    42         fail("Cannot create repo under existing repo")
       
    43     checkParents(path)
       
    44 
       
    45 def getrepo(op, repo):
    37 def getrepo(op, repo):
    46     # First canonicalise, then check the string, then the rules
    38     # First canonicalise, then check the string, then the rules
    47     # and finally the filesystem.
       
    48     repo = repo.strip().rstrip("/")
    39     repo = repo.strip().rstrip("/")
    49     if len(repo) == 0:
    40     if len(repo) == 0:
    50         fail("path to repository seems to be empty")
    41         fail("path to repository seems to be empty")
    51     if repo.startswith("/"):
    42     if repo.startswith("/"):
    52         fail("absolute paths are not supported")
    43         fail("absolute paths are not supported")
    53     checkDots(repo)
    44     checkDots(repo)
    54     ruleset.rules.set(repo=repo)
    45     ruleset.rules.set(repo=repo)
    55     if not ruleset.rules.allow(op, branch=None, file=None):
    46     if not ruleset.rules.allow(op, branch=None, file=None):
    56         fail("access denied")
    47         fail("access denied")
    57     checkParents(repo)
       
    58     return repo
    48     return repo
    59 
    49 
    60 config.initExe()
    50 config.initExe()
    61 
    51 
    62 for k,v in config.getEnv():
    52 for k,v in config.getEnv():