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

Yuya Nishihara yuya at tcha.org
Fri Jan 11 22:32:29 EST 2019


>          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?


More information about the Mercurial-devel mailing list