comparison hgext/remotefilelog/__init__.py @ 41248:312afd164009

remotefilelog: do file IO in terms of bytes Differential Revision: https://phab.mercurial-scm.org/D5597
author Augie Fackler <augie@google.com>
date Wed, 16 Jan 2019 10:55:42 -0500
parents 2338eab5f8b7
children 62bf34f70fe8
comparison
equal deleted inserted replaced
41247:a89b20a49c13 41248:312afd164009
802 repospath = os.path.join(cachepath, 'repos') 802 repospath = os.path.join(cachepath, 'repos')
803 if not os.path.exists(repospath): 803 if not os.path.exists(repospath):
804 ui.warn(_("no known cache at %s\n") % cachepath) 804 ui.warn(_("no known cache at %s\n") % cachepath)
805 return 805 return
806 806
807 reposfile = open(repospath, 'r') 807 reposfile = open(repospath, 'rb')
808 repos = set([r[:-1] for r in reposfile.readlines()]) 808 repos = set([r[:-1] for r in reposfile.readlines()])
809 reposfile.close() 809 reposfile.close()
810 810
811 # build list of useful files 811 # build list of useful files
812 validrepos = [] 812 validrepos = []
872 progress.complete() 872 progress.complete()
873 873
874 # write list of valid repos back 874 # write list of valid repos back
875 oldumask = os.umask(0o002) 875 oldumask = os.umask(0o002)
876 try: 876 try:
877 reposfile = open(repospath, 'w') 877 reposfile = open(repospath, 'wb')
878 reposfile.writelines([("%s\n" % r) for r in validrepos]) 878 reposfile.writelines([("%s\n" % r) for r in validrepos])
879 reposfile.close() 879 reposfile.close()
880 finally: 880 finally:
881 os.umask(oldumask) 881 os.umask(oldumask)
882 882