Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/localrepo.py @ 24320:b9f7f3eeb99c
localrepo: extend "changeid in repo" to return True for workingctx revision
This is necessary to implement "wc" symbol for workingctx, that will be used
as follows:
$ hg annotate -r wc FILE
In principle, "rev in repo" should be True if "repo[rev]" can return a context
object. But when it was implemented by ea3acaae25bb, lookup() had a long logic
to map all sorts of changeids to nodes, and "None in repo" did crash because
lookup() could not accept None. So I assume that the case of changeid=None was
not considered.
Now "None in repo" doesn't crash, it should be True for workingctx revision.
Behavior of "changeid in repo":
revision "null" existing rev None (workingctx)
---------- ------ ------------ -----------------
original* True True TypeError
current True True False
this patch True True True
(*original: ea3acaae25bb)
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 17 Aug 2014 11:35:31 +0900 |
parents | 6ddc86eedc3b |
children | 59cc09240afb |
comparison
equal
deleted
inserted
replaced
24319:6ff513495a8b | 24320:b9f7f3eeb99c |
---|---|
463 if i not in self.changelog.filteredrevs] | 463 if i not in self.changelog.filteredrevs] |
464 return context.changectx(self, changeid) | 464 return context.changectx(self, changeid) |
465 | 465 |
466 def __contains__(self, changeid): | 466 def __contains__(self, changeid): |
467 try: | 467 try: |
468 return bool(self.lookup(changeid)) | 468 self[changeid] |
469 return True | |
469 except error.RepoLookupError: | 470 except error.RepoLookupError: |
470 return False | 471 return False |
471 | 472 |
472 def __nonzero__(self): | 473 def __nonzero__(self): |
473 return True | 474 return True |