changeset 106808:390461140f6c

* files.el (copy-directory): Compute target for recursive directories with identical names. (Bug#5343)
author Michael Albinus <michael.albinus@gmx.de>
date Tue, 12 Jan 2010 22:59:05 +0100
parents 8f9c3a09d55a
children 5cb0f4fd512e a30f962075db
files lisp/ChangeLog lisp/files.el
diffstat 2 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Jan 12 11:25:08 2010 -0500
+++ b/lisp/ChangeLog	Tue Jan 12 22:59:05 2010 +0100
@@ -1,3 +1,8 @@
+2010-01-12  Michael Albinus  <michael.albinus@gmx.de>
+
+	* files.el (copy-directory): Compute target for recursive
+	directories with identical names.  (Bug#5343)
+
 2010-01-12  Glenn Morris  <rgm@gnu.org>
 
 	* mail/emacsbug.el (report-emacs-bug-pretest-address): Set
--- a/lisp/files.el	Tue Jan 12 11:25:08 2010 -0500
+++ b/lisp/files.el	Tue Jan 12 22:59:05 2010 +0100
@@ -4714,20 +4714,17 @@
       ;; Compute target name.
       (setq directory (directory-file-name (expand-file-name directory))
 	    newname   (directory-file-name (expand-file-name newname)))
-      (if (and (file-directory-p newname)
-	       (not (string-equal (file-name-nondirectory directory)
-				  (file-name-nondirectory newname))))
-	  (setq newname
-		(expand-file-name (file-name-nondirectory directory) newname)))
       (if (not (file-directory-p newname)) (make-directory newname parents))
 
       ;; Copy recursively.
       (mapc
        (lambda (file)
-	 (if (file-directory-p file)
-	     (copy-directory file newname keep-time parents)
-	   (copy-file file newname t keep-time)))
-       ;; We do not want to delete "." and "..".
+	 (let ((target (expand-file-name
+			(file-name-nondirectory file) newname)))
+	   (if (file-directory-p file)
+	       (copy-directory file target keep-time parents)
+	     (copy-file file target t keep-time))))
+       ;; We do not want to copy "." and "..".
        (directory-files	directory 'full directory-files-no-dot-files-regexp))
 
       ;; Set directory attributes.