[PATCH 3 of 7 V3 RFC] parser: move alias declaration parser to common rule-set class
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Sun Apr 3 17:04:20 EDT 2016
On 04/03/2016 02:48 AM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1456736043 -32400
> # Mon Feb 29 17:54:03 2016 +0900
> # Node ID aa54435b4a485541d3be7abbe5ed6fd584b43ee5
> # Parent 37cbd68f6cd8760b146570dd8b547589539605fd
> parser: move alias declaration parser to common rule-set class
>
> The original _parsealiasdecl() function is split into common _builddecl()
> and revset-specific _parsealiasdecl(). And the original _parsealiasdecl()
> call is temporarily replaced by rules._builddecl(), which should be eliminated
> later.
>
> The doctests are mostly ported by using the dummy parse(), but the test for
> 'foo bar' is kept in _parsealiasdecl() as it checks if "pos != len(decl)" is
> working. Also, 'foo($1)' test is added to make sure the alias tokenizer can
> handle '$1' symbol, which is the only reason why we need _parsealiasdecl().
>
[…]
> @@ -2373,6 +2316,7 @@ def _parsealiasdefn(defn, args):
> class _aliasrules(parser.basealiasrules):
> """Parsing and expansion rule set of revset aliases"""
> _section = _('revset alias')
> + _parsedecl = staticmethod(_parsealiasdecl)
> _getlist = staticmethod(getlist)
>
> class revsetalias(object):
Why are we keeping the function outside of the class? (With a manual
staticmethod promition and assignement). Shouln't we be able to directly
declare it inside the class with a @static method decorator?
Cheers,
--
Pierre-Yves David
More information about the Mercurial-devel
mailing list