Mercurial > hg-stable
changeset 4830:74f36b1027f4
archive: use util.opener when archiving files.
This simplifies the code a bit and makes it easier to support symlinks.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Wed, 11 Jul 2007 17:40:41 -0300 |
parents | 0403b80352c9 |
children | 6f08bc1bd00b |
files | mercurial/archival.py |
diffstat | 1 files changed, 5 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/archival.py Wed Jul 11 17:40:41 2007 -0300 +++ b/mercurial/archival.py Wed Jul 11 17:40:41 2007 -0300 @@ -149,19 +149,14 @@ if prefix: raise util.Abort(_('cannot give prefix when archiving to files')) self.basedir = name - self.dirs = {} - self.oflags = (os.O_CREAT | os.O_EXCL | os.O_WRONLY | - getattr(os, 'O_BINARY', 0) | - getattr(os, 'O_NOFOLLOW', 0)) + self.opener = util.opener(self.basedir) def addfile(self, name, mode, data): + f = self.opener(name, "w", atomictemp=True) + f.write(data) + f.rename() destfile = os.path.join(self.basedir, name) - destdir = os.path.dirname(destfile) - if destdir not in self.dirs: - if not os.path.isdir(destdir): - os.makedirs(destdir) - self.dirs[destdir] = 1 - os.fdopen(os.open(destfile, self.oflags, mode), 'wb').write(data) + os.chmod(destfile, mode) def done(self): pass