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(): |