[PATCH 2 of 2 V2] show: new extension for displaying various repository data

Augie Fackler raf at durin42.com
Thu Mar 23 11:38:45 EDT 2017


On Thu, Mar 23, 2017 at 12:16:16AM +0900, Yuya Nishihara wrote:
> On Tue, 21 Mar 2017 23:52:42 -0700, Gregory Szorc wrote:
> > On Tue, Mar 21, 2017 at 11:49 PM, Gregory Szorc <gregory.szorc at gmail.com>
> > wrote:
> >
> > > # HG changeset patch
> > > # User Gregory Szorc <gregory.szorc at gmail.com>
> > > # Date 1490165337 25200
> > > #      Tue Mar 21 23:48:57 2017 -0700
> > > # Node ID 80ca2bee4a06887f918e3328b3f005e4c1cb1ab1
> > > # Parent  ae796e23fd42b036352b298f570af8949c2db2d9
> > > show: new extension for displaying various repository data
> > >
> >
> > Yuya, et al:
> >
> > Since the default output isn't covered by BC guarantees, we probably want
> > HGPLAIN to be. I'm not sure what the preferred way to do that should be.
> > Should I create a separate topic within the template for the plain view?
>
> No idea about BC guarantees vs HGPLAIN. HGPLAIN is to disable user
> configuration. If "hg show" is covered by e.g. compat version, we'll only
> need to set it to the lowest version if HGPLAIN set.

My vision for `hg show` was that we document it as having explicitly
unstable output and unsuitable for scripting. Perhaps in light of
that, HGPLAIN=1 should cause `hg show` to say `abort: show is only for
humans, you appear to be a robot` or similar.

>
> > I'm still a bit confused as to how formatters work :/
>
> [...]
>
> > > + at showview('bookmarks', fmtopic='bookmarks')
> > > +def showbookmarks(ui, repo, fm):
> > > +    """bookmarks and their associated changeset"""
> > > +    marks = repo._bookmarks
> > > +    if not len(marks):
> > > +        ui.write(_('(no bookmarks set)\n'))
> > > +        return
> > > +
> > > +    active = repo._activebookmark
> > > +    longest = max(len(b) for b in marks)
> > > +
> > > +    for bm, node in sorted(marks.items()):
> > > +        fm.startitem()
> > > +        fm.context(ctx=repo[node])
> > > +        fm.write('bookmark', '%s', bm)
> > > +        fm.write('node', fm.hexfunc(node), fm.hexfunc(node))
> > > +        fm.data(active=bm == active,
> > > +                _longestlen=longest)
>
> I think the formatter API was designed to make hand-written output formatting
> templatable, so the default (plain) output doesn't use template file.
>
>   bookmarkfmt = '%%-%ds' % longest
>   fm.write('bookmark', bookmarkfmt, bm)
>   fm.write('node', '%s\n', fm.hexfunc_that_uses_shortest(node))
>
> But 'hg show' does use template by default. That's why fm.plain() doesn't work.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list