~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-08-10 06:14:23 UTC
  • mfrom: (1755.3.12 reduce-chmod)
  • Revision ID: pqm@pqm.ubuntu.com-20060810061423-3ae5999a70b60211
(robertc,jam) tweak Transport.append and AtomicFile so put and append are cheaper

Show diffs side-by-side

added added

removed removed

Lines of Context:
964
964
        shape is a sequence of file specifications.  If the final
965
965
        character is '/', a directory is created.
966
966
 
 
967
        This assumes that all the elements in the tree being built are new.
 
968
 
967
969
        This doesn't add anything to a branch.
968
970
        :param line_endings: Either 'binary' or 'native'
969
971
                             in binary mode, exact contents are written
974
976
                          VFS's. If the transport is readonly or None,
975
977
                          "." is opened automatically.
976
978
        """
977
 
        # XXX: It's OK to just create them using forward slashes on windows?
 
979
        # It's OK to just create them using forward slashes on windows.
978
980
        if transport is None or transport.is_readonly():
979
981
            transport = get_transport(".")
980
982
        for name in shape:
989
991
                else:
990
992
                    raise errors.BzrError('Invalid line ending request %r' % (line_endings,))
991
993
                content = "contents of %s%s" % (name.encode('utf-8'), end)
992
 
                transport.put(urlutils.escape(name), StringIO(content))
 
994
                # Technically 'put()' is the right command. However, put
 
995
                # uses an AtomicFile, which requires an extra rename into place
 
996
                # As long as the files didn't exist in the past, append() will
 
997
                # do the same thing as put()
 
998
                # On jam's machine, make_kernel_like_tree is:
 
999
                #   put:    4.5-7.5s (averaging 6s)
 
1000
                #   append: 2.9-4.5s
 
1001
                transport.append(urlutils.escape(name), StringIO(content))
993
1002
 
994
1003
    def build_tree_contents(self, shape):
995
1004
        build_tree_contents(shape)
1253
1262
    testmod_names = [
1254
1263
                   'bzrlib.tests.test_ancestry',
1255
1264
                   'bzrlib.tests.test_api',
 
1265
                   'bzrlib.tests.test_atomicfile',
1256
1266
                   'bzrlib.tests.test_bad_files',
1257
1267
                   'bzrlib.tests.test_branch',
1258
1268
                   'bzrlib.tests.test_bundle',