On 10.06.2009 16:51, Steve Borho wrote: > On Wed, Jun 10, 2009 at 6:59 AM, Adrian Buehlmann<[email protected]> wrote: >> 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): >>> >> This makes us susceptible to the problem: windows can't >> rename a file that is open for reading. And shellext *is* >> constantly reading. > > Is writing to an open file safer than renaming? Or you just don't > feel the complexity is warranted?
If the shell extension has the file open the rename call will fail, that is, the rpc server process will crash with a traceback. Writing to a file that is open for reading is no problem, but renaming is. On unix you can rename a file that is open for reading, on Windows a rename call for a file that has been opened by fopen will fail. As such the patch doesn't solve anything but introduces a new problem. ------------------------------------------------------------------------------ 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
