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) newexclude = set(oldexclude)
newprofiles = set(oldprofiles) newprofiles = set(oldprofiles)
if any(pat.startswith('/') for pat in pats): if any(os.path.isabs(pat) for pat in pats):
err = _('paths cannot start with /') err = _('paths cannot be absolute')
hint = _('do not use absolute paths') raise error.Abort(err)
raise error.Abort(err, hint=hint)
if (not ui.configbool('sparse', 'includereporootpaths', False) if (not ui.configbool('sparse', 'includereporootpaths', False)
and (include or exclude)): and (include or exclude)):

View File

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