This is an archive of the discontinued Mercurial Phabricator instance.

scmutil: make shortesthexnodeidprefix() take a full binary nodeid
ClosedPublic

Authored by martinvonz on Apr 14 2018, 3:20 AM.

Details

Summary

The shortest() template function depended on the behavior of
revlog._partialmatch() for these types of inputs:

  • non-hex strings
  • ambiguous strings
  • too long strings

revlog._partialmatch() seems to return the input unchanged in these
cases, but we shouldn't depend on such a low-level function to match
the behavior we want in the user-facing template function. Instead,
let's handle these cases in the template function and always pass a
binary nodeid to _partialmatch().

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

martinvonz created this revision.Apr 14 2018, 3:20 AM
martinvonz updated this revision to Diff 8286.Apr 14 2018, 12:21 PM
yuja added a subscriber: yuja.Apr 15 2018, 9:39 AM

Queued thanks.

The shortest() template function depended on the behavior of
revlog._partialmatch() for these types of inputs:

I guess some of them would be bug.

mercurial/templatefuncs.py
605

One minor bug in this patch.
hg log -T '{shortest(node|short)}\n' -r 'wdir()' no longer works.

This revision was automatically updated to reflect the committed changes.