This is an archive of the discontinued Mercurial Phabricator instance.

shortest: move revnum-disambiguation out of revlog
ClosedPublic

Authored by martinvonz on May 8 2018, 2:07 PM.

Details

Summary

I want to be able to change how we disambiguate and I think having
revlog.shortest() worry only about finding a prefix that's unambiguous
among nodeids makes more sense.

This slows down hg log -T '{shortest(node,1)}\n' from 4.0s to 4.1s.

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.May 8 2018, 2:07 PM
martinvonz updated this revision to Diff 8625.May 10 2018, 12:02 PM
yuja added a subscriber: yuja.May 11 2018, 10:20 AM

+ def disambiguate(prefix):
+ """Disambiguate against revnums."""
+ hexnode = hex(node)
+ for length in range(len(prefix), 41):

Nit: range(len(prefix), len(hexnode) + 1) seems slightly better than
using a magic number outside the revlog module.

+ prefix = hexnode[:length]
+ if not isrev(prefix):
+ return prefix

This revision was automatically updated to reflect the committed changes.