Commits

Anonymous committed f394ce2

* ediff-ptch.el (ediff-file-name-sans-prefix): treat nil as an empty
string.
(ediff-fixup-patch-map): better heuristic for intuiting the file names
to patch.
(ediff-prompt-for-patch-file): more intuitive prompt.

* ediff-util.el: use insert-buffer-substring.

* ediff-vers.el (cvs-run-ediff-on-file-descriptor): bug fix.

  • Participants
  • Parent commits 870d9ce

Comments (0)

Files changed (13)

+2005-09-20  Michael Kifer  <kifer@cs.stonybrook.edu>
+	
+	* ediff-ptch.el (ediff-file-name-sans-prefix): treat nil as an empty
+	string.
+	(ediff-fixup-patch-map): better heuristic for intuiting the file names
+	to patch.
+	(ediff-prompt-for-patch-file): more intuitive prompt.
+	
+	* ediff-util.el: use insert-buffer-substring.
+	
+	* ediff-vers.el (cvs-run-ediff-on-file-descriptor): bug fix.
+	
 2005-07-19  Norbert Koch  <viteno@xemacs.org>
 
 	* Makefile (VERSION): XEmacs package 1.54 released.
-
+	
 2005-07-19  Michael Kifer  <kifer@cs.stonybrook.edu>
 	
 	* ediff.el (ediff-patch-buffer): changed the docstring.

File ediff-diff.el

 ;;; ediff-diff.el --- diff-related utilities
 
-;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+;;   2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 

File ediff-help.el

 ;;; ediff-help.el --- Code related to the contents of Ediff help buffers
 
-;; Copyright (C) 1996, 97, 98, 99, 2000, 01, 02 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+;;   2004, 2005 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 

File ediff-hook.el

 ;;; ediff-hook.el --- setup for Ediff's menus and autoloads
 
-;; Copyright (C) 1995, 96, 97, 98, 99, 2000, 01, 02 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+;;   2004, 2005 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 

File ediff-init.el

 ;;; ediff-init.el --- Macros, variables, and defsubsts used by Ediff
 
 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-;;     2004, 2005 Free Software Foundation, Inc.
+;;     2003, 2004, 2005 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 
 
 
 ;; Highlighting
-(defcustom ediff-before-flag-bol (if ediff-xemacs-p (make-glyph "->>") "->>")
+(defcustom ediff-before-flag-bol (if (featurep 'xemacs) (make-glyph "->>") "->>")
   "*Flag placed before a highlighted block of differences, if block starts at beginning of a line."
   :type 'string
   :tag  "Region before-flag at beginning of line"
   :group 'ediff)
 
-(defcustom ediff-after-flag-eol  (if ediff-xemacs-p (make-glyph "<<-") "<<-")
+(defcustom ediff-after-flag-eol  (if (featurep 'xemacs) (make-glyph "<<-") "<<-")
   "*Flag placed after a highlighted block of differences, if block ends at end of a line."
   :type 'string
   :tag  "Region after-flag at end of line"
   :group 'ediff)
 
-(defcustom ediff-before-flag-mol (if ediff-xemacs-p (make-glyph "->>") "->>")
+(defcustom ediff-before-flag-mol (if (featurep 'xemacs) (make-glyph "->>") "->>")
   "*Flag placed before a highlighted block of differences, if block starts in mid-line."
   :type 'string
   :tag  "Region before-flag in the middle of line"
   :group 'ediff)
-(defcustom ediff-after-flag-mol  (if ediff-xemacs-p (make-glyph "<<-") "<<-")
+(defcustom ediff-after-flag-mol  (if (featurep 'xemacs) (make-glyph "<<-") "<<-")
   "*Flag placed after a highlighted block of differences, if block ends in mid-line."
   :type 'string
   :tag  "Region after-flag in the middle of line"
   :group 'ediff)
 
 ;; needed to simulate frame-char-width in XEmacs.
-(defvar ediff-H-glyph (if ediff-xemacs-p (make-glyph "H")))
+(defvar ediff-H-glyph (if (featurep 'xemacs) (make-glyph "H")))
 
 
 ;; Temporary file used for refining difference regions in buffer A.

File ediff-merg.el

 ;;; ediff-merg.el --- merging utilities
 
-;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+;;   2003, 2004, 2005 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 

File ediff-mult.el

 ;;; ediff-mult.el --- support for multi-file/multi-buffer processing in Ediff
 
-;; Copyright (C) 1995, 96, 97, 98, 99, 2000, 01, 02, 05 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+;;   2003, 2004, 2005 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 

File ediff-ptch.el

 ;;; ediff-ptch.el --- Ediff's  patch support
 
-;; Copyright (C) 1996, 97, 98, 99, 2000, 01, 02 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+;;   2003, 2004, 2005 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 
 ;; strip prefix from filename
 ;; returns /dev/null, if can't strip prefix
 (defsubst ediff-file-name-sans-prefix (filename prefix)
-  (save-match-data
-    (if (string-match (concat "^" (regexp-quote prefix)) filename)
-	(substring filename (match-end 0))
-      (concat "/null/" filename))))
+  (if prefix
+      (save-match-data
+	(if (string-match (concat "^" (if (stringp prefix)
+					  (regexp-quote prefix)
+					""))
+			  filename)
+	    (substring filename (match-end 0))
+	  (concat "/null/" filename)))
+    filename)
+  )
 
 
 
       count)))
 
 ;; Fix up the file names in the list using the argument FILENAME
-;; Algorithm: find the first file's directory and cut it out from each file
-;; name in the patch.  Prepend the directory of FILENAME to each file in the
-;; patch.  In addition, the first file in the patch is replaced by FILENAME.
-;; Each file is actually a file-pair of files found in the context diff header
-;; In the end, for each pair, we select the shortest existing file.
+;; Algorithm: find the files' directories in the patch and, if a directory is
+;; absolute, cut it out from the corresponding file name in the patch.
+;; Relative directories are not cut out.
+;; Prepend the directory of FILENAME to each resulting file (which came
+;; originally from the patch).
+;; In addition, the first file in the patch document is replaced by FILENAME.
+;; Each file is actually a pair of files found in the context diff header
+;; In the end, for each pair, we ask the user which file to patch.
 ;; Note: Ediff doesn't recognize multi-file patches that are separated
 ;; with the `Index:' line.  It treats them as a single-file patch.
 ;;
 			;; directory part of filename
 			(file-name-as-directory filename)
 		      (file-name-directory filename)))
-	;; Filename-spec is objA; at this point it is represented as
-	;; (file1 . file2). We get it using ediff-get-session-objA
-	;; directory part of the first file in the patch
-	(base-dir1 (file-name-directory
-		    (car (ediff-get-session-objA-name (car ediff-patch-map)))))
-	;; directory part of the 2nd file in the patch
-	(base-dir2 (file-name-directory
-		    (cdr (ediff-get-session-objA-name (car ediff-patch-map)))))
+	;; In case 2 files are possible patch targets, the user will be offered
+	;; to choose file1 or file2.  In a multifile patch, if the user chooses
+	;; 1 or 2, this choice is preserved to decide future alternatives.
+	chosen-alternative
 	)
 
     ;; chop off base-dirs
     (mapcar (lambda (session-info)
-	      (let ((proposed-file-names
-		     (ediff-get-session-objA-name session-info)))
+	      (let* ((proposed-file-names
+		      ;; Filename-spec is objA; it is represented as
+		      ;; (file1 . file2). Get it using ediff-get-session-objA.
+		      (ediff-get-session-objA-name session-info))
+		     ;; base-dir1 is  the dir part of the 1st file in the patch
+		     (base-dir1 (file-name-directory (car proposed-file-names)))
+		     ;; directory part of the 2nd file in the patch
+		     (base-dir2 (file-name-directory (cdr proposed-file-names)))
+		     )
+		;; If both base-dir1 and base-dir2 are relative, assume that
+		;; these dirs lead to the actual files starting at the present
+		;; directory. So, we don't strip these relative dirs from the
+		;; file names. This is a heuristic intended to improve guessing
+		(unless (or (file-name-absolute-p base-dir1)
+			    (file-name-absolute-p base-dir2))
+		  (setq base-dir1 ""
+			base-dir2 ""))
 		(or (string= (car proposed-file-names) "/dev/null")
 		    (setcar proposed-file-names
 			    (ediff-file-name-sans-prefix
 			     (car proposed-file-names) base-dir1)))
-	      (or (string=
-		   (cdr proposed-file-names) "/dev/null")
-		  (setcdr proposed-file-names
-			  (ediff-file-name-sans-prefix
-			   (cdr proposed-file-names) base-dir2)))
-	      ))
+		(or (string=
+		     (cdr proposed-file-names) "/dev/null")
+		    (setcdr proposed-file-names
+			    (ediff-file-name-sans-prefix
+			     (cdr proposed-file-names) base-dir2)))
+		))
 	    ediff-patch-map)
 
     ;; take the given file name into account
 		     (ediff-get-session-objA-name session-info)))
 		(if (and (string-match "^/null/" (car proposed-file-names))
 			 (string-match "^/null/" (cdr proposed-file-names)))
-		    ;; couldn't strip base-dir1 and base-dir2
-		    ;; hence, something is wrong
+		    ;; couldn't intuit the file name to patch, so
+		    ;; something is amiss
 		    (progn
 		      (with-output-to-temp-buffer ediff-msg-buffer
 			(ediff-with-current-buffer standard-output
 		     (f1-exists (file-exists-p file1))
 		     (f2-exists (file-exists-p file2)))
 		(cond
-		 ((and (< (length file2) (length file1))
-		       f2-exists)
+		 ((and
+		   ;; The patch program prefers the shortest file as the patch
+		   ;; target. However, this is a questionable heuristic. In an
+		   ;; interactive program, like ediff, we can offer the user a
+		   ;; choice.
+		   ;; (< (length file2) (length file1))
+		   (not f1-exists)
+		   f2-exists)
 		  ;; replace file-pair with the winning file2
 		  (setcar session-file-object file2))
-		 ((and (< (length file1) (length file2))
-		       f1-exists)
+		 ((and
+		   ;; (< (length file1) (length file2))
+		   (not f2-exists)
+		   f1-exists)
 		  ;; replace file-pair with the winning file1
 		  (setcar session-file-object file1))
 		 ((and f1-exists f2-exists
 		       (string= file1 file2))
 		  (setcar session-file-object file1))
+		 ((and f1-exists f2-exists (eq chosen-alternative 1))
+		  (setcar session-file-object file1))
+		 ((and f1-exists f2-exists (eq chosen-alternative 2))
+		  (setcar session-file-object file2))
 		 ((and f1-exists f2-exists)
 		  (with-output-to-temp-buffer ediff-msg-buffer
 		    (ediff-with-current-buffer standard-output
     Type `y' to use %s as the target;
     Type `n' to use %s as the target.
 "
-				   file1 file2 file2 file1)))
+				   file1 file2 file1 file2)))
 		  (setcar session-file-object
-			  (if (y-or-n-p (format "Use %s ? " file2))
-			      file2 file1)))
+			  (if (y-or-n-p (format "Use %s ? " file1))
+			      (progn
+				(setq chosen-alternative 1)
+				file1)
+			    (setq chosen-alternative 2)
+			    file2))
+		  )
 		 (f2-exists (setcar session-file-object file2))
 		 (f1-exists (setcar session-file-object file1))
 		 (t
 		    (if (string= file1 file2)
 			(princ (format "
 	%s
-is the target for this patch.  However, this file does not exist."
+is assumed to be the target for this patch.  However, this file does not exist."
 				       file1))
 		      (princ (format "
 	%s
 
 ;; prompt for file, get the buffer
 (defun ediff-prompt-for-patch-file ()
-  (let ((dir (cond (ediff-patch-default-directory) ; try patch default dir
-		   (ediff-use-last-dir ediff-last-dir-patch)
+  (let ((dir (cond (ediff-use-last-dir ediff-last-dir-patch)
+		   (ediff-patch-default-directory) ; try patch default dir
 		   (t default-directory)))
-	(coding-system-for-read ediff-coding-system-for-read))
-    (find-file-noselect
-     (read-file-name
-      (format "Patch is in file:%s "
-	      (cond ((and buffer-file-name
-			  (equal (expand-file-name dir)
-				 (file-name-directory buffer-file-name)))
-		     (concat
-		      " (default "
-		      (file-name-nondirectory buffer-file-name)
-		      ")"))
-		    (t "")))
-      dir buffer-file-name 'must-match))
+	(coding-system-for-read ediff-coding-system-for-read)
+	patch-file-name)
+    (setq patch-file-name
+	  (read-file-name
+	   (format "Patch is in file:%s "
+		   (cond ((and buffer-file-name
+			       (equal (expand-file-name dir)
+				      (file-name-directory buffer-file-name)))
+			  (concat
+			   " (default "
+			   (file-name-nondirectory buffer-file-name)
+			   ")"))
+			 (t "")))
+	   dir buffer-file-name 'must-match))
+    (if (file-directory-p patch-file-name)
+	(error "Patch file cannot be a directory: %s" patch-file-name)
+      (find-file-noselect patch-file-name))
     ))
 
 
     (ediff-maybe-checkout buf-to-patch)
 
     (ediff-with-current-buffer patch-diagnostics
-      (insert-buffer patch-buf)
+      (insert-buffer-substring patch-buf)
       (message "Applying patch ... ")
       ;; fix environment for gnu patch, so it won't make numbered extensions
       (setq backup-style (getenv "VERSION_CONTROL"))

File ediff-util.el

 ;;; ediff-util.el --- the core commands and utilities of ediff
 
 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-;;   2004 Free Software Foundation, Inc.
+;;   2003, 2004, 2005 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 
 		   (ediff-unique-buffer-name "*ediff-merge" "*")))
 	    (save-excursion
 	      (set-buffer buffer-C)
-	      (insert-buffer buf)
+	      (insert-buffer-substring buf)
 	      (funcall (ediff-with-current-buffer buf major-mode))
 	      (widen) ; merge buffer is always widened
 	      (add-hook 'local-write-file-hooks 'ediff-set-merge-mode nil t)
 	  (ediff-clear-fine-differences n))
       ;; Make sure that the message about saving and how to restore is seen
       ;; by the user
-      (message messg))
+      (message "%s" messg))
     ))
 
 ;; Save Nth diff of buffer BUF-TYPE \(A, B, or C\).
 	     (format "Another buffer is visiting file %s. Too dangerous to save the merge buffer"
 		     file)))
 	(beep)
-	(message warn-message)
+	(message "%s" warn-message)
 	(with-output-to-temp-buffer ediff-msg-buffer
 	  (princ "\n\n")
 	  (princ warn-message)
 	    (princ warn-message)
 	    (princ "\n\n"))
 	  (if (y-or-n-p
-	       (message warn-message))
+	       (message "%s" warn-message))
 	      (with-current-buffer buff
 		(save-buffer)
 		(kill-buffer (current-buffer)))

File ediff-vers.el

 ;;; ediff-vers.el --- version control interface to Ediff
 
-;;; Copyright (C) 1995, 96, 97, 2002 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 1997, 2002, 2003, 2004,
+;;   2005 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 
 	  ((eq type 'MODIFIED)
 	   (ediff-buffers
 	    (find-file-noselect tmp-file)
-	    (find-file-noselect (cvs-fileinfo->full-path fileinfo))
+	    (if (featurep 'xemacs)
+		;; XEmacs doesn't seem to have cvs-fileinfo->full-name
+		(find-file-noselect (cvs-fileinfo->full-path fileinfo))
+	      (find-file-noselect (cvs-fileinfo->full-name fileinfo)))
 	    nil ; startup-hooks
 	    'ediff-revisions)))
     (if (stringp tmp-file) (delete-file tmp-file))

File ediff-wind.el

 ;;; ediff-wind.el --- window manipulation utilities
 
-;; Copyright (C) 1994, 95, 96, 97, 2000, 01, 02 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003,
+;;   2004, 2005 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 
 ;;; ediff.el --- a comprehensive visual interface to diff & patch
 
-;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02, 03, 05 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+;;   2003, 2004, 2005 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 ;; Created: February 2, 1994
 ;; Keywords: comparing, merging, patching, tools, unix
 
-(defconst ediff-version "2.80" "The current version of Ediff")
-(defconst ediff-date "July 8, 2005" "Date of last update")
+(defconst ediff-version "2.80.1" "The current version of Ediff")
+(defconst ediff-date "September 19, 2005" "Date of last update")
 
 
 ;; This file is part of GNU Emacs.
 This file documents Ediff, a comprehensive visual interface to Unix diff
 and patch utilities.
 
-Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software
-Foundation, Inc.
+Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+   2003, 2004, 2005 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.1 or
+under the terms of the GNU Free Documentation License, Version 1.2 or
 any later version published by the Free Software Foundation; with no
 Invariant Sections, with the Front-Cover texts being ``A GNU
 Manual'', and with the Back-Cover Texts as in (a) below.  A copy of the