Mercurial > hg-stable
changeset 14008:da65edcac72a
atomictempfile: rewrite docstring to clarify rename() vs. close().
author | Greg Ward <greg@gerg.ca> |
---|---|
date | Sun, 24 Apr 2011 17:30:50 -0400 |
parents | d764463b433e |
children | 64de9ca66511 bcff4759d17d |
files | mercurial/util.py |
diffstat | 1 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/util.py Sun Apr 24 19:25:10 2011 -0400 +++ b/mercurial/util.py Sun Apr 24 17:30:50 2011 -0400 @@ -719,12 +719,15 @@ return temp class atomictempfile(object): - """file-like object that atomically updates a file + '''writeable file object that atomically updates a file - All writes will be redirected to a temporary copy of the original - file. When rename is called, the copy is renamed to the original - name, making the changes visible. - """ + All writes will go to a temporary copy of the original file. Call + rename() when you are done writing, and atomictempfile will rename + the temporary copy to the original name, making the changes visible. + + Unlike other file-like objects, close() discards your writes by + simply deleting the temporary file. + ''' def __init__(self, name, mode='w+b', createmode=None): self.__name = name # permanent name self._tempname = mktempcopy(name, emptyok=('w' in mode),