[PATCH 2 of 2] util: move checknlink away from the dependency of a hard-coded filename

Tony Tung tonytung at instagram.com
Tue Aug 23 13:38:01 EDT 2016


> On Aug 23, 2016, at 10:30 AM, Tony Tung <tonytung at instagram.com> wrote:
> 
>> On Aug 23, 2016, at 8:28 AM, Yuya Nishihara <yuya at tcha.org> wrote:
>> 
>>> +    # there's a small race condition that another file can jam itself in between
>>> +    # the time we remove f2 and the time we create the hard link.  in the
>>> +    # unlikely scenario that happens, we'll treat it as nlink being unreliable.
>>>    try:
>> [...]
>>> +        os.unlink(f2path)
>>> +        oslink(f1path, f2path)
>> 
>> I would use f2path = f1path + '.2' assuming f1path has enough random bits, but
>> your version, mkstemp+unlink+link, should be more robust for a race condition.
> 
> I think I can actually make this more robust. :)
> 
> Thanks,
> Tony


… I take that back.  But I’ll fix the cleanup path.

Thanks,
Tony


More information about the Mercurial-devel mailing list