[PATCH 2 of 2 sparse-ext maybe-for-stable] sparse: treat paths as cwd-relative

Martin von Zweigbergk martinvonz at google.com
Fri Jul 28 12:23:11 EDT 2017


On Fri, Jul 28, 2017 at 6:47 AM, Kostia Balytskyi <ikostia at fb.com> wrote:
>> -----Original Message-----
>> From: Martin von Zweigbergk [mailto:martinvonz at google.com]
>> Sent: Thursday, 27 July, 2017 00:28
>> To: Kostia Balytskyi <ikostia at fb.com>
>> Cc: Mercurial-devel <mercurial-devel at mercurial-scm.org>
>> Subject: Re: [PATCH 2 of 2 sparse-ext maybe-for-stable] sparse: treat paths
>> as cwd-relative
>>
>> On Wed, Jul 26, 2017 at 4:11 PM, Kostia Balytskyi <ikostia at fb.com> wrote:
>> > # HG changeset patch
>> > # User Kostia Balytskyi <ikostia at fb.com> # Date 1501110087 25200
>> > #      Wed Jul 26 16:01:27 2017 -0700
>> > # Branch stable
>> > # Node ID 6bc64227f84e6a17aa1f8e71916915644531a04e
>> > # Parent  681f8819475ed5546e712d9ce04116b8b5a04f9b
>> > sparse: treat paths as cwd-relative
>>
>> No tests?
>>
>> > diff --git a/mercurial/sparse.py b/mercurial/sparse.py
>> > --- a/mercurial/sparse.py
>> > +++ b/mercurial/sparse.py
>> > @@ -639,6 +639,10 @@ def updateconfig(repo, pats, opts, inclu
>> >          if any(os.path.isabs(pat) for pat in pats):
>> >              raise error.Abort(_('paths cannot be absolute'))
>> >
>> > +        if not usereporootpaths:
>> > +            # let's treat paths as relative to cwd
>> > +            pats = scmutil.match(repo['.'], pats).files()
>>
>> This looks suspicious to me. Can pats contain patterns here? If
>> pats=['glob:**/*.py'], what will the new pats be?
>
> I do not think I understand the question about globs, but I added a glob to the test in the next version of this patch in case it removes some of your concerns.

IIUC, these patterns (the 'pats' variable) go into the sparse config
file. And sparse actually defaults to "glob" patterns.

$ python
>>> from mercurial import match
>>> match.match(root='subdir', cwd='subdir', patterns=['relpath:foo']).files()
['subdir/foo']
>>> match.match(root='subdir', cwd='subdir', patterns=['glob:*.py']).files()
['subdir']

Is the above what you wanted? I think the first one is. For the second
one, I'd expect ['glob:subdir/*.py'].


More information about the Mercurial-devel mailing list