Rev 3021: Provide file modes to files created by pack repositories in http://people.ubuntu.com/~robertc/baz2.0/pack.read-locks
Robert Collins
robertc at robertcollins.net
Thu Nov 22 00:30:44 GMT 2007
At http://people.ubuntu.com/~robertc/baz2.0/pack.read-locks
------------------------------------------------------------
revno: 3021
revision-id:robertc at robertcollins.net-20071122003029-puc7qosvic1beace
parent: robertc at robertcollins.net-20071122002958-szgbifl258kcstzp
committer: Robert Collins <robertc at robertcollins.net>
branch nick: pack.read-locks
timestamp: Thu 2007-11-22 11:30:29 +1100
message:
Provide file modes to files created by pack repositories
modified:
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py 2007-11-13 21:39:37 +0000
+++ b/bzrlib/repofmt/pack_repo.py 2007-11-22 00:30:29 +0000
@@ -187,7 +187,7 @@
}
def __init__(self, upload_transport, index_transport, pack_transport,
- upload_suffix=''):
+ upload_suffix='', file_mode=None):
"""Create a NewPack instance.
:param upload_transport: A writable transport for the pack to be
@@ -199,6 +199,7 @@
upload_transport.clone('../packs').
:param upload_suffix: An optional suffix to be given to any temporary
files created during the pack creation. e.g '.autopack'
+ :param file_mode: An optional file mode to create the new files with.
"""
# The relative locations of the packs are constrained, but all are
# passed in because the caller has them, so as to avoid object churn.
@@ -223,6 +224,8 @@
self.index_transport = index_transport
# where is the pack renamed to when it is finished?
self.pack_transport = pack_transport
+ # What file mode to upload the pack and indices with.
+ self._file_mode = file_mode
# tracks the content written to the .pack file.
self._hash = md5.new()
# a four-tuple with the length in bytes of the indices, once the pack
@@ -239,7 +242,7 @@
self.start_time = time.time()
# open an output stream for the data added to the pack.
self.write_stream = self.upload_transport.open_write_stream(
- self.random_name)
+ self.random_name, mode=self._file_mode)
if 'pack' in debug.debug_flags:
mutter('%s: create_pack: pack stream open: %s%s t+%6.3fs',
time.ctime(), self.upload_transport.base, self.random_name,
@@ -368,7 +371,8 @@
"""
index_name = self.index_name(index_type, self.name)
self.index_sizes[self.index_offset(index_type)] = \
- self.index_transport.put_file(index_name, index.finish())
+ self.index_transport.put_file(index_name, index.finish(),
+ mode=self._file_mode)
if 'pack' in debug.debug_flags:
# XXX: size might be interesting?
mutter('%s: create_pack: wrote %s index: %s%s t+%6.3fs',
@@ -533,7 +537,8 @@
"""Open a pack for the pack we are creating."""
return NewPack(self._pack_collection._upload_transport,
self._pack_collection._index_transport,
- self._pack_collection._pack_transport, upload_suffix=self.suffix)
+ self._pack_collection._pack_transport, upload_suffix=self.suffix,
+ file_mode=self._pack_collection.repo.control_files._file_mode)
def _create_pack_from_packs(self):
self.pb.update("Opening pack", 0, 5)
@@ -1245,7 +1250,8 @@
# changing it.
for key, value in disk_nodes:
builder.add_node(key, value)
- self.transport.put_file('pack-names', builder.finish())
+ self.transport.put_file('pack-names', builder.finish(),
+ mode=self.repo.control_files._file_mode)
# move the baseline forward
self._packs_at_load = disk_nodes
# now clear out the obsolete packs directory
@@ -1288,7 +1294,8 @@
if not self.repo.is_write_locked():
raise errors.NotWriteLocked(self)
self._new_pack = NewPack(self._upload_transport, self._index_transport,
- self._pack_transport, upload_suffix='.pack')
+ self._pack_transport, upload_suffix='.pack',
+ file_mode=self.repo.control_files._file_mode)
# allow writing: queue writes to a new index
self.revision_index.add_writable_index(self._new_pack.revision_index,
self._new_pack)
More information about the bazaar-commits
mailing list