Index: subversion/tests/cmdline/merge_tests.py
===================================================================
--- subversion/tests/cmdline/merge_tests.py	(revision 1297725)
+++ subversion/tests/cmdline/merge_tests.py	(working copy)
@@ -17467,6 +17467,64 @@
                                      'merge', sbox.repo_url + '/A',
                                      A_COPY_path)
 
+@XFail()
+@Issue(4139)
+def merge_dir_file_same_name(sbox):
+  "merged directory has file with same name"
+  sbox.build()
+  wc_dir = sbox.wc_dir
+
+  # Paths of interest in first WC
+  A_B_B_path = os.path.join(wc_dir, 'A', 'B', 'B')
+
+  # Create file 'B' in path '/A/B' - revision 2
+  svntest.main.file_write(A_B_B_path, "Project B now has file B")
+  svntest.main.run_svn(None, 'add', A_B_B_path)
+  expected_output = svntest.wc.State(wc_dir, {
+    'A/B/B' : Item(verb='Adding'),
+    })
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+  expected_status.add({
+    'A/B/B' : Item(status='  ', wc_rev=2),
+    })
+  svntest.actions.run_and_verify_commit(wc_dir, expected_output,
+                                        expected_status, None,
+                                        wc_dir)
+
+  # Copy '/A' to '/A_COPY' - revision 3
+  sbox.simple_repo_copy('A', 'A_COPY')
+
+  # Now modify '/A/B/B' - revision 4
+  svntest.main.file_write(A_B_B_path, "File B is now modified")
+  expected_output = svntest.wc.State(wc_dir, {
+    'A/B/B' : Item(verb='Sending'),
+    })
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+  expected_status.add({
+    'A/B/B' : Item(status='  ', wc_rev=4),
+    })
+  svntest.actions.run_and_verify_commit(wc_dir, expected_output,
+                                        expected_status, None,
+                                        wc_dir)
+
+  # Now check out A_COPY/B in a separate WC
+  wc_copy = sbox.add_wc_path('copy')
+  svntest.actions.run_and_verify_svn(None, None, [], 'checkout',
+		  sbox.repo_url + '/A_COPY/B', wc_copy)
+
+  # And try to merge the change from revision 4 of /A/B/B to
+  # /A_COPY/B/B from the WC dir.
+  saved_cwd = os.getcwd()
+  os.chdir(wc_copy)
+  expected_output = expected_merge_output([[4]],
+                           ['U    B\n',
+                            ' U   \.',])
+  svntest.actions.run_and_verify_svn(None, expected_output, [],
+                                     'merge', '-c', '4',
+                                     sbox.repo_url + '/A/B')
+  os.chdir(saved_cwd)
+
+
 ########################################################################
 # Run the tests
 
@@ -17599,6 +17657,7 @@
               unnecessary_noninheritable_mergeinfo_shallow_merge,
               svnmucc_abuse_1,
               merge_source_with_replacement,
+              merge_dir_file_same_name,
              ]
 
 if __name__ == '__main__':

