( )⚙ D724 templater: extract shortest() logic from template function

This is an archive of the discontinued Mercurial Phabricator instance.

templater: extract shortest() logic from template function
ClosedPublic

Authored by martinvonz on Sep 15 2017, 2:23 PM.

Details

Summary

It can be useful for extensions to be able to produce the shortest
unambiguous hash (including the in-tree "show" extension). That logic
is currently inside the shortest() template function. Let's move it
out of the templater. I've put it on revlog since it's closely related
to revlog._partialmatch. We may also want a convenience method on
context, but I'll leave that for a later patch.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

martinvonz created this revision.Sep 15 2017, 2:23 PM
quark accepted this revision.Sep 15 2017, 6:26 PM
quark added a subscriber: quark.

It might make sense to be a revlog method if we don't really care about the "cleanness" of revlog class. I slightly prefer that.

martinvonz edited the summary of this revision. (Show Details)Sep 15 2017, 7:37 PM
martinvonz updated this revision to Diff 1860.
In D724#12091, @quark wrote:

It might make sense to be a revlog method if we don't really care about the "cleanness" of revlog class. I slightly prefer that.

Heh, that's what I decided to do. I apparently forgot to send it after tests had run, but now it's there. PTAL.

yuja accepted this revision.Sep 16 2017, 7:49 PM
yuja added a subscriber: yuja.

Queued, thanks.

I slightly prefer moving shortest() to scmutil as it seems not a core function
of revlog, but that's just my preference.

This revision is now accepted and ready to land.Sep 16 2017, 7:49 PM
This revision was automatically updated to reflect the committed changes.
quark added a comment.EditedSep 16 2017, 10:49 PM

Oops. What I originally thought was shortest may have alternative implementation if the changelog is not backed by revlog (in the far far future). So it feels the current implementation (using some revlog internals) belongs to revlog itself.

yuja added a comment.Sep 17 2017, 10:35 PM

\What I originally thought was shortest may have alternative implementation if the changelog is not backed by revlog (in the far far future).

Okay, got it. Even if it's backed by revlog, shortest can be implemented as a one-pass
lookup of prefix tree.