[PATCH] update: fix edge-case with update.atomic-file and read-only files

Boris FELD boris.feld at octobus.net
Sun Jan 13 04:28:33 EST 2019


On 12/01/2019 04:32, Yuya Nishihara wrote:
>>          self._tempname = mktempcopy(name, emptyok=('w' in mode),
>>                                      createmode=createmode)
>> +
>> +        # If we are gonna write on the tempfile, we need to make sure we have
>> +        # the permission to do so
>> +        if 'w' in mode and os.path.isfile(name):
>> +            oldstat = filestat.frompath(name)
>> +            newstat = oldstat.stat.st_mode | stat.S_IWUSR
>> +            os.chmod(self._tempname, newstat)
> Isn't it better to add an option for mktempcopy() to forcibly flag S_IWUSR
> bit on?

I was hesitant between the two designs. I give a try to the mktempcopy
modification design thanks to your comment and it seems better.

I'm not familiar with how Windows handle file permissions but I see that
copymode for windows does nothing. Should we also avoid enforcing the
writable bit on Windows platform?

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list