From patchwork Tue Oct 27 22:42:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D9250: rebase: use hard-coded template for one-line commit description From: phabricator X-Patchwork-Id: 47521 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Tue, 27 Oct 2020 22:42:17 +0000 martinvonz created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This is to prepare for making making the one-line summary customizable. The template ended up pretty complicated because of the conditional output of "()". Maybe we can simplify the template later. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D9250 AFFECTED FILES hgext/rebase.py CHANGE DETAILS To: martinvonz, #hg-reviewers Cc: mercurial-patches, mercurial-devel diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -34,6 +34,7 @@ dirstateguard, error, extensions, + formatter, merge as mergemod, mergestate as mergestatemod, mergeutil, @@ -51,6 +52,7 @@ scmutil, smartset, state as statemod, + templatekw, util, ) @@ -146,20 +148,12 @@ def _ctxdesc(ctx): """short description for a context""" - desc = b'%d:%s "%s"' % ( - ctx.rev(), - ctx, - ctx.description().split(b'\n', 1)[0], + labels_spec = b'join(filter(namespaces % "{ifeq(namespace, "branches", "", join(names, " "))}"), " ")' + spec = b'{rev}:{node|short} "{desc|firstline}"{if(%s, " ({%s})")}' % ( + labels_spec, + labels_spec, ) - repo = ctx.repo() - names = [] - for nsname, ns in pycompat.iteritems(repo.names): - if nsname == b'branches': - continue - names.extend(ns.names(repo, ctx.node())) - if names: - desc += b' (%s)' % b' '.join(names) - return desc + return cmdutil.rendertemplate(ctx, spec) class rebaseruntime(object):