~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-13 18:38:58 UTC
  • mfrom: (1863 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1869.
  • Revision ID: john@arbash-meinel.com-20060713183858-ebf4aa1f9ef8bb6e
[merge] bzr.dev 1863

Show diffs side-by-side

added added

removed removed

Lines of Context:
205
205
        # set the date stamps for files in the working tree to known values
206
206
        os.utime('file1', (1144195200, 1144195200)) # 2006-04-05 00:00:00 UTC
207
207
 
208
 
    def get_diff(self, tree1, tree2):
 
208
    def get_diff(self, tree1, tree2, specific_files=None, working_tree=None):
209
209
        output = StringIO()
210
 
        show_diff_trees(tree1, tree2, output,
211
 
                        old_label='old/', new_label='new/')
 
210
        if working_tree is not None:
 
211
            extra_trees = (working_tree,)
 
212
        else:
 
213
            extra_trees = ()
 
214
        show_diff_trees(tree1, tree2, output, specific_files=specific_files,
 
215
                        extra_trees=extra_trees, old_label='old/', 
 
216
                        new_label='new/')
212
217
        return output.getvalue()
213
218
 
214
219
    def test_diff_rev_tree_working_tree(self):
275
280
 
276
281
''')
277
282
 
 
283
    def test_show_diff_specified(self):
 
284
        """A working tree filename can be used to identify a file"""
 
285
        self.wt.rename_one('file1', 'file1b')
 
286
        old_tree = self.b.repository.revision_tree('rev-1')
 
287
        new_tree = self.b.repository.revision_tree('rev-4')
 
288
        out = self.get_diff(old_tree, new_tree, specific_files=['file1b'], 
 
289
                            working_tree=self.wt)
 
290
        self.assertContainsRe(out, 'file1\t')
 
291
 
 
292
    def test_recursive_diff(self):
 
293
        """Children of directories are matched"""
 
294
        os.mkdir('dir1')
 
295
        os.mkdir('dir2')
 
296
        self.wt.add(['dir1', 'dir2'])
 
297
        self.wt.rename_one('file1', 'dir1/file1')
 
298
        old_tree = self.b.repository.revision_tree('rev-1')
 
299
        new_tree = self.b.repository.revision_tree('rev-4')
 
300
        out = self.get_diff(old_tree, new_tree, specific_files=['dir1'], 
 
301
                            working_tree=self.wt)
 
302
        self.assertContainsRe(out, 'file1\t')
 
303
        out = self.get_diff(old_tree, new_tree, specific_files=['dir2'], 
 
304
                            working_tree=self.wt)
 
305
        self.assertNotContainsRe(out, 'file1\t')
278
306
 
279
307
class TestPatienceDiffLib(TestCase):
280
308