diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -452,6 +452,8 @@ class revbranchcache(object): def _setcachedata(self, rev, node, branchidx): """Writes the node's branch data to the in-memory cache data.""" + if rev == nullrev: + return rbcrevidx = rev * _rbcrecsize if len(self._rbcrevs) < rbcrevidx + _rbcrecsize: self._rbcrevs.extend('\0' * diff --git a/tests/test-branches.t b/tests/test-branches.t --- a/tests/test-branches.t +++ b/tests/test-branches.t @@ -1,5 +1,10 @@ $ hg init a $ cd a + +Verify checking branch of nullrev before the cache is created doesnt crash + $ hg log -r 'branch(.)' -T '{branch}\n' + +Basic test $ echo 'root' >root $ hg add root $ hg commit -d '0 0' -m "Adding root node"