diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -211,10 +211,13 @@ Raise KeyError for unknown branch.''' return self._branchtip(self[branch])[0] + def iteropen(self, nodes): + return (n for n in nodes if n not in self._closednodes) + def branchheads(self, branch, closed=False): heads = self[branch] if not closed: - heads = [h for h in heads if h not in self._closednodes] + heads = list(self.iteropen(heads)) return heads def iterbranches(self): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1077,7 +1077,10 @@ allheads = set(repo.heads()) branches = [] for tag, heads, tip, isclosed in repo.branchmap().iterbranches(): - isactive = not isclosed and bool(set(heads) & allheads) + isactive = False + if not isclosed: + openheads = set(repo.branchmap().iteropen(heads)) + isactive = bool(openheads & allheads) branches.append((tag, repo[tip], isactive, not isclosed)) branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]), reverse=True)