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.
Details
Diff Detail
- Repository
- rHG Mercurial
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
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.
Queued, thanks.
I slightly prefer moving shortest() to scmutil as it seems not a core function
of revlog, but that's just my preference.
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.
\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.