Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/pathutil.py @ 48417:35f1ecd84bd0
errors: use detailed exit code in pathauditor
Differential Revision: https://phab.mercurial-scm.org/D11830
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 19 Nov 2021 16:21:00 -0800 |
parents | e02f9af7aed1 |
children | 6000f5b25c9b |
comparison
equal
deleted
inserted
replaced
48416:8c4881c07f57 | 48417:35f1ecd84bd0 |
---|---|
77 normpath = self.normcase(path) | 77 normpath = self.normcase(path) |
78 if normpath in self.audited: | 78 if normpath in self.audited: |
79 return | 79 return |
80 # AIX ignores "/" at end of path, others raise EISDIR. | 80 # AIX ignores "/" at end of path, others raise EISDIR. |
81 if util.endswithsep(path): | 81 if util.endswithsep(path): |
82 raise error.Abort(_(b"path ends in directory separator: %s") % path) | 82 raise error.InputError( |
83 _(b"path ends in directory separator: %s") % path | |
84 ) | |
83 parts = util.splitpath(path) | 85 parts = util.splitpath(path) |
84 if ( | 86 if ( |
85 os.path.splitdrive(path)[0] | 87 os.path.splitdrive(path)[0] |
86 or _lowerclean(parts[0]) in (b'.hg', b'.hg.', b'') | 88 or _lowerclean(parts[0]) in (b'.hg', b'.hg.', b'') |
87 or pycompat.ospardir in parts | 89 or pycompat.ospardir in parts |
88 ): | 90 ): |
89 raise error.Abort(_(b"path contains illegal component: %s") % path) | 91 raise error.InputError( |
92 _(b"path contains illegal component: %s") % path | |
93 ) | |
90 # Windows shortname aliases | 94 # Windows shortname aliases |
91 for p in parts: | 95 for p in parts: |
92 if b"~" in p: | 96 if b"~" in p: |
93 first, last = p.split(b"~", 1) | 97 first, last = p.split(b"~", 1) |
94 if last.isdigit() and first.upper() in [b"HG", b"HG8B6C"]: | 98 if last.isdigit() and first.upper() in [b"HG", b"HG8B6C"]: |
95 raise error.Abort( | 99 raise error.InputError( |
96 _(b"path contains illegal component: %s") % path | 100 _(b"path contains illegal component: %s") % path |
97 ) | 101 ) |
98 if b'.hg' in _lowerclean(path): | 102 if b'.hg' in _lowerclean(path): |
99 lparts = [_lowerclean(p) for p in parts] | 103 lparts = [_lowerclean(p) for p in parts] |
100 for p in b'.hg', b'.hg.': | 104 for p in b'.hg', b'.hg.': |
101 if p in lparts[1:]: | 105 if p in lparts[1:]: |
102 pos = lparts.index(p) | 106 pos = lparts.index(p) |
103 base = os.path.join(*parts[:pos]) | 107 base = os.path.join(*parts[:pos]) |
104 raise error.Abort( | 108 raise error.InputError( |
105 _(b"path '%s' is inside nested repo %r") | 109 _(b"path '%s' is inside nested repo %r") |
106 % (path, pycompat.bytestr(base)) | 110 % (path, pycompat.bytestr(base)) |
107 ) | 111 ) |
108 | 112 |
109 normparts = util.splitpath(normpath) | 113 normparts = util.splitpath(normpath) |