sparse: make path absoluteness checks cross-platform

Summary: Let's be friendlier to our friends on Windows.

Test Plan: rt

Reviewers: mjpieters, #fbhgext

Differential Revision: https://phab.mercurial-scm.org/D194
This commit is contained in:
Kostia Balytskyi 2017-07-28 06:23:52 -07:00
parent 4e6c705cbd
commit 99b1950cd9
2 changed files with 5 additions and 8 deletions

View File

@ -758,10 +758,9 @@ def _config(ui, repo, pats, opts, include=False, exclude=False, reset=False,
newexclude = set(oldexclude)
newprofiles = set(oldprofiles)
if any(pat.startswith('/') for pat in pats):
err = _('paths cannot start with /')
hint = _('do not use absolute paths')
raise error.Abort(err, hint=hint)
if any(os.path.isabs(pat) for pat in pats):
err = _('paths cannot be absolute')
raise error.Abort(err)
if (not ui.configbool('sparse', 'includereporootpaths', False)
and (include or exclude)):

View File

@ -28,14 +28,12 @@ Verify basic --include
Absolute paths outside the repo should just be rejected
$ hg sparse --include /foo/bar
abort: paths cannot start with /
(do not use absolute paths)
abort: paths cannot be absolute
[255]
$ hg sparse --include '$TESTTMP/myrepo/hide'
$ hg sparse --include '/root'
abort: paths cannot start with /
(do not use absolute paths)
abort: paths cannot be absolute
[255]
Repo root-relaive vs. cwd-relative includes