##// END OF EJS Templates
windows.rename: eliminate temp name race (issue2571)...
windows.rename: eliminate temp name race (issue2571) On Windows, os.rename reliably raises OSError with errno.EEXIST if the destination already exists (even on shares served by Samba). Windows does *not* silently overwrite the destination of a rename. So there is no need to first call os.path.exists on the chosen temp path. Trusting os.path.exists is actually harmful, since using it enables the following racy sequence of actions: 1) os.path.exists(temp) returns False 2) some evil other process creates a file with name temp 3) os.rename(dst, temp) now fails because temp has been taken Not using os.path.exists and directly trying os.rename(dst, temp) eliminates this race.

File last commit:

r13194:b549ee32 default
r13206:650314ed stable
Show More
test-doctest.py
20 lines | 502 B | text/x-python | PythonLexer
# this is hack to make sure no escape characters are inserted into the output
import os
if 'TERM' in os.environ:
del os.environ['TERM']
import doctest
import mercurial.changelog
doctest.testmod(mercurial.changelog)
import mercurial.dagparser
doctest.testmod(mercurial.dagparser, optionflags=doctest.NORMALIZE_WHITESPACE)
import mercurial.match
doctest.testmod(mercurial.match)
import mercurial.url
doctest.testmod(mercurial.url)
import hgext.convert.cvsps
doctest.testmod(hgext.convert.cvsps)