diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1436,13 +1436,14 @@ def heads(ui, repo, *branchrevs, **opts) descendants.add(startrev) heads += [h for h in ls if repo.changelog.rev(h) in descendants] - if not opts.get('closed'): - heads = [h for h in heads if not repo[h].extra().get('close')] - - if opts.get('active'): - dagheads = repo.heads(start) - heads = [h for h in heads if h in dagheads] - + if not opts.get('closed'): + heads = [h for h in heads if not repo[h].extra().get('close')] + + if opts.get('active') and branchrevs: + dagheads = repo.heads(start) + heads = [h for h in heads if h in dagheads] + + if branchrevs: haveheads = set(repo[h].branch() for h in heads) if branches - haveheads: headless = ', '.join(encode(b) for b in branches - haveheads) diff --git a/tests/test-branches.out b/tests/test-branches.out --- a/tests/test-branches.out +++ b/tests/test-branches.out @@ -143,12 +143,6 @@ user: test date: Thu Jan 01 00:00:09 1970 +0000 summary: reopen branch with a change -changeset: 11:c84627f3c15d -branch: b -user: test -date: Thu Jan 01 00:00:09 1970 +0000 -summary: prune bad branch - changeset: 7:10ff5895aa57 branch: a branch name much longer than the default justification used by branches user: test