[PATCH 1 of 4 py3] similar: avoid sorting and making copies of addedfiles and removedfiles sets

Yuya Nishihara yuya at tcha.org
Wed Mar 22 09:43:58 EDT 2017


On Tue, 21 Mar 2017 15:13:00 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie at google.com>
> # Date 1489903420 14400
> #      Sun Mar 19 02:03:40 2017 -0400
> # Node ID a4745fd9219ed5b408bfc0403a4a8e6acd41df6c
> # Parent  66c3ae6d886cae0e3a3cff6a0058e2d2a866fd9d
> similar: avoid sorting and making copies of addedfiles and removedfiles sets
> 
> The process of porting to Python 3 exposed some weirdness in this
> code: workingfilectx doesn't define rich comparison operators, so in
> Python 2 the default comparison devolved to id(value), which is the
> pointer address of the object. Inspection of _findexactmatches and
> _findsimilarmatches revealed that they didn't care about the sort
> order of the data, so we remove the sort (and potentially make
> addremove faster since it's not sorting things). We now have to do one
> little extra set dance in order to not mutate the addedfiles set
> during its iteration, but that's a small price to pay for the
> resulting cleaner nature of the code.

I have unsent patch to sort files alphabetically, not by memory address. IIRC,
I wrote it because a TortoiseHg user reported that the similarity detection
was unstable if there were multiple candidates of the copy source.

I'll post my patch soon.


More information about the Mercurial-devel mailing list