Rev 2410: Test InterTree._iter_changes with missing (absent but versioned) files. in sftp://bazaar.launchpad.net/%7Ebzr/bzr/dirstate/
Robert Collins
robertc at robertcollins.net
Mon Feb 26 04:29:06 GMT 2007
At sftp://bazaar.launchpad.net/%7Ebzr/bzr/dirstate/
------------------------------------------------------------
revno: 2410
revision-id: robertc at robertcollins.net-20070226042755-e21ce5f15vz94wyr
parent: robertc at robertcollins.net-20070226035330-h52h54murds6wmpi
committer: Robert Collins <robertc at robertcollins.net>
branch nick: dirstate
timestamp: Mon 2007-02-26 15:27:55 +1100
message:
Test InterTree._iter_changes with missing (absent but versioned) files.
modified:
bzrlib/tests/intertree_implementations/test_compare.py test_compare.py-20060724101752-09ysswo1a92uqyoz-2
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
=== modified file 'bzrlib/tests/intertree_implementations/test_compare.py'
--- a/bzrlib/tests/intertree_implementations/test_compare.py 2007-02-26 03:53:30 +0000
+++ b/bzrlib/tests/intertree_implementations/test_compare.py 2007-02-26 04:27:55 +0000
@@ -17,6 +17,7 @@
"""Tests for the InterTree.compare() function."""
import os
+import shutil
from bzrlib import errors
from bzrlib.osutils import file_kind
@@ -337,6 +338,11 @@
(old_entry.name, new_entry.name), (old_entry.kind, new_entry.kind),
(old_entry.executable, new_entry.executable))
+ def missing(self, file_id, path, parent_id, kind):
+ _, basename = os.path.split(path)
+ return (file_id, path, True, (True, True), (parent_id, parent_id),
+ (basename, basename), (kind, None), (False, False))
+
def deleted(self, tree, file_id):
entry = tree.inventory[file_id]
path = tree.id2path(file_id)
@@ -505,6 +511,25 @@
(False, True))],
self.do_iter_changes(tree1, tree2))
+ def test_missing_in_target(self):
+ """Test with the target files versioned but absent from disk."""
+ tree1 = self.make_branch_and_tree('1')
+ tree2 = self.make_to_branch_and_tree('2')
+ tree1 = self.get_tree_no_parents_abc_content(tree1)
+ tree2 = self.get_tree_no_parents_abc_content(tree2)
+ os.unlink('2/a')
+ shutil.rmtree('2/b')
+ # TODO ? have a symlink here?
+ tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2)
+ root_id = tree1.path2id('')
+ expected = sorted([
+ self.missing('a-id', 'a', root_id, 'file'),
+ self.missing('b-id', 'b', root_id, 'directory'),
+ self.missing('c-id', 'b/c', 'b-id', 'file'),
+ ])
+ self.assertEqual(expected, self.do_iter_changes(tree1, tree2))
+
+
def test_unchanged_with_renames_and_modifications(self):
"""want_unchanged should generate a list of unchanged entries."""
tree1 = self.make_branch_and_tree('1')
@@ -518,9 +543,9 @@
tree2.lock_read()
self.addCleanup(tree2.unlock)
self.assertEqual(sorted([self.unchanged(tree1, root_id),
- unchanged(tree1, 'b-id'), ('a-id', 'd', True, (True, True),
+ self.unchanged(tree1, 'b-id'), ('a-id', 'd', True, (True, True),
(root_id, root_id), ('a', 'd'), ('file', 'file'),
- (False, False)), unchanged(tree1, 'c-id')]),
+ (False, False)), self.unchanged(tree1, 'c-id')]),
self.do_iter_changes(tree1, tree2, include_unchanged=True))
def _todo_test_unversioned_paths_in_tree(self):
=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py 2007-02-26 01:06:36 +0000
+++ b/bzrlib/workingtree.py 2007-02-26 04:27:55 +0000
@@ -2506,9 +2506,9 @@
return self.get_format_string()
-__default_format = WorkingTreeFormat3()
+__default_format = WorkingTreeFormat4()
WorkingTreeFormat.register_format(__default_format)
-WorkingTreeFormat.register_format(WorkingTreeFormat4())
+WorkingTreeFormat.register_format(WorkingTreeFormat3())
WorkingTreeFormat.set_default_format(__default_format)
# formats which have no format string are not discoverable
# and not independently creatable, so are not registered.
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2007-02-26 03:53:30 +0000
+++ b/bzrlib/workingtree_4.py 2007-02-26 04:27:55 +0000
@@ -1556,18 +1556,20 @@
old_dirname, old_basename = entry[0][0:2]
if path_info is None:
# the file is missing on disk, show as removed.
- print "missing file"
old_path = os.path.join(*entry[0][0:2])
- result.removed.append((old_path, entry[0][2], dirstate.DirState._minikind_to_kind[source_details[0]]))
- # use the kind from disk.
+ content_change = True
+ target_kind = None
+ target_exec = False
else:
# source and target are both versioned and disk file is present.
+ target_kind = path_info[2]
if path_info[2][0] == 'd':
if source_details[0][0] != 'd':
content_change = True
else:
# directories have no fingerprint
content_change = False
+ target_exec = False
elif path_info[2][0] == 'f':
if source_details[0][0] != 'f':
content_change = True
@@ -1579,6 +1581,9 @@
# maybe the same. Get the hash
new_hash = self.target._hashcache.get_sha1(path, path_info[3])
content_change = (new_hash != source_details[1])
+ target_exec = bool(
+ stat.S_ISREG(path_info[3].st_mode)
+ and stat.S_IEXEC & path_info[3].st_mode)
elif path_info[2][0] == 's':
if source_details[0][0] != 'l':
content_change = True
@@ -1589,25 +1594,22 @@
target_exec = False
else:
raise Exception, "unknown kind %s" % path_info[2]
- # parent id is the entry for the path in the target tree
- # TODO: the target is the same for an entire directory: cache em.
- source_parent_id = state._get_entry(source_index, path_utf8=old_dirname)[0][2]
- if source_parent_id == entry[0][2]:
- source_parent_id = None
- target_parent_id = state._get_entry(target_index, path_utf8=entry[0][0])[0][2]
- if target_parent_id == entry[0][2]:
- target_parent_id = None
- source_exec = source_details[3]
- target_exec = bool(
- stat.S_ISREG(path_info[3].st_mode)
- and stat.S_IEXEC & path_info[3].st_mode)
- path_unicode = path.decode('utf8')
- return ((entry[0][2], path_unicode, content_change,
- (True, True),
- (source_parent_id, target_parent_id),
- (old_basename, entry[0][1]),
- (dirstate.DirState._minikind_to_kind[source_details[0]], path_info[2]),
- (source_exec, target_exec)),)
+ # parent id is the entry for the path in the target tree
+ # TODO: the target is the same for an entire directory: cache em.
+ source_parent_id = state._get_entry(source_index, path_utf8=old_dirname)[0][2]
+ if source_parent_id == entry[0][2]:
+ source_parent_id = None
+ target_parent_id = state._get_entry(target_index, path_utf8=entry[0][0])[0][2]
+ if target_parent_id == entry[0][2]:
+ target_parent_id = None
+ source_exec = source_details[3]
+ path_unicode = path.decode('utf8')
+ return ((entry[0][2], path_unicode, content_change,
+ (True, True),
+ (source_parent_id, target_parent_id),
+ (old_basename, entry[0][1]),
+ (dirstate.DirState._minikind_to_kind[source_details[0]], target_kind),
+ (source_exec, target_exec)),)
elif source_details[0] in 'a' and target_details[0] in 'fdl':
# looks like a new file
if path_info is not None:
More information about the bazaar-commits
mailing list