[Bug 4649] New: Mercurial commands should display unambiguous hashes

mercurial-bugs at selenic.com mercurial-bugs at selenic.com
Wed May 6 07:44:45 UTC 2015


http://bz.selenic.com/show_bug.cgi?id=4649

          Priority: normal
            Bug ID: 4649
                CC: gregory.szorc at gmail.com, mercurial-devel at selenic.com,
                    mh+hg at glandium.org
          Assignee: bugzilla at selenic.com
           Summary: Mercurial commands should display unambiguous hashes
          Severity: bug
    Classification: Unclassified
                OS: All
          Reporter: jandemooij at gmail.com
          Hardware: All
            Status: UNCONFIRMED
           Version: unspecified
         Component: Mercurial
           Product: Mercurial

Yesterday I wrote a tool to create Mercurial short-hash collisions:

http://www.jandemooij.nl/blog/2015/05/05/using-rust-to-generate-mercurial-short-hash-collisions/

We noticed that Mercurial, by default, displays short hashes (12 hex chars),
even if these are ambiguous:

$ hg id
b991f0726738 patch/qbase/qtip/tip
$ hg log -r b991f0726738
abort: 00changelog.i at b991f0726738: ambiguous identifier!

So if there's a collision, the output of |hg id| and |hg log| is no longer
useful to identify the current revision. It'd be nice if these commands always
printed an unambiguous hash.

To quote Gregory Szorc, one of our Mercurial gurus:

Mercurial does have a “shortest(node, minlength)” template that is used to
render the shortest hex SHA-1 that isn’t ambiguous. The default templates for
Mercurial should arguably be using “shortest(node, 12)” instead of
“short(node)” so collisions in the first 48 bits don’t result in ambiguous
output.

And also:

This could be a “fun” bug since there are performance considerations with
enabling it globally. But certain commands like `hg id` can probably be changed
without much thought.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Mercurial-devel mailing list