Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 24204:d2de20e1451f
revset: extend fullreposet to make "null" revision magically appears in set
As per fullreposet.__and__, it can omit the range check of rev. Therefore,
"null" revision is accepted automagically.
It seems this can fix many query results involving null symbol. Originally,
the simplest "(null)" query did fail if there were hidden revisions. Tests
are randomly chosen.
fullreposet mimics the behavior of localrepo, where "null" revision is not
listed but contained.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 08 Jan 2015 23:05:45 +0900 |
parents | 33c7a94d4dd0 |
children | 282c0d8c1880 |
comparison
equal
deleted
inserted
replaced
24203:33c7a94d4dd0 | 24204:d2de20e1451f |
---|---|
321 | 321 |
322 # operator methods | 322 # operator methods |
323 | 323 |
324 def stringset(repo, subset, x): | 324 def stringset(repo, subset, x): |
325 x = repo[x].rev() | 325 x = repo[x].rev() |
326 if x == -1 and len(subset) == len(repo): | |
327 return baseset([-1]) | |
328 if x in subset: | 326 if x in subset: |
329 return baseset([x]) | 327 return baseset([x]) |
330 return baseset() | 328 return baseset() |
331 | 329 |
332 def symbolset(repo, subset, x): | 330 def symbolset(repo, subset, x): |
3310 return None | 3308 return None |
3311 | 3309 |
3312 class fullreposet(spanset): | 3310 class fullreposet(spanset): |
3313 """a set containing all revisions in the repo | 3311 """a set containing all revisions in the repo |
3314 | 3312 |
3315 This class exists to host special optimization. | 3313 This class exists to host special optimization and magic to handle virtual |
3314 revisions such as "null". | |
3316 """ | 3315 """ |
3317 | 3316 |
3318 def __init__(self, repo): | 3317 def __init__(self, repo): |
3319 super(fullreposet, self).__init__(repo) | 3318 super(fullreposet, self).__init__(repo) |
3320 | 3319 |
3321 def __contains__(self, rev): | 3320 def __contains__(self, rev): |
3321 # assumes the given rev is valid | |
3322 hidden = self._hiddenrevs | 3322 hidden = self._hiddenrevs |
3323 return ((self._start <= rev < self._end) | 3323 return not (hidden and rev in hidden) |
3324 and not (hidden and rev in hidden)) | |
3325 | 3324 |
3326 def __and__(self, other): | 3325 def __and__(self, other): |
3327 """As self contains the whole repo, all of the other set should also be | 3326 """As self contains the whole repo, all of the other set should also be |
3328 in self. Therefore `self & other = other`. | 3327 in self. Therefore `self & other = other`. |
3329 | 3328 |