No subject


Sun Jun 27 20:02:09 UTC 2010


such as os.path.islink or mymodule.py's is_ignored() func."

>
> Second, I have a patch I am sitting on which adds the debugignore command=
, which produces the regular expression that Mercurial uses for ignoring th=
ings. I asked about this on IRC and several people thought that this would =
be a good idea, including Matt. (I can paste the IRC chat for those interes=
ted...)

It does sound useful. Please patchbomb this, that would help us a lot
to debug the usual hgignore issues we have to deal with on IRC

>
> Using debugignore many other client programs can / could deal with this r=
egular expression... Such as MacHg, TortiseHg, MercurialEclipse, Murky, etc=
. In almost every major target language eg C, Java, Javascript, bash, perl,=
 ruby, php, C#, X++, Objective C, etc... there are tools which deal with th=
ese regular expressions, how many deal well with a python snippet of code?
>
> If we recast all of the ignore patterns as python routines then we restri=
ct the ignore functionality to only working within python (of course all th=
e clients call python in one way or another but there is often a lag in cal=
ling out to external programs, and the official documented way for clients =
to access Mercurial is through the public API and not through some lowerlev=
el hooks...)
>
> If there is some extension that does things differently, thats fine, but =
I am against changing core Mercurial with this patch, since clients really =
need to interact with regular expressions.

I do not understand your point. Boris seems to have a strong enough
need for this feature that he's coded it, and made two successive
moves towards us to try to include it as much as possible within
mercurial.
I think that the core should allow extension developers to do whatever
they want. Including doing things that, in another context, would be
considered stupid. These are still _extensions_, not enabled by
default, probably not distributed with official hg, so what's wrong
with that, as long as the default behaviour is correct and safe?

Some might argue that fixutf8, fixcase or casestop are the wrong ways
to enforce something that should be policy-driven, but those
extensions still exist, because... people are free to shoot themselves
in the foot, if they think that it's helpful to them :) And if core
had needed small changes to accommodate those extensions, I think we
would have allowed them.

>
> Sorry...

Disagreeing with people is good. Not disagreeing is a good way to let
stupid changes in :)
Thanks for your input.

Regards,
-Nicolas.

>
> Cheers,
> =C2=A0 Jas
>
> On Jul 4, 2010, at 2:29 AM, Mads Kiilerich wrote:
>
>> Boris Figovsky wrote, On 07/03/2010 10:33 AM:
>>> Hello,
>>>
>>> This patch allows extensions to add new syntaxes to .hgignore.
>>> An example extension is attached.
>>>
>>> # HG changeset patch
>>> # User Boris Figovsky<borfig at gmail.com>
>>> # Date 1278145261 -10800
>>> # Node ID 68f65947ef90819e0f062b2d53e727351efa179e
>>> # Parent =C2=A08b452fe4bf506a1a08bbc7e1bac81aceda8f4d10
>>> Allow extensions to add new hgignore syntaxes
>>
>> Why should an extension want to do that? Can you give a more convincing =
example than twice.py?
>>
>> You should include tests for the new functionality.
>>
>> What behavior should users see if they use a repo with a .hgignore which=
 references a syntax from an extension they don't have?
>>
>> And ...
>>
>>> diff -r 8b452fe4bf50 -r 68f65947ef90 mercurial/ignore.py
>>> --- a/mercurial/ignore.py =C2=A0 =C2=A0Mon Jun 21 17:02:48 2010 -0300
>>> +++ b/mercurial/ignore.py =C2=A0 =C2=A0Sat Jul 03 11:21:01 2010 +0300
>>> @@ -10,12 +10,13 @@
>>> =C2=A0import re
>>>
>>> =C2=A0_commentre =3D None
>>> +_syntaxes =3D {'re': 'relre:', 'regexp': 'relre:', 'glob': 'relglob:'}
>>>
>>> =C2=A0def ignorepats(lines):
>>> =C2=A0 =C2=A0 =C2=A0'''parse lines (iterable) of .hgignore text, return=
ing a tuple of
>>> =C2=A0 =C2=A0 =C2=A0(patterns, parse errors). These patterns should be =
given to compile()
>>> =C2=A0 =C2=A0 =C2=A0to be validated and converted into a match function=
.'''
>>> - =C2=A0 =C2=A0syntaxes =3D {'re': 'relre:', 'regexp': 'relre:', 'glob'=
: 'relglob:'}
>>> + =C2=A0 =C2=A0syntaxes =3D _syntaxes
>>> =C2=A0 =C2=A0 =C2=A0syntax =3D 'relre:'
>>> =C2=A0 =C2=A0 =C2=A0patterns =3D []
>>> =C2=A0 =C2=A0 =C2=A0warnings =3D []
>>
>> If the intention is that it should be possible to extend syntaxes from e=
xtensions then it would IMHO be better to not mark it as a private (by not =
prefixing with _).
>>
>>> diff -r 8b452fe4bf50 -r 68f65947ef90 mercurial/match.py
>>> --- a/mercurial/match.py =C2=A0 =C2=A0 Mon Jun 21 17:02:48 2010 -0300
>>> +++ b/mercurial/match.py =C2=A0 =C2=A0 Sat Jul 03 11:21:01 2010 +0300
>>> @@ -110,12 +110,14 @@
>>> =C2=A0def patkind(pat):
>>> =C2=A0 =C2=A0 =C2=A0return _patsplit(pat, None)[0]
>>>
>>> +_kinds =3D ['re', 'glob', 'path', 'relglob', 'relpath', 'relre']
>>> +
>>> =C2=A0def _patsplit(pat, default):
>>> =C2=A0 =C2=A0 =C2=A0"""Split a string into an optional pattern kind pre=
fix and the
>>> =C2=A0 =C2=A0 =C2=A0actual pattern."""
>>> =C2=A0 =C2=A0 =C2=A0if ':' in pat:
>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0kind, val =3D pat.split(':', 1)
>>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0if kind in ('re', 'glob', 'path', 'relglob=
', 'relpath', 'relre'):
>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0if kind in _kinds:
>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return kind, val
>>> =C2=A0 =C2=A0 =C2=A0return default, pat
>>>
>>> @@ -175,23 +177,21 @@
>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0res +=3D escape(c)
>>> =C2=A0 =C2=A0 =C2=A0return res
>>>
>>> +_regex_builders =3D {
>>> + =C2=A0 =C2=A0're' : lambda name, tail: name,
>>> + =C2=A0 =C2=A0'path' : lambda name, tail: '^' + re.escape(name) + '(?:=
/|$)',
>>> + =C2=A0 =C2=A0'glob' : lambda name, tail: _globre(name) + tail,
>>> + =C2=A0 =C2=A0'relglob' : lambda name, tail: '(?:|.*/)' + _globre(name=
) + tail,
>>> + =C2=A0 =C2=A0'relpath' : lambda name, tail: re.escape(name) + '(?:/|$=
)',
>>> + =C2=A0 =C2=A0'relre' : lambda name, tail: name if name.startswith('^'=
) else '.*' + name,
>>
>> Mercurial supports Python 2.4 and can thus not use ternary if.
>>
>> Try to run "contrib/check-code.py mercurial/match.py".
>>
>>> + =C2=A0 =C2=A0}
>>> +
>>> =C2=A0def _regex(kind, name, tail):
>>> =C2=A0 =C2=A0 =C2=A0'''convert a pattern into a regular expression'''
>>> =C2=A0 =C2=A0 =C2=A0if not name:
>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return ''
>>> - =C2=A0 =C2=A0if kind =3D=3D 're':
>>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0return name
>>> - =C2=A0 =C2=A0elif kind =3D=3D 'path':
>>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0return '^' + re.escape(name) + '(?:/|$)'
>>> - =C2=A0 =C2=A0elif kind =3D=3D 'relglob':
>>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0return '(?:|.*/)' + _globre(name) + tail
>>> - =C2=A0 =C2=A0elif kind =3D=3D 'relpath':
>>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0return re.escape(name) + '(?:/|$)'
>>> - =C2=A0 =C2=A0elif kind =3D=3D 'relre':
>>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0if name.startswith('^'):
>>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return name
>>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0return '.*' + name
>>> - =C2=A0 =C2=A0return _globre(name) + tail
>>> + =C2=A0 =C2=A0regex_builder =3D _regex_builders[kind]
>>> + =C2=A0 =C2=A0return regex_builder(name, tail)
>>
>> What happens if kind isn't found?
>>
>>
>> /Mads
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>



--=20
Nicolas Dumazet =E2=80=94 NicDumZ


More information about the Mercurial-devel mailing list