Rev 2440: Clean up test_bad_files, and fix a bug in _iter_changes when in http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate
John Arbash Meinel
john at arbash-meinel.com
Wed Feb 28 22:41:58 GMT 2007
At http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate
------------------------------------------------------------
revno: 2440
revision-id: john at arbash-meinel.com-20070228224054-11e83q8puulllfuh
parent: john at arbash-meinel.com-20070228221101-c3szee94o5h3uvt7
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate
timestamp: Wed 2007-02-28 16:40:54 -0600
message:
Clean up test_bad_files, and fix a bug in _iter_changes when
we get to an unknown file.
modified:
bzrlib/tests/intertree_implementations/test_compare.py test_compare.py-20060724101752-09ysswo1a92uqyoz-2
bzrlib/tests/test_bad_files.py test_bad_files.py-20050918155938-c76a2295c8ab9503
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
-------------- next part --------------
=== modified file 'bzrlib/tests/intertree_implementations/test_compare.py'
--- a/bzrlib/tests/intertree_implementations/test_compare.py 2007-02-27 22:07:53 +0000
+++ b/bzrlib/tests/intertree_implementations/test_compare.py 2007-02-28 22:40:54 +0000
@@ -767,3 +767,24 @@
expected = sorted(self.content_changed(tree2, f_id) for f_id in path_ids
if f_id.endswith('_f-id'))
self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
+
+ def test_trees_with_unknown(self):
+ tree1 = self.make_branch_and_tree('tree1')
+ tree2 = self.make_to_branch_and_tree('tree2')
+ self.build_tree(['tree1/a', 'tree1/c',
+ 'tree2/a', 'tree2/b', 'tree2/c'])
+ tree1.add(['a', 'c'], ['a-id', 'c-id'])
+ tree2.add(['a', 'c'], ['a-id', 'c-id'])
+
+ tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
+ tree1.lock_read()
+ self.addCleanup(tree1.unlock)
+ tree2.lock_read()
+ self.addCleanup(tree2.unlock)
+
+ # We should ignore the fact that 'b' exists in tree-2
+ expected = sorted([
+ self.content_changed(tree2, 'a-id'),
+ self.content_changed(tree2, 'c-id'),
+ ])
+ self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
=== modified file 'bzrlib/tests/test_bad_files.py'
--- a/bzrlib/tests/test_bad_files.py 2006-10-11 23:08:27 +0000
+++ b/bzrlib/tests/test_bad_files.py 2007-02-28 22:40:54 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005 Canonical Ltd
+# Copyright (C) 2005, 2007 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -15,54 +15,49 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-"""Tests being able to ignore mad filetypes.
-"""
-
+"""Tests being able to ignore bad filetypes."""
+
+from cStringIO import StringIO
+import os
+
+from bzrlib import (
+ add,
+ errors,
+ )
+from bzrlib.status import show_tree_status
from bzrlib.tests import TestCaseWithTransport
-from bzrlib.errors import BadFileKindError
-import os
+
def verify_status(tester, tree, value):
- from bzrlib.status import show_tree_status
- from cStringIO import StringIO
-
+ """Verify the output of show_tree_status"""
tof = StringIO()
show_tree_status(tree, to_file=tof)
tof.seek(0)
- tester.assertEquals(tof.readlines(), value)
+ tester.assertEqual(value, tof.readlines())
class TestBadFiles(TestCaseWithTransport):
-
+
def test_bad_files(self):
"""Test that bzr will ignore files it doesn't like"""
- from bzrlib.add import smart_add_tree
- from bzrlib.branch import Branch
+ if getattr(os, 'mkfifo', None) is None:
+ # TODO: Ultimately this should be TestSkipped
+ # or PlatformDeficiency
+ return
wt = self.make_branch_and_tree('.')
b = wt.branch
files = ['one', 'two', 'three']
+ file_ids = ['one-id', 'two-id', 'three-id']
self.build_tree(files)
- wt.add(files)
+ wt.add(files, file_ids)
wt.commit("Commit one", rev_id="a at u-0-0")
- self.build_tree(['four'])
- wt.add(['four'])
- wt.commit("Commit two", rev_id="a at u-0-1")
- self.build_tree(['five'])
- wt.add(['five'])
- wt.commit("Commit three", rev_id="a at u-0-2")
# We should now have a few files, lets try to
# put some bogus stuff in the tree
- # We can only continue if we have mkfifo
- if getattr(os, 'mkfifo', None) is None:
- # TODO: Ultimately this should be TestSkipped
- # or PlatformDeficiency
- return
-
- # status with nothing
+ # status with nothing changed
verify_status(self, wt, [])
os.mkfifo('a-fifo')
@@ -73,10 +68,21 @@
' a-fifo\n',
' six\n'
])
-
+
+ # We should raise an error if we are adding a bogus file
+ self.assertRaises(errors.BadFileKindError,
+ add.smart_add_tree, wt, ['a-fifo'])
+
+ # And the list of files shouldn't have been modified
+ verify_status(self, wt,
+ ['unknown:\n',
+ ' a-fifo\n',
+ ' six\n'
+ ])
+
# Make sure smart_add can handle having a bogus
# file in the way
- smart_add_tree(wt, '.')
+ add.smart_add_tree(wt, ['.'])
verify_status(self, wt,
['added:\n',
' six\n',
@@ -89,8 +95,3 @@
['unknown:\n',
' a-fifo\n',
])
-
- # We should raise an error if we are adding a bogus file
- # Is there a way to test the actual error that should be raised?
- self.run_bzr('add', 'a-fifo', retcode=3)
-
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2007-02-28 20:39:36 +0000
+++ b/bzrlib/workingtree_4.py 2007-02-28 22:40:54 +0000
@@ -1813,7 +1813,12 @@
new_executable = bool(
stat.S_ISREG(current_path_info[3].st_mode)
and stat.S_IEXEC & current_path_info[3].st_mode)
- yield (None, current_path_info[0], True, (False, False), (None, None), (None, current_path_info[1]), (None, current_path_info[2]), (None, new_executable))
+ yield (None, current_path_info[0], True,
+ (False, False),
+ (None, None),
+ (None, current_path_info[1]),
+ (None, current_path_info[2]),
+ (None, new_executable))
elif current_path_info is None:
# no path is fine: the per entry code will handle it.
for result in _process_entry(current_entry, current_path_info):
@@ -1831,9 +1836,11 @@
yield result
elif current_entry[0][1] != current_path_info[1]:
if current_path_info[1] < current_entry[0][1]:
- # extra file on disk: pass for now
- import pdb;pdb.set_trace()
- print 'unversioned file'
+ # extra file on disk: pass for now, but only
+ # increment the path, not the entry
+ # import pdb; pdb.set_trace()
+ # print 'unversioned file'
+ advance_entry = False
else:
# entry referring to file not present on disk.
# advance the entry only, after processing.
More information about the bazaar-commits
mailing list