Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 25765:5e1b0739611c
revset: use integer representation of wdir() in revset
This is the simplest way to handle wdir() revision in revset. None didn't
work well because revset heavily depends on integer operations such as min(),
max(), sorted(), x:y, etc.
One downside is that we cannot do "wctx.rev() in set" because wctx.rev() is
still None. We could wrap the result set by wdirproxyset that translates None
to wdirrev, but it seems overengineered at this point.
result = getset(repo, subset, tree)
if 'wdir' in funcsused(tree):
result = wdirproxyset(result)
Test cases need the '(all() + wdir()) &' hack because we have yet to fix the
bootstrapping issue of null and wdir.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 16 Mar 2015 16:17:06 +0900 |
parents | d50677c3bf44 |
children | d51dac68ec98 |
comparison
equal
deleted
inserted
replaced
25764:22049b565d57 | 25765:5e1b0739611c |
---|---|
1479 ps = set() | 1479 ps = set() |
1480 cl = repo.changelog | 1480 cl = repo.changelog |
1481 up = ps.update | 1481 up = ps.update |
1482 parentrevs = cl.parentrevs | 1482 parentrevs = cl.parentrevs |
1483 for r in getset(repo, fullreposet(repo), x): | 1483 for r in getset(repo, fullreposet(repo), x): |
1484 if r is None: | 1484 if r == node.wdirrev: |
1485 up(p.rev() for p in repo[r].parents()) | 1485 up(p.rev() for p in repo[r].parents()) |
1486 else: | 1486 else: |
1487 up(parentrevs(r)) | 1487 up(parentrevs(r)) |
1488 ps -= set([node.nullrev]) | 1488 ps -= set([node.nullrev]) |
1489 return subset & ps | 1489 return subset & ps |
1984 | 1984 |
1985 # experimental | 1985 # experimental |
1986 def wdir(repo, subset, x): | 1986 def wdir(repo, subset, x): |
1987 # i18n: "wdir" is a keyword | 1987 # i18n: "wdir" is a keyword |
1988 getargs(x, 0, 0, _("wdir takes no arguments")) | 1988 getargs(x, 0, 0, _("wdir takes no arguments")) |
1989 if None in subset or isinstance(subset, fullreposet): | 1989 if node.wdirrev in subset or isinstance(subset, fullreposet): |
1990 return baseset([None]) | 1990 return baseset([node.wdirrev]) |
1991 return baseset() | 1991 return baseset() |
1992 | 1992 |
1993 # for internal use | 1993 # for internal use |
1994 def _list(repo, subset, x): | 1994 def _list(repo, subset, x): |
1995 s = getstring(x, "internal error") | 1995 s = getstring(x, "internal error") |