diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -341,6 +341,10 @@ class revbranchcache(object): changelog = self._repo.changelog rbcrevidx = rev * _rbcrecsize + # avoid negative index, changelog.read(nullrev) is fast without cache + if rev == nullrev: + return changelog.branchinfo(rev) + # if requested rev is missing, add and populate all missing revs if len(self._rbcrevs) < rbcrevidx + _rbcrecsize: self._rbcrevs.extend('\0' * (len(changelog) * _rbcrecsize - diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -1602,6 +1602,14 @@ prepare repository that has "default" br $ echo default5 >> a $ hg ci -m5 +"null" revision belongs to "default" branch (issue4683) + + $ log 'branch(null)' + 0 + 1 + 4 + 5 + "null" revision belongs to "default" branch, but it shouldn't appear in set unless explicitly specified (issue4682)