'Add a new pack to this object store.
:return: Fileobject to write to and a commit function to
call when the pack is finished.'

def add_pack(self):

    f = BytesIO()
    def commit():
        f.seek(0)
        pack = PackData(file=f, filename='')
        entries = pack.sorted_entries()
        if len(entries):
            basename = posixpath.join(self.pack_dir, ('pack-%s' % iter_sha1((entry[0] for entry in entries))))
            index = BytesIO()
            write_pack_index_v2(index, entries, pack.get_stored_checksum())
            self.scon.put_object((basename + '.pack'), f)
            f.close()
            self.scon.put_object((basename + '.idx'), index)
            index.close()
            final_pack = SwiftPack(basename, scon=self.scon)
            final_pack.check_length_and_checksum()
            self._add_known_pack(basename, final_pack)
            return final_pack
        else:
            return None
    def abort():
        pass
    return (f, commit, abort)
