On 10.06.2009 13:23, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <[email protected]>
> # Date 1243410000 -7200
> # Node ID a703c9b518d5fe94002f30bd5b5b7ae73792016e
> # Parent 62587c4f0e577faca23d03048c3ad6a070660001
> shlib: use repo.opener with atomic file for writing status file
>
> like this, there is never a partialy written file
>
> diff -r 62587c4f0e57 -r a703c9b518d5 thgutil/shlib.py
> --- a/thgutil/shlib.py Mit Jun 10 12:24:31 2009 +0200
> +++ b/thgutil/shlib.py Mit Mai 27 09:40:00 2009 +0200
> @@ -92,12 +92,12 @@
> dirstatus[dirname(fn)] = 'm'
> for fn in removed + deleted:
> dirstatus[dirname(fn)] = 'r'
> - f = open(repo.join("thgstatus"), 'wb')
> + f = repo.opener('thgstatus', 'wb', atomictemp=True)
> for dn in sorted(dirstatus):
> s = dirstatus[dn]
> f.write(s + dn + '\n')
> ui.note("%s %s\n" % (s, dn))
> - f.close()
> + f.rename()
>
> else:
> def shell_notify(paths):
>
Ok.
So I have created an opentest.exe by using MingW with
opentest.cpp:
'''
#include <stdio.h>
#include <iostream>
void test()
{
const char* name = "thgstatus";
FILE *f = fopen(name, "rb");
if (f == 0)
{
std::cout << "can't open " << name << std::endl;
return;
}
std::cout << "opened " << name << std::endl;
getchar();
}
int main(int argc, char *argv[])
{
test();
return 0;
}
'''
Makefile:
'''
BASE_LDFLAGS=-lole32 -lkernel32 -luser32 -lgdi32 -lshlwapi -lwininet \
-lwinmm -luuid
LDFLAGS=$(BASE_LDFLAGS) \
-Wl,--subsystem,console,--enable-stdcall-fixup \
-mwindows
# set DEBUG env var to 1 to enable debug trace
ifeq ($(DEBUG),1)
CXXFLAGS+=-D_DEBUG
endif
all: opentest.exe
opentest.exe: opentest.cpp
g++ -o $@ $(CXXFLAGS) -DAPPMAIN $< $(LDFLAGS)
clean:
rm -f *.o *.dll *.exe
'''
Then I have applied Simon's patch to my local clone of thg-crew.
Then I copied opentest.exe into the .hg dir of a testrepo
and started it (on my WinXP computer). So it held open that
thgstatus file forever.
Then I did 'hgtk thgstatus' in that same repo.
What I got was this nice little traceback here:
'''
** Please report this bug to [email protected] or
http://bitbucket.org/tortoisehg/stable/issues
** Mercurial version (6f21613d25a2). TortoiseHg version (unknown)
** Command: thgstatus
** CWD: W:\xxx
** Extensions loaded: mq, graphlog, rebase
Traceback (most recent call last):
File "W:\thg-crew\hggtk\hgtk.py", line 48, in dispatch
return _runcatch(u, args)
File "W:\thg-crew\hggtk\hgtk.py", line 141, in _runcatch
return runcommand(ui, args)
File "W:\thg-crew\hggtk\hgtk.py", line 200, in runcommand
return func(ui, *args, **cmdoptions)
File "W:\thg-crew\hggtk\hgtk.py", line 244, in thgstatus
run(ui, *pats, **opts)
File "W:\thg-crew\hggtk\thgstatus.py", line 58, in run
shlib.update_thgstatus(_ui, root, wait=wait)
File "W:\thg-crew\thgutil\shlib.py", line 100, in update_thgstatus
f.rename()
File "C:\Python25\Lib\site-packages\mercurial\util.py", line 772, in rename
rename(self.temp, localpath(self.__name))
File "C:\Python25\Lib\site-packages\mercurial\util.py", line 414, in rename
os.rename(dst, temp)
WindowsError: [Error 32] The process cannot access the file because it is being
used by another process
'''
Like I feared.
What did I miss / have I done wrong?
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Tortoisehg-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop