util.copyfile and permissions

Chad Dombrova chadrik at gmail.com
Thu Oct 22 02:58:19 UTC 2009


>> this function ensures that the access time and modification time of
>> the destination file matches that of the source file.  where within
>> the repo is this required and where not?
>
> Mercurial assumes it has full read/write access to everything in
> the .hg/ directory. If that fails, things won't go well for you.
> The usual way to deal with this on Unix is with groups and g+rwxs  
> modes
> on the .hg directory and subdirectories. The kernel will take care of
> setting the group on those directories, and Mercurial will take care  
> of
> the r/w permission inheritance.

even with permissions set fully open -- rwx by user/group/other -- it  
is not possible to explicitly set the time of a file that you do not  
own.

from http://www.gnu.org/software/coreutils/manual/html_node/touch-invocation.html:
"If changing both the access and modification times to the current  
time, touch can change the timestamps for files that the user running  
it does not own but has write permission for. Otherwise, the user must  
own the files."

in the case of bookmarks i was wondering if there is some technical  
reason that util.copyfile is used instead of shutil.copyfile, which  
does not attempt to set timestamps.  i'm curious what the purpose of  
setting these timestamps is.  i can see how it would be useful for  
files in the working copy in order to avoid flagging them as modified,  
but for internal files, it is less clear.  this question is in part a  
warning:  if this function is used throughout mercurial as a basic  
copy utility, then it could have pretty serious and unnecessary side  
effects:  a shared repository that can only be safely used by one user  
will probably not be widely useful.

-chad








More information about the Mercurial mailing list