in a different pack.
"""
fd, path = tempfile.mkstemp(dir=self.pack_dir, suffix=".pack")
- f = os.fdopen(fd, 'w')
+ f = os.fdopen(fd, 'wb')
def commit():
os.fsync(fd)
f.close()
call when the pack is finished.
"""
fd, path = tempfile.mkstemp(dir=self.pack_dir, suffix=".pack")
- f = os.fdopen(fd, 'w')
+ f = os.fdopen(fd, 'wb')
def commit():
os.fsync(fd)
f.close()
def load_pack_index(filename):
- f = open(filename, 'r')
+ f = open(filename, 'rb')
if f.read(4) == '\377tOc':
version = struct.unpack(">L", f.read(4))[0]
if version == 2:
# ensure that it hasn't changed.
self._size = os.path.getsize(filename)
if file is None:
- self._file = open(filename, 'r')
+ self._file = open(filename, 'rb')
else:
self._file = file
self._contents, map_offset = simple_mmap(self._file, 0, self._size)
:param objects: Iterable over (object, path) tuples to write
:param num_objects: Number of objects to write
"""
- f = open(filename + ".pack", 'w')
+ f = open(filename + ".pack", 'wb')
try:
entries, data_sum = write_pack_data(f, objects, num_objects)
finally:
crc32_checksum.
:param pack_checksum: Checksum of the pack file.
"""
- f = open(filename, 'w')
+ f = open(filename, 'wb')
f = SHA1Writer(f)
fan_out_table = defaultdict(lambda: 0)
for (name, offset, entry_checksum) in entries:
crc32_checksum.
:param pack_checksum: Checksum of the pack file.
"""
- f = open(filename, 'w')
+ f = open(filename, 'wb')
f = SHA1Writer(f)
f.write('\377tOc') # Magic!
f.write(struct.pack(">L", 2))
dirpath = os.path.dirname(file)
if not os.path.exists(dirpath):
os.makedirs(dirpath)
- f = open(file, 'w')
+ f = open(file, 'wb')
try:
f.write(ref+"\n")
finally:
os.mkdir(os.path.join(path, *d))
ret = cls(path)
ret.refs.set_ref("HEAD", "refs/heads/master")
- open(os.path.join(path, 'description'), 'w').write("Unnamed repository")
- open(os.path.join(path, 'info', 'excludes'), 'w').write("")
+ open(os.path.join(path, 'description'), 'wb').write("Unnamed repository")
+ open(os.path.join(path, 'info', 'excludes'), 'wb').write("")
return ret
create = init_bare