# HG changeset patch # User Boris Feld <boris.f...@octobus.net> # Date 1546575417 -3600 # Fri Jan 04 05:16:57 2019 +0100 # Node ID 438ea9b8a44c181d62741338c1d16b2031fdda41 # Parent d360e33ec21c012b8990dfb1148b4fd52f0ece31 # EXP-Topic revs-efficiency # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 438ea9b8a44c revert: extract "%ld" formatting in a _formatintlist function
We'll have to reuse this logic in different places. diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py --- a/mercurial/revsetlang.py +++ b/mercurial/revsetlang.py @@ -607,7 +607,7 @@ def _formatlistexp(s, t): elif l == 1: return _formatargtype(t, s[0]) elif t == 'd': - return "_intlist('%s')" % "\0".join('%d' % int(a) for a in s) + return _formatintlist(s) elif t == 's': return "_list(%s)" % _quote("\0".join(s)) elif t == 'n': @@ -621,6 +621,17 @@ def _formatlistexp(s, t): m = l // 2 return '(%s or %s)' % (_formatlistexp(s[:m], t), _formatlistexp(s[m:], t)) +def _formatintlist(data): + try: + l = len(data) + if l == 0: + return "_list('')" + elif l == 1: + return _formatargtype('d', data[0]) + return "_intlist('%s')" % "\0".join('%d' % int(a) for a in data) + except (TypeError, ValueError): + raise error.ParseError(_('invalid argument for revspec')) + def _formatparamexp(args, t): return ', '.join(_formatargtype(t, a) for a in args) _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel