226 def copytostoreabsolute(repo, file, hash): |
226 def copytostoreabsolute(repo, file, hash): |
227 util.makedirs(os.path.dirname(storepath(repo, hash))) |
227 util.makedirs(os.path.dirname(storepath(repo, hash))) |
228 if inusercache(repo.ui, hash): |
228 if inusercache(repo.ui, hash): |
229 link(usercachepath(repo.ui, hash), storepath(repo, hash)) |
229 link(usercachepath(repo.ui, hash), storepath(repo, hash)) |
230 else: |
230 else: |
231 shutil.copyfile(file, storepath(repo, hash)) |
231 dst = util.atomictempfile(storepath(repo, hash)) |
232 os.chmod(storepath(repo, hash), os.stat(file).st_mode) |
232 for chunk in util.filechunkiter(open(file)): |
|
233 dst.write(chunk) |
|
234 dst.close() |
|
235 util.copymode(file, storepath(repo, hash)) |
233 linktousercache(repo, hash) |
236 linktousercache(repo, hash) |
234 |
237 |
235 def linktousercache(repo, hash): |
238 def linktousercache(repo, hash): |
236 util.makedirs(os.path.dirname(usercachepath(repo.ui, hash))) |
239 util.makedirs(os.path.dirname(usercachepath(repo.ui, hash))) |
237 link(storepath(repo, hash), usercachepath(repo.ui, hash)) |
240 link(storepath(repo, hash), usercachepath(repo.ui, hash)) |