Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revset.py @ 25024:263bbed1833c
revset: test current behavior of addset class
The addset class isn't simple and it has a hidden bug that will be fixed by
future patches. So let's test the current behavior.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 30 Mar 2015 19:51:40 +0900 |
parents | 405cb38448ad |
children | bb2f543b48b5 |
comparison
equal
deleted
inserted
replaced
25023:405cb38448ad | 25024:263bbed1833c |
---|---|
2942 performance on the __contains__ method | 2942 performance on the __contains__ method |
2943 | 2943 |
2944 If the ascending attribute is set, that means the two structures are | 2944 If the ascending attribute is set, that means the two structures are |
2945 ordered in either an ascending or descending way. Therefore, we can add | 2945 ordered in either an ascending or descending way. Therefore, we can add |
2946 them maintaining the order by iterating over both at the same time | 2946 them maintaining the order by iterating over both at the same time |
2947 | |
2948 >>> xs = baseset([0, 3, 2]) | |
2949 >>> ys = baseset([5, 2, 4]) | |
2950 | |
2951 >>> rs = addset(xs, ys) | |
2952 >>> bool(rs), 0 in rs, 1 in rs, 5 in rs, rs.first(), rs.last() | |
2953 (True, True, False, True, 0, 4) | |
2954 >>> rs = addset(xs, baseset([])) | |
2955 >>> bool(rs), 0 in rs, 1 in rs, rs.first(), rs.last() | |
2956 (True, True, False, 0, 2) | |
2957 >>> rs = addset(baseset([]), baseset([])) | |
2958 >>> bool(rs), 0 in rs, rs.first(), rs.last() | |
2959 (False, False, None, None) | |
2960 | |
2961 iterate unsorted: | |
2962 >>> rs = addset(xs, ys) | |
2963 >>> [x for x in rs] # without _genlist | |
2964 [0, 3, 2, 5, 4] | |
2965 >>> assert not rs._genlist | |
2966 >>> len(rs) | |
2967 5 | |
2968 >>> [x for x in rs] # with _genlist | |
2969 [0, 3, 2, 5, 4] | |
2970 >>> assert rs._genlist | |
2971 | |
2972 iterate ascending: | |
2973 >>> rs = addset(xs, ys, ascending=True) | |
2974 >>> [x for x in rs], [x for x in rs.fastasc()] # without _asclist | |
2975 ([0, 2, 3, 4, 5], [0, 2, 3, 4, 5]) | |
2976 >>> assert not rs._asclist | |
2977 >>> len(rs) # BROKEN | |
2978 6 | |
2979 >>> [x for x in rs], [x for x in rs.fastasc()] # BROKEN with _asclist | |
2980 ([0, 2, 2, 3, 4, 5], [0, 2, 2, 3, 4, 5]) | |
2981 >>> assert rs._asclist | |
2982 | |
2983 iterate descending: | |
2984 >>> rs = addset(xs, ys, ascending=False) | |
2985 >>> [x for x in rs], [x for x in rs.fastdesc()] # without _asclist | |
2986 ([5, 4, 3, 2, 0], [5, 4, 3, 2, 0]) | |
2987 >>> assert not rs._asclist | |
2988 >>> len(rs) # BROKEN | |
2989 6 | |
2990 >>> [x for x in rs], [x for x in rs.fastdesc()] # BROKEN with _asclist | |
2991 ([5, 4, 3, 2, 2, 0], [5, 4, 3, 2, 2, 0]) | |
2992 >>> assert rs._asclist | |
2993 | |
2994 iterate ascending without fastasc: | |
2995 >>> rs = addset(xs, generatorset(ys), ascending=True) | |
2996 >>> assert rs.fastasc is None | |
2997 >>> [x for x in rs] # BROKEN | |
2998 [0, 2, 2, 3, 4, 5] | |
2999 | |
3000 iterate descending without fastdesc: | |
3001 >>> rs = addset(generatorset(xs), ys, ascending=False) | |
3002 >>> assert rs.fastdesc is None | |
3003 >>> [x for x in rs] # BROKEN | |
3004 [5, 4, 3, 2, 2, 0] | |
2947 """ | 3005 """ |
2948 def __init__(self, revs1, revs2, ascending=None): | 3006 def __init__(self, revs1, revs2, ascending=None): |
2949 self._r1 = revs1 | 3007 self._r1 = revs1 |
2950 self._r2 = revs2 | 3008 self._r2 = revs2 |
2951 self._iter = None | 3009 self._iter = None |