[PATCH 5 of 7 V3] revert: extract "%ld" formatting in a _formatintlist function
Boris Feld
boris.feld at octobus.net
Mon Jan 14 09:27:21 EST 2019
# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1546575417 -3600
# Fri Jan 04 05:16:57 2019 +0100
# Node ID 2c5c8e76f2a95b10f367e50c17ae903471337b69
# Parent 3e2bfc71b5408b23ba2ed50cf8d655c4ebab3401
# EXP-Topic revs-efficiency
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 2c5c8e76f2a9
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)
More information about the Mercurial-devel
mailing list