# HG changeset patch # User Thomas Arendsen Hein # Date 1132142179 -3600 # Node ID e793cbc8be005926f4e9582b8326594aac8f9615 # Parent ccb9b62de892a5be6a7e0985b0cfddb4e1921c9e Fixes to "hg heads -r FOO": Make it actually work (undefined variable 'rev'; allow to pass a rev parameter). repo.branchlookup() doesn't need a copy of heads because it doesn't modify it. Use None as default argument to heads() instead of nullid. Doc string PEPification. diff -r ccb9b62de892 -r e793cbc8be00 mercurial/commands.py --- a/mercurial/commands.py Wed Nov 16 12:08:25 2005 +0100 +++ b/mercurial/commands.py Wed Nov 16 12:56:19 2005 +0100 @@ -1287,12 +1287,12 @@ 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 @@ "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 -r ccb9b62de892 -r e793cbc8be00 mercurial/localrepo.py --- a/mercurial/localrepo.py Wed Nov 16 12:08:25 2005 +0100 +++ b/mercurial/localrepo.py Wed Nov 16 12:56:19 2005 +0100 @@ -613,7 +613,7 @@ 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 -r ccb9b62de892 -r e793cbc8be00 mercurial/revlog.py --- a/mercurial/revlog.py Wed Nov 16 12:08:25 2005 +0100 +++ b/mercurial/revlog.py Wed Nov 16 12:56:19 2005 +0100 @@ -409,10 +409,15 @@ 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)