[PATCH 2 of 5 STABLE] transaction: separate calculating TXNID from creating transaction object

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed May 20 10:39:39 CDT 2015

On 05/20/2015 08:14 AM, FUJIWARA Katsunori wrote:
> At Tue, 19 May 2015 17:26:39 -0500,
> Pierre-Yves David wrote:
>> On 05/19/2015 10:39 AM, FUJIWARA Katsunori wrote:
>>> # HG changeset patch
>>> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
>>> # Date 1432049572 -32400
>>> #      Wed May 20 00:32:52 2015 +0900
>>> # Branch stable
>>> # Node ID ae2915053ec6ee06c64482fba7ba668ce91305e1
>>> # Parent  11f3cae961f815ee7f8acc4e0312ed724d4ef8fe
>>> transaction: separate calculating TXNID from creating transaction object
>>> Before this patch, transaction ID (TXNID) is calculated from
>>> `transaction` object itself, but this prevents TXNID from being passed
>>> to `pretxnopen` hooks, which should be executed before starting
>>> transaction processing (also any preparations for it, like writing
>>> journal files out).
>>> As a preparation for passing TXNID to `pretxnopen` hooks, this patch
>>> separates calculation of TXNID from creation of `transaction` object.
>>> To keep uniqueness of assigned TXNID (= prevent `idobj` from being
>>> reused at another `txnid()` invocation) while corresponded
>>> `transaction` object is alive, this patch also adds `_txnid` field to
>>> `transaction` and makes it refer the tuple returned by `txnid()`.
>> I think this object() business is to awful. We have been using id(txn)
>> because it was super simple and "good enough". But this is becoming to
>> complicated.
>> We need a simple way to generate unique ID. I would point at "uuid" if
>> the branch was not still Python2.4 compatible. Can I leave you with the
>> task of finding a good enough uniq (enough) id generator on stable?
>> (marmoute give a side looks at random) and send a V3 of this series?
> I thought that `id(obj)` style is used because we don't want to use
> "random" library (maybe for performance reason), "uuid" (performance
> and Python 2.4 compatibility reason) or so.
> I'll send V3 series using "random".

I picked id(txn) because that was the simplest thing around while doing 
that. transaction opening have enough overhead so that we do not care 
about the "cost" of speudo random generation. And speudo random 
generation is not crazilly expensive either.

Pierre-Yves David

More information about the Mercurial-devel mailing list