Rev 2407: Fix bug #103870 by passing None instead of a (sometimes wrong) path in http://bzr.arbash-meinel.com/branches/bzr/0.16-dev/diff_renamed_103870
John Arbash Meinel
john at arbash-meinel.com
Wed Apr 11 23:02:31 BST 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.16-dev/diff_renamed_103870
------------------------------------------------------------
revno: 2407
revision-id: john at arbash-meinel.com-20070411220215-o07i1rcajpghkpom
parent: john at arbash-meinel.com-20070411215736-rii53nkqb42hezup
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: diff_renamed_103870
timestamp: Wed 2007-04-11 17:02:15 -0500
message:
Fix bug #103870 by passing None instead of a (sometimes wrong) path
modified:
bzrlib/diff.py diff.py-20050309040759-26944fbbf2ebbf36
bzrlib/tests/test_diff.py testdiff.py-20050727164403-d1a3496ebb12e339
-------------- next part --------------
=== modified file 'bzrlib/diff.py'
--- a/bzrlib/diff.py 2007-03-13 02:16:17 +0000
+++ b/bzrlib/diff.py 2007-04-11 22:02:15 +0000
@@ -471,8 +471,11 @@
has_changes = 1
prop_str = get_prop_change(meta_modified)
print >>to_file, '=== modified %s %r%s' % (kind, path.encode('utf8'), prop_str)
+ # The path may not be correct in the case that the containing directory
+ # was renamed. So don't pass it to _patch_header_date, which passes it
+ # to tree.get_file_mtime()
old_name = '%s%s\t%s' % (old_label, path,
- _patch_header_date(old_tree, file_id, path))
+ _patch_header_date(old_tree, file_id, None))
new_name = '%s%s\t%s' % (new_label, path,
_patch_header_date(new_tree, file_id, path))
if text_modified:
@@ -485,7 +488,11 @@
def _patch_header_date(tree, file_id, path):
"""Returns a timestamp suitable for use in a patch header."""
- return timestamp.format_patch_date(tree.get_file_mtime(file_id, path))
+ mtime = tree.get_file_mtime(file_id, path)
+ assert mtime is not None, \
+ "got an mtime of None for file-id %s, path %s in tree %s" % (
+ file_id, path, tree)
+ return timestamp.format_patch_date(mtime)
def _raise_if_nonexistent(paths, old_tree, new_tree):
=== modified file 'bzrlib/tests/test_diff.py'
--- a/bzrlib/tests/test_diff.py 2007-04-11 21:57:36 +0000
+++ b/bzrlib/tests/test_diff.py 2007-04-11 22:02:15 +0000
@@ -377,6 +377,26 @@
self.assertContainsRe(diff, '-contents\n'
'\\+new contents\n')
+ def test_modified_file_in_renamed_dir(self):
+ """Test when a file is modified in a renamed directory."""
+ tree = self.make_branch_and_tree('tree')
+ self.build_tree(['tree/dir/'])
+ self.build_tree_contents([('tree/dir/file', 'contents\n')])
+ tree.add(['dir', 'dir/file'], ['dir-id', 'file-id'])
+ tree.commit('one', rev_id='rev-1')
+
+ tree.rename_one('dir', 'other')
+ self.build_tree_contents([('tree/other/file', 'new contents\n')])
+ diff = self.get_diff(tree.basis_tree(), tree)
+ self.assertContainsRe(diff, "=== renamed directory 'dir' => 'other'\n")
+ self.assertContainsRe(diff, "=== modified file 'other/file'\n")
+ # XXX: This is technically incorrect, because it used to be at another
+ # location. What to do?
+ self.assertContainsRe(diff, '--- old/other/file\t')
+ self.assertContainsRe(diff, '\\+\\+\\+ new/other/file\t')
+ self.assertContainsRe(diff, '-contents\n'
+ '\\+new contents\n')
+
def test_renamed_directory(self):
"""Test when only a directory is only renamed."""
tree = self.make_branch_and_tree('tree')
More information about the bazaar-commits
mailing list