diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1287,12 +1287,12 @@ def heads(ui, repo, **opts): are the usual targets for update and merge operations. """ if opts['rev']: - heads = repo.heads(repo.lookup(rev)) + heads = repo.heads(repo.lookup(opts['rev'])) else: heads = repo.heads() br = None if opts['branches']: - br = repo.branchlookup(list(heads)) + br = repo.branchlookup(heads) for n in heads: show_changeset(ui, repo, changenode=n, brinfo=br) @@ -2241,7 +2241,7 @@ table = { "heads": (heads, [('b', 'branches', None, _('find branch info')), - ('r', 'rev', None, _('show only heads descendants from rev'))], + ('r', 'rev', "", _('show only heads which are descendants of rev'))], _('hg heads [-b] [-r ]')), "help": (help_, [], _('hg help [COMMAND]')), "identify|id": (identify, [], _('hg identify')), diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -613,7 +613,7 @@ class localrepository: self.dirstate.update([dest], "a") self.dirstate.copy(source, dest) - def heads(self, start=nullid): + def heads(self, start=None): heads = self.changelog.heads(start) # sort the output in rev descending order heads = [(-self.changelog.rev(h), h) for h in heads] diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -409,10 +409,15 @@ class revlog: assert heads return (orderedout, roots, heads) - def heads(self, start=nullid): + def heads(self, start=None): """return the list of all nodes that have no children - if start is specified, only heads that are children of - start will be returned""" + + if start is specified, only heads that are descendants of + start will be returned + + """ + if start is None: + start = nullid reachable = {start: 1} heads = {start: 1} startrev = self.rev(start)