hgext/largefiles/lfutil.py
changeset 15700 1facaad963a8
parent 15660 c7b0bedbb07a
parent 15699 84e55467093c
child 15793 3ef07ecdb0d5
equal deleted inserted replaced
15697:21eb048edc19 15700:1facaad963a8
    77     try:
    77     try:
    78         util.oslink(src, dest)
    78         util.oslink(src, dest)
    79     except OSError:
    79     except OSError:
    80         # if hardlinks fail, fallback on atomic copy
    80         # if hardlinks fail, fallback on atomic copy
    81         dst = util.atomictempfile(dest)
    81         dst = util.atomictempfile(dest)
    82         for chunk in util.filechunkiter(open(src)):
    82         for chunk in util.filechunkiter(open(src, 'rb')):
    83             dst.write(chunk)
    83             dst.write(chunk)
    84         dst.close()
    84         dst.close()
    85         os.chmod(dest, os.stat(src).st_mode)
    85         os.chmod(dest, os.stat(src).st_mode)
    86 
    86 
    87 def usercachepath(ui, hash):
    87 def usercachepath(ui, hash):
   236     util.makedirs(os.path.dirname(storepath(repo, hash)))
   236     util.makedirs(os.path.dirname(storepath(repo, hash)))
   237     if inusercache(repo.ui, hash):
   237     if inusercache(repo.ui, hash):
   238         link(usercachepath(repo.ui, hash), storepath(repo, hash))
   238         link(usercachepath(repo.ui, hash), storepath(repo, hash))
   239     else:
   239     else:
   240         dst = util.atomictempfile(storepath(repo, hash))
   240         dst = util.atomictempfile(storepath(repo, hash))
   241         for chunk in util.filechunkiter(open(file)):
   241         for chunk in util.filechunkiter(open(file, 'rb')):
   242             dst.write(chunk)
   242             dst.write(chunk)
   243         dst.close()
   243         dst.close()
   244         util.copymode(file, storepath(repo, hash))
   244         util.copymode(file, storepath(repo, hash))
   245         linktousercache(repo, hash)
   245         linktousercache(repo, hash)
   246 
   246