Mercurial temporary file nomenclature

Jason Harris jason.f.harris at gmail.com
Mon Apr 12 20:25:37 UTC 2010


Wow! That appears to work! I can change the code to then simply 

 fh, fn = tempfile.mkstemp(prefix='hg-check-exec-')

To ensure this temp file is then generated outside the tree in the default temp file location... Is there anything bad about that then?  It looks from the intent of this code that you want to check the executable bit, maybe we could locate the temporary file in the parent directory then? Ie:

fh, fn = tempfile.mkstemp(dir= os.path.dirname(path), prefix='hg-check-exec-')

Or failing that then a specific file inside a folder inside the .hg directory and then FSEventStream (and I am guessing other tools) can ignore that directory. FSEventStream only works on directories and not on files.

Thus it could be:
fh, fn = tempfile.mkstemp(dir= os.path.join(path,".hg","temporaryFileDirectory"), prefix='hg-check-exec-')

and clients could then ignore <repository-path>/.hg/temporaryFileDirectory/

Thanks!
   Jason

On Apr 12, 2010, at 9:35 PM, Benoit Boissinot wrote:

> On Mon, Apr 12, 2010 at 9:32 PM, Dirkjan Ochtman <dirkjan at ochtman.nl> wrote:
>> On Mon, Apr 12, 2010 at 21:26, Jason Harris <jason.f.harris at gmail.com> wrote:
>>> No I am not using inotify. Sorry, but something quite similar. I am using apples FSEventStream functionality, to get notified when changes occur in a directory. Then I can rescan that directory, but since that file goes wizzing, the stream handling catches this and I turn around and rescan the directory, which causes another file to whizz by, which I then rescan the directory for, which causes another file to wizz by and well you get the idea. Thus I have to try and interrupt this process...
>>> 
>>> I suspend watching the stream until my scan is done, then try to flush the queued up notifications, but I have to wait a bit for the notifications to clear before I can pay attention to them, and this waiting time can be variable... and well this whole process is kind of unstable. It works but, man I wish I could just have the temp files generated outside of the tree.
>> 
>> So apparently this even happens without inotify?
> 
> The following should fix it:
> 
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -664,7 +664,7 @@
> 
>     try:
>         EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
> -        fh, fn = tempfile.mkstemp("", "", path)
> +        fh, fn = tempfile.mkstemp(dir=path, prefix='hg-check-exec-')
>         try:
>             os.close(fh)
>             m = os.stat(fn).st_mode & 0777
> 
> Cheers,
> 
> Benoit




More information about the Mercurial mailing list