mercurial/smartset.py
changeset 36265 b44fac3a49fb
parent 35904 fc44c2657dc5
child 38261 f3033692ccef
equal deleted inserted replaced
36264:18e29c65bc5c 36265:b44fac3a49fb
    33     elif isinstance(r, bytes):
    33     elif isinstance(r, bytes):
    34         return r
    34         return r
    35     elif callable(r):
    35     elif callable(r):
    36         return r()
    36         return r()
    37     else:
    37     else:
    38         return pycompat.sysbytes(repr(r))
    38         return pycompat.byterepr(r)
    39 
    39 
    40 def _typename(o):
    40 def _typename(o):
    41     return pycompat.sysbytes(type(o).__name__).lstrip('_')
    41     return pycompat.sysbytes(type(o).__name__).lstrip('_')
    42 
    42 
    43 class abstractsmartset(object):
    43 class abstractsmartset(object):
   398             # if _list has been built from a set, it might have a different
   398             # if _list has been built from a set, it might have a different
   399             # order from one python implementation to another.
   399             # order from one python implementation to another.
   400             # We fallback to the sorted version for a stable output.
   400             # We fallback to the sorted version for a stable output.
   401             if self._ascending is not None:
   401             if self._ascending is not None:
   402                 l = self._asclist
   402                 l = self._asclist
   403             s = pycompat.sysbytes(repr(l))
   403             s = pycompat.byterepr(l)
   404         return '<%s%s %s>' % (_typename(self), d, s)
   404         return '<%s%s %s>' % (_typename(self), d, s)
   405 
   405 
   406 class filteredset(abstractsmartset):
   406 class filteredset(abstractsmartset):
   407     """Duck type for baseset class which iterates lazily over the revisions in
   407     """Duck type for baseset class which iterates lazily over the revisions in
   408     the subset and contains a function which tests for membership in the
   408     the subset and contains a function which tests for membership in the
   511                 pass
   511                 pass
   512             return x
   512             return x
   513 
   513 
   514     @encoding.strmethod
   514     @encoding.strmethod
   515     def __repr__(self):
   515     def __repr__(self):
   516         xs = [pycompat.sysbytes(repr(self._subset))]
   516         xs = [pycompat.byterepr(self._subset)]
   517         s = _formatsetrepr(self._condrepr)
   517         s = _formatsetrepr(self._condrepr)
   518         if s:
   518         if s:
   519             xs.append(s)
   519             xs.append(s)
   520         return '<%s %s>' % (_typename(self), ', '.join(xs))
   520         return '<%s %s>' % (_typename(self), ', '.join(xs))
   521 
   521 
  1130         other.sort(reverse=self.isdescending())
  1130         other.sort(reverse=self.isdescending())
  1131         return other
  1131         return other
  1132 
  1132 
  1133 def prettyformat(revs):
  1133 def prettyformat(revs):
  1134     lines = []
  1134     lines = []
  1135     rs = pycompat.sysbytes(repr(revs))
  1135     rs = pycompat.byterepr(revs)
  1136     p = 0
  1136     p = 0
  1137     while p < len(rs):
  1137     while p < len(rs):
  1138         q = rs.find('<', p + 1)
  1138         q = rs.find('<', p + 1)
  1139         if q < 0:
  1139         if q < 0:
  1140             q = len(rs)
  1140             q = len(rs)