Rev 3506: Add more tests of working tree specific functionality for get_fingerprint in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/get_fingerprint
John Arbash Meinel
john at arbash-meinel.com
Mon Jun 23 23:32:07 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/get_fingerprint
------------------------------------------------------------
revno: 3506
revision-id: john at arbash-meinel.com-20080623223154-893fwsaa1bjllugi
parent: john at arbash-meinel.com-20080623220633-h3k0e8q0i4lsc5fn
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: get_fingerprint
timestamp: Mon 2008-06-23 17:31:54 -0500
message:
Add more tests of working tree specific functionality for get_fingerprint
-------------- next part --------------
=== modified file 'bzrlib/tests/tree_implementations/test_get_fingerprint.py'
--- a/bzrlib/tests/tree_implementations/test_get_fingerprint.py 2008-06-23 22:06:33 +0000
+++ b/bzrlib/tests/tree_implementations/test_get_fingerprint.py 2008-06-23 22:31:54 +0000
@@ -16,6 +16,9 @@
"""Test that all Tree's implement .get_fingerprint()"""
+import os
+
+from bzrlib import tests
from bzrlib.tests.tree_implementations import TestCaseWithTree
@@ -46,7 +49,7 @@
self.assertGetFingerprint('directory', 'second-rev-id', None,
tree, 'dir2-id')
- def test_file_kind(self):
+ def test_file(self):
wt = self.make_branch_and_tree('tree')
self.build_tree(['tree/file'])
wt.add(['file'], ['file-id'])
@@ -71,3 +74,21 @@
tree.lock_read()
self.addCleanup(tree.unlock)
self.assertGetFingerprint(None, None, None, tree, 'no-such-file-id')
+
+ def test_symlink(self):
+ self.requireFeature(tests.SymlinkFeature)
+ wt = self.make_branch_and_tree('tree')
+ os.symlink('tree/link', 'some_target')
+ wt.add(['link'], ['link-id'])
+ wt.commit('link', rev_id='first-rev-id')
+ os.symlink('tree/link2', 'other_target')
+ wt.add(['link2'], ['link2-id'])
+ wt.commit('link2', rev_id='second-rev-id')
+
+ tree = self._convert_tree(wt)
+ tree.lock_read()
+ self.addCleanup(tree.unlock)
+ self.assertGetFingerprint('file', 'first-rev-id', 'some_target',
+ tree, 'file-id')
+ self.assertGetFingerprint('file', 'second-rev-id', 'other_target',
+ tree, 'file2-id')
=== modified file 'bzrlib/tests/workingtree_implementations/test_get_fingerprint.py'
--- a/bzrlib/tests/workingtree_implementations/test_get_fingerprint.py 2008-06-23 22:06:33 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_get_fingerprint.py 2008-06-23 22:31:54 +0000
@@ -16,8 +16,9 @@
"""Test that all WorkingTree's implement .get_fingerprint()"""
+from bzrlib.revision import CURRENT_REVISION
+from bzrlib import tests
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
-from bzrlib.revision import CURRENT_REVISION
class TestGetFingerprint(TestCaseWithWorkingTree):
@@ -31,3 +32,94 @@
self.assertEqual(exp_modified, modified)
self.assertEqual(exp_info, info)
+ def test_no_commits(self):
+ wt = self.make_branch_and_tree('tree')
+ self.build_tree(['tree/file'])
+ wt.add(['file'], ['file-id'])
+
+ wt.lock_read()
+ self.addCleanup(wt.unlock)
+ self.assertGetFingerprint('file', CURRENT_REVISION,
+ 'fdd68fdc095181052aaa4f74fdb2db4a2ce6eb9f',
+ wt, 'file-id')
+ self.assertGetFingerprint(None, None, None, wt, 'no-such-file-id')
+
+ def test_modified_since_commit(self):
+ wt = self.make_branch_and_tree('tree')
+ self.build_tree(['tree/file'])
+ wt.add(['file'], ['file-id'])
+ wt.commit('file', rev_id='first-rev-id')
+ # XXX: Ideally, we would do this such that the file could have hit the
+ # cache before it was modified
+
+ wt.lock_read()
+ self.addCleanup(wt.unlock)
+ self.assertGetFingerprint('file', 'first-rev-id',
+ 'fdd68fdc095181052aaa4f74fdb2db4a2ce6eb9f',
+ wt, 'file-id')
+ self.build_tree_contents([('tree/file', 'new contents\n')])
+ self.assertGetFingerprint('file', CURRENT_REVISION,
+ 'be9f309239729f69a6309e970ef24941d31e042c',
+ wt, 'file-id')
+
+ def test_renamed_since_commit(self):
+ wt = self.make_branch_and_tree('tree')
+ self.build_tree(['tree/file'])
+ wt.add(['file'], ['file-id'])
+ wt.commit('file', rev_id='first-rev-id')
+ # XXX: Ideally, we would do this such that the file could have hit the
+ # cache before it was modified
+
+ wt.rename_one('file', 'other_file')
+ wt.lock_read()
+ self.addCleanup(wt.unlock)
+ self.assertGetFingerprint('file', CURRENT_REVISION,
+ 'fdd68fdc095181052aaa4f74fdb2db4a2ce6eb9f',
+ wt, 'file-id')
+
+ def test_parent_dir_renamed(self):
+ wt = self.make_branch_and_tree('tree')
+ self.build_tree(['tree/dir/', 'tree/dir/file'])
+ wt.add(['dir', 'dir/file'], ['dir-id', 'file-id'])
+ wt.commit('dir/file', rev_id='first-rev-id')
+
+ wt.rename_one('dir', 'alt')
+ wt.lock_read()
+ self.addCleanup(wt.unlock)
+ self.assertGetFingerprint('directory', CURRENT_REVISION, None,
+ wt, 'dir-id')
+ self.assertGetFingerprint('file', 'first-rev-id',
+ '787bfeabafbfc8a068e466cbbcfbe5de1233bddb',
+ wt, 'file-id')
+
+ def test_changed_directories(self):
+ wt = self.make_branch_and_tree('tree')
+ self.build_tree(['tree/dir/', 'tree/dir/file', 'tree/dir2/'])
+ wt.add(['dir', 'dir/file', 'dir2'], ['dir-id', 'file-id', 'dir2-id'])
+ wt.commit('dir/file, dir2', rev_id='first-rev-id')
+
+ wt.rename_one('dir/file', 'dir2/file')
+ wt.lock_read()
+ self.addCleanup(wt.unlock)
+ self.assertGetFingerprint('directory', 'first-rev-id', None,
+ wt, 'dir-id')
+ self.assertGetFingerprint('file', CURRENT_REVISION,
+ '787bfeabafbfc8a068e466cbbcfbe5de1233bddb',
+ wt, 'file-id')
+
+ def test_symlink(self):
+ self.requireFeature(tests.SymlinkFeature)
+ wt = self.make_branch_and_tree('tree')
+ os.symlink('tree/link', 'some_target')
+ wt.add(['link'], ['link-id'])
+ wt.commit('link', rev_id='first-rev-id')
+
+ wt.lock_read()
+ self.addCleanup(wt.unlock)
+ self.assertGetFingerprint('symlink', 'first-rev-id', 'some_target',
+ wt, 'file-id')
+
+ os.remove('tree/link')
+ os.symlink('tree/link', 'other_target')
+ self.assertGetFingerprint('symlink', CURRENT_REVISION, 'other_target',
+ wt, 'file-id')
=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py 2008-06-23 22:06:33 +0000
+++ b/bzrlib/workingtree.py 2008-06-23 22:31:54 +0000
@@ -617,8 +617,10 @@
# This didn't exist in the base, so it gets marked current
is_modified = True
else:
- basis_relpath = basis_tree.id2path(file_id)
- if basis_ie.kind != kind or basis_relpath != path:
+ # basis_relpath = basis_tree.id2path(file_id)
+ dirname, basename = osutils.split(path)
+ if (basis_ie.kind != kind or basis_ie.name != basename
+ or self.path2id(dirname) != basis_ie.parent_id):
is_modified = True
else:
if kind == 'file':
More information about the bazaar-commits
mailing list