/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-01-03 16:01:06 UTC
  • mfrom: (3123.6.8 no-inventory2)
  • Revision ID: pqm@pqm.ubuntu.com-20080103160106-v6qfwv4ta8sorx1q
diff --using uses symlinks if possible,
        marks temp files read-only (abentley)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
import os
 
18
import os.path
18
19
from cStringIO import StringIO
19
20
import errno
20
21
import subprocess
1270
1271
    def test_prepare_files(self):
1271
1272
        output = StringIO()
1272
1273
        tree = self.make_branch_and_tree('tree')
1273
 
        self.build_tree_contents([('tree/file', 'oldcontent')])
1274
 
        tree.add('file', 'file-id')
1275
 
        tree.commit('old tree')
1276
 
        self.build_tree_contents([('tree/file', 'newcontent')])
 
1274
        self.build_tree_contents([('tree/oldname', 'oldcontent')])
 
1275
        tree.add('oldname', 'file-id')
 
1276
        tree.commit('old tree', timestamp=0)
 
1277
        tree.rename_one('oldname', 'newname')
 
1278
        self.build_tree_contents([('tree/newname', 'newcontent')])
1277
1279
        old_tree = tree.basis_tree()
1278
1280
        old_tree.lock_read()
1279
1281
        self.addCleanup(old_tree.unlock)
 
1282
        tree.lock_read()
 
1283
        self.addCleanup(tree.unlock)
1280
1284
        diff_obj = DiffFromTool(['python', '-c',
1281
1285
                                 'print "%(old_path)s %(new_path)s"'],
1282
1286
                                old_tree, tree, output)
1285
1289
        old_path, new_path = diff_obj._prepare_files('file-id', 'oldname',
1286
1290
                                                     'newname')
1287
1291
        self.assertContainsRe(old_path, 'old/oldname$')
 
1292
        self.assertEqual(0, os.stat(old_path).st_mtime)
1288
1293
        self.assertContainsRe(new_path, 'new/newname$')
1289
1294
        self.assertFileEqual('oldcontent', old_path)
1290
1295
        self.assertFileEqual('newcontent', new_path)
 
1296
        if osutils.has_symlinks():
 
1297
            self.assertTrue(os.path.samefile('tree/newname', new_path))
1291
1298
        # make sure we can create files with the same parent directories
1292
1299
        diff_obj._prepare_files('file-id', 'oldname2', 'newname2')