[PATCH] hgweb: display fate of obsolete changesets

Yuya Nishihara yuya at tcha.org
Thu Jan 4 04:36:24 EST 2018


On Thu, 04 Jan 2018 09:44:17 +0100, Boris Feld wrote:
> On Thu, 2018-01-04 at 16:50 +0900, Yuya Nishihara wrote:
> > On Wed, 03 Jan 2018 17:00:35 +0100, Boris Feld wrote:
> > > What about introducing a intermediary function obsfatedata that
> > > would
> > > returns a dictionary with all the raw values.
> > > 
> > > Something like:
> > > 
> > > {'markers': [..., ...],
> > >  'max_date': (0.0, 0),
> > >  'min_date': (0.0, 0),
> > >  'successors': ['7a230b46bf61e50b30308c6cfd7bd1269ef54702'],
> > >  'users': ['test'],
> > >  'verb': 'reworded'}
> > 
> > IIUC, we already have utility functions at that level, such as
> > obsutil.obsfateverb(). What's an advantage of packing them into a
> > dict?
> 
> As Anton said, the obsfateprinter function is not short.
> 
> This function has 3 responsibilities:
> 
> - Gather all obsfate-related information, verb, operation, users, dates
> using functions in obsutil.
> - Apply some logic, like filtering the current user or computing the
> date range.
> - Format a string and returns it.
> 
> The advantage I can see about spitting the formatting in another
> function is that all users could use the same function for the first
> and second responsibility. Also, we won't need to update several
> functions when adding a new obsfate-related field.

The first two are served by template keywords/functions, and the last one
is only needed for changeset_printer.

> > > This dictionnary could then be used by various functions in
> > > different
> > > context to render for hgweb, a non-template translation version and
> > > a
> > > template version.
> > 
> > hgweb thing was implemented using templatekw.
> 
> Right, but we want an implementation not dependent on templatekw to
> clean the following piece of code, right?
> 
> +def obsfate(repo, ctx, ui):
> +    return [obsutil.obsfateprinter(x['successors'], x['markers'], ui)
> +            for x in templatekw.showsuccsandmarkers(repo, ctx)]

No. We decided to export {succsandmarkers} to web templates. We could make
template fragments shared across styles, but that's another story.


More information about the Mercurial-devel mailing list