D5742: histedit: add templating support to histedit's rule file generation

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Wed Jan 30 07:11:41 EST 2019


yuja added a comment.


  > +  [histedit]
  >  +  summary-format = '{rev} {bookmarks} {desc|firstline}'
  
  Perhaps, "summary-template" is more consistent with the other config keys.
  
  >   ctx = self.repo[self.node]
  > 
  > - summary = _getsummary(ctx)
  > - line = '%s %s %d %s' % (self.verb, ctx, ctx.rev(), summary) +        ui = self.repo.ui +        tres = formatter.templateresources(ui, self.repo) +        t = formatter.maketemplater(ui, ui.config('histedit', 'summary-format'), +                                    defaults=templatekw.keywords, +                                    resources=tres)
  
  `cmdutil.rendertemplate()` can be used.
  
  And it's probably better to do `templater.unquotestring(ui.config(...))` for
  consistency, even though we won't need any syntax to preserve leading/trailing
  spaces here.
  
  > +        summary = t.renderdefault({'ctx': ctx}).splitlines()[0]
  
  Nit: `splitlines()[0]` would fail if template was empty.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5742

To: durin42, #hg-reviewers
Cc: yuja, mercurial-devel


More information about the Mercurial-devel mailing list