And here's the patch.
Blair
* subversion/libsvn_wc/adm_ops.c:
Resolve issue #976. When copying a file, do not determine
svn:executable and svn:mime-type settings as though the file is
brand new, instead use the copied file's property values.
* subversion/tests/clients/cmdline/prop_tests.py
(cp_binary_file_shouldnt_reset_mime_type): New regression test for
issue #976.
Index: subversion/libsvn_wc/adm_ops.c
===================================================================
--- subversion/libsvn_wc/adm_ops.c (revision 3705)
+++ subversion/libsvn_wc/adm_ops.c (working copy)
@@ -856,28 +856,34 @@
if (kind == svn_node_file)
{
- /* Try to detect the mime-type of this new addition. */
- SVN_ERR (svn_io_detect_mimetype (&mimetype, path, pool));
- if (mimetype)
+ /* If this is a new addition, then try to detect the mime-type
+ of this file and set svn:executable if the file is
+ executable. Otherwise, use the values in the original
+ file. */
+ if (! copyfrom_url)
{
- svn_string_t mt_str;
- mt_str.data = mimetype;
- mt_str.len = strlen(mimetype);
- SVN_ERR (svn_wc_prop_set (SVN_PROP_MIME_TYPE, &mt_str, path,
- parent_access, pool));
- }
+ SVN_ERR (svn_io_detect_mimetype (&mimetype, path, pool));
+ if (mimetype)
+ {
+ svn_string_t mt_str;
+ mt_str.data = mimetype;
+ mt_str.len = strlen(mimetype);
+ SVN_ERR (svn_wc_prop_set (SVN_PROP_MIME_TYPE, &mt_str, path,
+ parent_access, pool));
+ }
- /* Set svn:executable if the new addition is executable. */
- SVN_ERR (svn_io_is_file_executable (&executable, path, pool));
- if (executable)
- {
- svn_string_t emptystr;
- emptystr.data = "";
- emptystr.len = 0;
- SVN_ERR (svn_wc_prop_set (SVN_PROP_EXECUTABLE, &emptystr, path,
- parent_access, pool));
+ /* Set svn:executable if the new addition is executable. */
+ SVN_ERR (svn_io_is_file_executable (&executable, path, pool));
+ if (executable)
+ {
+ svn_string_t emptystr;
+ emptystr.data = "";
+ emptystr.len = 0;
+ SVN_ERR (svn_wc_prop_set (SVN_PROP_EXECUTABLE, &emptystr, path,
+ parent_access, pool));
+ }
}
- }
+ }
else /* scheduling a directory for addition */
{
if (! copyfrom_url)
Index: subversion/tests/clients/cmdline/prop_tests.py
===================================================================
--- subversion/tests/clients/cmdline/prop_tests.py (revision 3705)
+++ subversion/tests/clients/cmdline/prop_tests.py (working copy)
@@ -591,6 +591,68 @@
return 1
+#----------------------------------------------------------------------
+
+# Issue #976. Copying a file deemded to be binary, i.e. svn would add
+# an svn:mime-type of application/octet-stream if the file were added,
+# will upon a copy have its svm:mime-type reset.
+
+def cp_binary_file_shouldnt_reset_mime_type(sbox):
+ "copying a binary file should not reset svn:mime-type"
+
+ # Bootstrap
+ if sbox.build():
+ return 1
+
+ wc_dir = sbox.wc_dir
+
+ orig_mime_type = 'image/fake_image'
+
+ # Create two paths
+ new_path1 = os.path.join(wc_dir, 'new_file1.bin')
+ new_path2 = os.path.join(wc_dir, 'new_file2.bin')
+
+ # Create the first path as a binary file
+ svntest.main.file_append(new_path1, "binary file\000\001\002\003")
+ svntest.main.run_svn(None, 'add', new_path1)
+
+ # Add initial svn:mime-type to the file
+ svntest.main.run_svn(None, 'propset', 'svn:mime-type', orig_mime_type,
+ new_path1)
+
+ # Commit the file
+ svntest.main.run_svn(None, 'ci', '-m', 'create file and set svn:mime-type',
+ wc_dir)
+
+ # Copy the file
+ svntest.main.run_svn(None, 'cp', new_path1, new_path2)
+
+ # Create expected output tree
+ expected_output = svntest.wc.State(wc_dir, {
+ 'new_file2.bin' : Item(verb='Adding (bin)'),
+ })
+
+ # Create expected disk tree
+ expected_disk = svntest.main.greek_state.copy()
+ expected_disk.add({'new_file2.bin' : Item()})
+# expected_disk.tweak('new_file2.bin',
+# props={'svn:mime-type' : orig_mime_type})
+
+ # Create expected status tree
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
+ expected_status.tweak(repos_rev=3)
+ expected_status.add({'new_file2.bin' : Item(wc_rev=5, status=' ')})
+
+ # Commit the copy
+ return svntest.main.actions.run_and_verify_commit(wc_dir,
+ expected_output,
+ expected_disk,
+ expected_status,
+ None, None,
+ None, None,
+ wc_dir)
+
+
########################################################################
# Run the tests
@@ -606,6 +668,7 @@
commit_replacement_props,
revert_replacement_props,
inappropriate_props,
+ cp_binary_file_shouldnt_reset_mime_type,
]
if __name__ == '__main__':
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Nov 9 04:06:57 2002