##// END OF EJS Templates
largefiles: use repo.wwrite for writing standins (issue3909)
Mads Kiilerich -
r19089:0509ae08 stable
parent child Browse files
Show More
@@ -215,20 +215,12 b' def _lfconvert_addchangeset(rsrc, rdst, '
215 215 raise util.Abort(_('largefile %s becomes symlink') % f)
216 216
217 217 # largefile was modified, update standins
218 fullpath = rdst.wjoin(f)
219 util.makedirs(os.path.dirname(fullpath))
220 218 m = util.sha1('')
221 219 m.update(ctx[f].data())
222 220 hash = m.hexdigest()
223 221 if f not in lfiletohash or lfiletohash[f] != hash:
224 try:
225 fd = open(fullpath, 'wb')
226 fd.write(ctx[f].data())
227 finally:
228 if fd:
229 fd.close()
222 rdst.wwrite(f, ctx[f].data(), ctx[f].flags())
230 223 executable = 'x' in ctx[f].flags()
231 os.chmod(fullpath, lfutil.getmode(executable))
232 224 lfutil.writestandin(rdst, lfutil.standin(f), hash,
233 225 executable)
234 226 lfiletohash[f] = hash
@@ -277,7 +277,7 b' def readstandin(repo, filename, node=Non'
277 277
278 278 def writestandin(repo, standin, hash, executable):
279 279 '''write hash to <repo.root>/<standin>'''
280 writehash(hash, repo.wjoin(standin), executable)
280 repo.wwrite(standin, hash + '\n', executable and 'x' or '')
281 281
282 282 def copyandhash(instream, outfile):
283 283 '''Read bytes from instream (iterable) and write them to outfile,
@@ -301,23 +301,12 b' def hashfile(file):'
301 301 fd.close()
302 302 return hasher.hexdigest()
303 303
304 def writehash(hash, filename, executable):
305 util.makedirs(os.path.dirname(filename))
306 util.writefile(filename, hash + '\n')
307 os.chmod(filename, getmode(executable))
308
309 304 def getexecutable(filename):
310 305 mode = os.stat(filename).st_mode
311 306 return ((mode & stat.S_IXUSR) and
312 307 (mode & stat.S_IXGRP) and
313 308 (mode & stat.S_IXOTH))
314 309
315 def getmode(executable):
316 if executable:
317 return 0755
318 else:
319 return 0644
320
321 310 def urljoin(first, second, *arg):
322 311 def join(left, right):
323 312 if not left.endswith('/'):
General Comments 0
You need to be logged in to leave comments. Login now