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.
--- 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 <rev>]')),
"help": (help_, [], _('hg help [COMMAND]')),
"identify|id": (identify, [], _('hg identify')),
--- 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]
--- 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)