Mercurial > hg-stable
changeset 19089:0509ae083ec1 stable
largefiles: use repo.wwrite for writing standins (issue3909)
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Sat, 27 Apr 2013 00:41:42 +0200 |
parents | ce4472b2edb2 |
children | ff01506c6852 |
files | hgext/largefiles/lfcommands.py hgext/largefiles/lfutil.py |
diffstat | 2 files changed, 2 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/lfcommands.py Fri Apr 26 19:04:01 2013 +0200 +++ b/hgext/largefiles/lfcommands.py Sat Apr 27 00:41:42 2013 +0200 @@ -215,20 +215,12 @@ raise util.Abort(_('largefile %s becomes symlink') % f) # largefile was modified, update standins - fullpath = rdst.wjoin(f) - util.makedirs(os.path.dirname(fullpath)) m = util.sha1('') m.update(ctx[f].data()) hash = m.hexdigest() if f not in lfiletohash or lfiletohash[f] != hash: - try: - fd = open(fullpath, 'wb') - fd.write(ctx[f].data()) - finally: - if fd: - fd.close() + rdst.wwrite(f, ctx[f].data(), ctx[f].flags()) executable = 'x' in ctx[f].flags() - os.chmod(fullpath, lfutil.getmode(executable)) lfutil.writestandin(rdst, lfutil.standin(f), hash, executable) lfiletohash[f] = hash
--- a/hgext/largefiles/lfutil.py Fri Apr 26 19:04:01 2013 +0200 +++ b/hgext/largefiles/lfutil.py Sat Apr 27 00:41:42 2013 +0200 @@ -277,7 +277,7 @@ def writestandin(repo, standin, hash, executable): '''write hash to <repo.root>/<standin>''' - writehash(hash, repo.wjoin(standin), executable) + repo.wwrite(standin, hash + '\n', executable and 'x' or '') def copyandhash(instream, outfile): '''Read bytes from instream (iterable) and write them to outfile, @@ -301,23 +301,12 @@ fd.close() return hasher.hexdigest() -def writehash(hash, filename, executable): - util.makedirs(os.path.dirname(filename)) - util.writefile(filename, hash + '\n') - os.chmod(filename, getmode(executable)) - def getexecutable(filename): mode = os.stat(filename).st_mode return ((mode & stat.S_IXUSR) and (mode & stat.S_IXGRP) and (mode & stat.S_IXOTH)) -def getmode(executable): - if executable: - return 0755 - else: - return 0644 - def urljoin(first, second, *arg): def join(left, right): if not left.endswith('/'):