From patchwork Tue Apr 5 01:13:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,2] revset: stabilise repr of baseset initialised with a set From: Pierre-Yves David X-Patchwork-Id: 14361 Message-Id: <0f39406de1cb1a95008c.1459818796@marginatus.alto.octopoid.net> To: mercurial-devel@mercurial-scm.org Cc: Pierre-Yves David Date: Mon, 04 Apr 2016 18:13:16 -0700 # HG changeset patch # User Pierre-Yves David # Date 1459817115 25200 # Mon Apr 04 17:45:15 2016 -0700 # Node ID 0f39406de1cb1a95008c3b97273ebc7da7bf7c6b # Parent 4ea482ff4804dab641e23ad8d44c08db2b957d24 # Available At http://mercurial-scm.org/repo/users/marmoute/mercurial/ # hg pull http://mercurial-scm.org/repo/users/marmoute/mercurial/ -r 0f39406de1cb # EXP-Topic pypy.revset revset: stabilise repr of baseset initialised with a set Cpython and pypy have different way to build and order set, so the result of list(myset) is different. We work around this by using the sorted version of the data when displaying a list. This get pypy closer to pass test-revset.t. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -2891,11 +2891,17 @@ class baseset(abstractsmartset): def __repr__(self): d = {None: '', False: '-', True: '+'}[self._ascending] s = _formatsetrepr(self._datarepr) if not s: - s = repr(self._list) + l = self._list + # if _list have been built from a set, it might have a different + # order from one python implementation to another. + # We fallback to the sorted version for a stable output. + if self._ascending is not None: + l = self._asclist + s = repr(l) return '<%s%s %s>' % (type(self).__name__, d, s) class filteredset(abstractsmartset): """Duck type for baseset class which iterates lazily over the revisions in the subset and contains a function which tests for membership in the diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -723,11 +723,11 @@ Test opreand of '%' is optimized recursi ('symbol', 'only') (list ('symbol', '9') ('symbol', '5'))) * set: - + 2 4 8 9