Mercurial > hg
view tests/test-debugextensions.t @ 31210:e1d035905b2e
similar: compare between actual file contents for exact identity
Before this patch, similarity detection logic (for addremove and
automv) depends entirely on SHA-1 digesting. But this causes incorrect
rename detection, if:
- removing file A and adding file B occur at same committing, and
- SHA-1 hash values of file A and B are same
This may prevent security experts from managing sample files for
SHAttered issue in Mercurial repository, for example.
https://security.googleblog.com/2017/02/announcing-first-sha1-collision.html
https://shattered.it/
Hash collision itself isn't so serious for core repository
functionality of Mercurial, described by mpm as below, though.
https://www.mercurial-scm.org/wiki/mpm/SHA1
This patch compares between actual file contents after hash comparison
for exact identity.
Even after this patch, SHA-1 is still used, because it is reasonable
enough to quickly detect existence of "(almost) same" file.
- replacing SHA-1 causes decreasing performance, and
- replacement of it has ambiguity, yet
Getting content of removed file (= rfctx.data()) at each exact
comparison should be cheap enough, even though getting content of
added one costs much.
======= ============== =====================
file fctx data() reads from
======= ============== =====================
removed filectx in-memory revlog data
added workingfilectx storage
======= ============== =====================
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 03 Mar 2017 02:57:06 +0900 |
parents | 4c28ddda5d48 |
children | a543d17dce03 |
line wrap: on
line source
$ hg debugextensions $ debugpath=`pwd`/extwithoutinfos.py $ cat > extwithoutinfos.py <<EOF > EOF $ cat > extwithinfos.py <<EOF > testedwith = '3.0 3.1 3.2.1' > buglink = 'https://example.org/bts' > EOF $ cat >> $HGRCPATH <<EOF > [extensions] > color= > histedit= > patchbomb= > rebase= > mq= > ext1 = $debugpath > ext2 = `pwd`/extwithinfos.py > EOF $ hg debugextensions color ext1 (untested!) ext2 (3.2.1!) histedit mq patchbomb rebase $ hg debugextensions -v color location: */hgext/color.py* (glob) bundled: yes ext1 location: */extwithoutinfos.py* (glob) bundled: no ext2 location: */extwithinfos.py* (glob) bundled: no tested with: 3.0 3.1 3.2.1 bug reporting: https://example.org/bts histedit location: */hgext/histedit.py* (glob) bundled: yes mq location: */hgext/mq.py* (glob) bundled: yes patchbomb location: */hgext/patchbomb.py* (glob) bundled: yes rebase location: */hgext/rebase.py* (glob) bundled: yes $ hg debugextensions -Tjson | sed 's|\\\\|/|g' [ { "buglink": "", "bundled": true, "name": "color", "source": "*/hgext/color.py*", (glob) "testedwith": [] }, { "buglink": "", "bundled": false, "name": "ext1", "source": "*/extwithoutinfos.py*", (glob) "testedwith": [] }, { "buglink": "https://example.org/bts", "bundled": false, "name": "ext2", "source": "*/extwithinfos.py*", (glob) "testedwith": ["3.0", "3.1", "3.2.1"] }, { "buglink": "", "bundled": true, "name": "histedit", "source": "*/hgext/histedit.py*", (glob) "testedwith": [] }, { "buglink": "", "bundled": true, "name": "mq", "source": "*/hgext/mq.py*", (glob) "testedwith": [] }, { "buglink": "", "bundled": true, "name": "patchbomb", "source": "*/hgext/patchbomb.py*", (glob) "testedwith": [] }, { "buglink": "", "bundled": true, "name": "rebase", "source": "*/hgext/rebase.py*", (glob) "testedwith": [] } ] $ hg debugextensions -T '{ifcontains("3.1", testedwith, "{name}\n")}' ext2 $ hg debugextensions \ > -T '{ifcontains("3.2", testedwith, "no substring match: {name}\n")}'