diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1129,6 +1129,7 @@ [('a', 'active', False, _('show only branches that have unmerged heads (DEPRECATED)')), ('c', 'closed', False, _('show normal and closed branches')), + ('r', 'rev', [], _('show branch name(s) of the given rev(s)')) ] + formatteropts, _('[-c]'), helpcategory=command.CATEGORY_CHANGE_ORGANIZATION, @@ -1158,6 +1159,10 @@ """ opts = pycompat.byteskwargs(opts) + revs = opts.get('rev') + if revs: + revs = scmutil.revrange(repo, revs) + ui.pager('branches') fm = ui.formatter('branches', opts) hexfunc = fm.hexfunc @@ -1192,8 +1197,11 @@ label = 'branches.current' fm.startitem() + rev = ctx.rev() + if opts.get('rev') and rev not in revs: + continue + fm.write('branch', '%s', tag, label=label) - rev = ctx.rev() padsize = max(31 - len("%d" % rev) - encoding.colwidth(tag), 0) fmt = ' ' * padsize + ' %d:%s' fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),