Submitter | Yuya Nishihara |
---|---|
Date | May 24, 2015, 4:48 a.m. |
Message ID | <95e4e05ef06c2cd6e9fa.1432442893@mimosa> |
Download | mbox | patch |
Permalink | /patch/9253/ |
State | Accepted |
Headers | show |
Comments
On 05/23/2015 09:48 PM, Yuya Nishihara wrote: > # HG changeset patch > # User Yuya Nishihara <yuya@tcha.org> > # Date 1432347240 -32400 > # Sat May 23 11:14:00 2015 +0900 > # Branch stable > # Node ID 95e4e05ef06c2cd6e9fa6a1d2460dc5d760b8675 > # Parent c1758faf54617855d3f21152cd05e81fecf6cf6b > revbranchcache: return uncached branchinfo for nullrev (issue4683) > > This fixes the crash caused by "branch(null)" revset. No cache should be > necessary for nullrev because changelog.branchinfo(nullrev) does not involve > IO operation. > > Note that the problem of "branch(wdir())" isn't addressed by this patch. > "wdir()" will raise TypeError in many places because of None. This is the > reason why "wdir()" is still experimental. With a mix of relieved and sadness, I've pushed to the clowncopter this series.
Patch
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)