revset: stabilize repr of baseset initialized with a set
authorPierre-Yves David <pierre-yves.david@fb.com>
Mon, 04 Apr 2016 17:45:15 -0700
changeset 28785 87b89dca669d
parent 28784 09750b1231c2
child 28786 69c6e9623bdc
revset: stabilize repr of baseset initialized 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.
mercurial/revset.py
tests/test-revset.t
--- a/mercurial/revset.py	Mon Apr 04 17:27:37 2016 +0100
+++ b/mercurial/revset.py	Mon Apr 04 17:45:15 2016 -0700
@@ -2889,7 +2889,13 @@
         d = {None: '', False: '-', True: '+'}[self._ascending]
         s = _formatsetrepr(self._datarepr)
         if not s:
-            s = repr(self._list)
+            l = self._list
+            # if _list has 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):
--- a/tests/test-revset.t	Mon Apr 04 17:27:37 2016 +0100
+++ b/tests/test-revset.t	Mon Apr 04 17:45:15 2016 -0700
@@ -725,7 +725,7 @@
       ('symbol', '9')
       ('symbol', '5')))
   * set:
-  <baseset+ [8, 9, 2, 4]>
+  <baseset+ [2, 4, 8, 9]>
   2
   4
   8