mercurial/commands.py
changeset 50834 07c6a085fad7
parent 50833 f7cfac1260be
child 50835 2bbc76528733
equal deleted inserted replaced
50833:f7cfac1260be 50834:07c6a085fad7
  3741     topological heads (changesets with no children) will be shown.
  3741     topological heads (changesets with no children) will be shown.
  3742 
  3742 
  3743     Returns 0 if matching heads are found, 1 if not.
  3743     Returns 0 if matching heads are found, 1 if not.
  3744     """
  3744     """
  3745 
  3745 
  3746     opts = pycompat.byteskwargs(opts)
       
  3747     start = None
  3746     start = None
  3748     rev = opts.get(b'rev')
  3747     rev = opts.get('rev')
  3749     if rev:
  3748     if rev:
  3750         repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
  3749         repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn')
  3751         start = logcmdutil.revsingle(repo, rev, None).node()
  3750         start = logcmdutil.revsingle(repo, rev, None).node()
  3752 
  3751 
  3753     if opts.get(b'topo'):
  3752     if opts.get('topo'):
  3754         heads = [repo[h] for h in repo.heads(start)]
  3753         heads = [repo[h] for h in repo.heads(start)]
  3755     else:
  3754     else:
  3756         heads = []
  3755         heads = []
  3757         for branch in repo.branchmap():
  3756         for branch in repo.branchmap():
  3758             heads += repo.branchheads(branch, start, opts.get(b'closed'))
  3757             heads += repo.branchheads(branch, start, opts.get('closed'))
  3759         heads = [repo[h] for h in heads]
  3758         heads = [repo[h] for h in heads]
  3760 
  3759 
  3761     if branchrevs:
  3760     if branchrevs:
  3762         branches = {
  3761         branches = {
  3763             repo[r].branch() for r in logcmdutil.revrange(repo, branchrevs)
  3762             repo[r].branch() for r in logcmdutil.revrange(repo, branchrevs)
  3764         }
  3763         }
  3765         heads = [h for h in heads if h.branch() in branches]
  3764         heads = [h for h in heads if h.branch() in branches]
  3766 
  3765 
  3767     if opts.get(b'active') and branchrevs:
  3766     if opts.get('active') and branchrevs:
  3768         dagheads = repo.heads(start)
  3767         dagheads = repo.heads(start)
  3769         heads = [h for h in heads if h.node() in dagheads]
  3768         heads = [h for h in heads if h.node() in dagheads]
  3770 
  3769 
  3771     if branchrevs:
  3770     if branchrevs:
  3772         haveheads = {h.branch() for h in heads}
  3771         haveheads = {h.branch() for h in heads}
  3773         if branches - haveheads:
  3772         if branches - haveheads:
  3774             headless = b', '.join(b for b in branches - haveheads)
  3773             headless = b', '.join(b for b in branches - haveheads)
  3775             msg = _(b'no open branch heads found on branches %s')
  3774             msg = _(b'no open branch heads found on branches %s')
  3776             if opts.get(b'rev'):
  3775             if opts.get('rev'):
  3777                 msg += _(b' (started at %s)') % opts[b'rev']
  3776                 msg += _(b' (started at %s)') % opts['rev']
  3778             ui.warn((msg + b'\n') % headless)
  3777             ui.warn((msg + b'\n') % headless)
  3779 
  3778 
  3780     if not heads:
  3779     if not heads:
  3781         return 1
  3780         return 1
  3782 
  3781 
  3783     ui.pager(b'heads')
  3782     ui.pager(b'heads')
  3784     heads = sorted(heads, key=lambda x: -(x.rev()))
  3783     heads = sorted(heads, key=lambda x: -(x.rev()))
  3785     displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
  3784     displayer = logcmdutil.changesetdisplayer(
       
  3785         ui, repo, pycompat.byteskwargs(opts)
       
  3786     )
  3786     for ctx in heads:
  3787     for ctx in heads:
  3787         displayer.show(ctx)
  3788         displayer.show(ctx)
  3788     displayer.close()
  3789     displayer.close()
  3789 
  3790 
  3790 
  3791