/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: Andrew Bennetts
  • Date: 2009-12-18 08:22:42 UTC
  • mfrom: (4906 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4909.
  • Revision ID: andrew.bennetts@canonical.com-20091218082242-f7wy9tlk0yxvkkju
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1337
1337
        tree.commit('old tree')
1338
1338
        tree.lock_read()
1339
1339
        self.addCleanup(tree.unlock)
 
1340
        basis_tree = tree.basis_tree()
 
1341
        basis_tree.lock_read()
 
1342
        self.addCleanup(basis_tree.unlock)
1340
1343
        diff_obj = DiffFromTool(['python', '-c',
1341
1344
                                 'print "@old_path @new_path"'],
1342
 
                                tree, tree, output)
 
1345
                                basis_tree, tree, output)
1343
1346
        diff_obj._prepare_files('file-id', 'file', 'file')
1344
 
        self.assertReadableByAttrib(diff_obj._root, 'old\\file', r'old\\file')
1345
 
        self.assertReadableByAttrib(diff_obj._root, 'new\\file', r'new\\file')
 
1347
        # The old content should be readonly
 
1348
        self.assertReadableByAttrib(diff_obj._root, 'old\\file',
 
1349
                                    r'R.*old\\file$')
 
1350
        # The new content should use the tree object, not a 'new' file anymore
 
1351
        self.assertEndsWith(tree.basedir, 'work/tree')
 
1352
        self.assertReadableByAttrib(tree.basedir, 'file', r'work\\tree\\file$')
1346
1353
 
1347
1354
    def assertReadableByAttrib(self, cwd, relpath, regex):
1348
1355
        proc = subprocess.Popen(['attrib', relpath],
1349
1356
                                stdout=subprocess.PIPE,
1350
1357
                                cwd=cwd)
1351
 
        proc.wait()
1352
 
        result = proc.stdout.read()
1353
 
        self.assertContainsRe(result, regex)
 
1358
        (result, err) = proc.communicate()
 
1359
        self.assertContainsRe(result.replace('\r\n', '\n'), regex)
1354
1360
 
1355
1361
    def test_prepare_files(self):
1356
1362
        output = StringIO()