Mercurial > hg > xemacs-beta
comparison lisp/ediff/ediff.el @ 12:bcdc7deadc19 r19-15b7
Import from CVS: tag r19-15b7
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:48:16 +0200 |
parents | ac2d302a0011 |
children | 9ee227acff29 |
comparison
equal
deleted
inserted
replaced
11:91ffe8bd52e4 | 12:bcdc7deadc19 |
---|---|
4 | 4 |
5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> | 5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> |
6 ;; Created: February 2, 1994 | 6 ;; Created: February 2, 1994 |
7 ;; Keywords: comparing, merging, patching, version control. | 7 ;; Keywords: comparing, merging, patching, version control. |
8 | 8 |
9 (defconst ediff-version "2.61" "The current version of Ediff") | 9 (defconst ediff-version "2.63" "The current version of Ediff") |
10 (defconst ediff-date "June 10, 1996" "Date of last update") | 10 (defconst ediff-date "September 12, 1996" "Date of last update") |
11 | 11 |
12 | 12 |
13 ;; This file is part of GNU Emacs. | 13 ;; This file is part of GNU Emacs. |
14 | 14 |
15 ;; GNU Emacs is free software; you can redistribute it and/or modify | 15 ;; GNU Emacs is free software; you can redistribute it and/or modify |
108 | 108 |
109 (require 'ediff-init) | 109 (require 'ediff-init) |
110 ;; ediff-mult is always required, because of the registry stuff | 110 ;; ediff-mult is always required, because of the registry stuff |
111 (require 'ediff-mult) | 111 (require 'ediff-mult) |
112 | 112 |
113 (eval-when-compile | 113 (and noninteractive |
114 (load "dired") | 114 (eval-when-compile |
115 (load-file "./ediff-ptch.el") | 115 (let ((load-path (cons (expand-file-name ".") load-path))) |
116 (load-file "./ediff-vers.el") | 116 (load-library "dired") |
117 (load "pcl-cvs" 'noerror)) | 117 (load-file "ediff-ptch.el") |
118 (load-file "ediff-vers.el") | |
119 (load "pcl-cvs" 'noerror)))) | |
118 | 120 |
119 (defvar ediff-use-last-dir nil | 121 (defvar ediff-use-last-dir nil |
120 "*If t, Ediff uses previous directory as default when reading file name.") | 122 "*If t, Ediff uses previous directory as default when reading file name.") |
121 | 123 |
122 (defvar ediff-last-dir-A nil | 124 (defvar ediff-last-dir-A nil |
125 "Last directory used by an Ediff command for file-B.") | 127 "Last directory used by an Ediff command for file-B.") |
126 (defvar ediff-last-dir-C nil | 128 (defvar ediff-last-dir-C nil |
127 "Last directory used by an Ediff command for file-C.") | 129 "Last directory used by an Ediff command for file-C.") |
128 (defvar ediff-last-dir-ancestor nil | 130 (defvar ediff-last-dir-ancestor nil |
129 "Last directory used by an Ediff command for the ancestor file.") | 131 "Last directory used by an Ediff command for the ancestor file.") |
132 (defvar ediff-last-merge-autostore-dir | |
133 "Last directory used by an Ediff command as the output directory for merge.") | |
130 | 134 |
131 ;; Some defvars to reduce the number of compiler warnings | 135 ;; Some defvars to reduce the number of compiler warnings |
132 (defvar cvs-cookie-handle) | 136 (defvar cvs-cookie-handle) |
133 (defvar ediff-last-dir-patch) | 137 (defvar ediff-last-dir-patch) |
134 (defvar ediff-patch-default-directory) | 138 (defvar ediff-patch-default-directory) |
603 ;; Run ediff-action (ediff-files, ediff-merge, ediff-merge-with-ancestors) | 607 ;; Run ediff-action (ediff-files, ediff-merge, ediff-merge-with-ancestors) |
604 ;; on a pair of directories (three directories, in case of ancestor). | 608 ;; on a pair of directories (three directories, in case of ancestor). |
605 ;; The third argument, REGEXP, is a regular expression that can be used to | 609 ;; The third argument, REGEXP, is a regular expression that can be used to |
606 ;; filter out certain file names. | 610 ;; filter out certain file names. |
607 ;; JOBNAME is the symbol indicating the meta-job to be performed. | 611 ;; JOBNAME is the symbol indicating the meta-job to be performed. |
608 (defun ediff-directories-internal (dir1 dir2 dir3 regexp | 612 ;; MERGE-DIR is the directory in which to store merged files. |
609 action jobname | 613 (defun ediff-directories-internal (dir1 dir2 dir3 regexp action jobname |
610 &optional startup-hooks) | 614 &optional startup-hooks) |
611 ;; ediff-read-file-name is set to attach a previously entered file name if | 615 ;; ediff-read-file-name is set to attach a previously entered file name if |
612 ;; the currently entered file is a directory. This code takes care of that. | 616 ;; the currently entered file is a directory. This code takes care of that. |
613 (setq dir1 (if (file-directory-p dir1) dir1 (file-name-directory dir1)) | 617 (setq dir1 (if (file-directory-p dir1) dir1 (file-name-directory dir1)) |
614 dir2 (if (file-directory-p dir2) dir2 (file-name-directory dir2))) | 618 dir2 (if (file-directory-p dir2) dir2 (file-name-directory dir2))) |
624 ((and (eq jobname 'ediff-directories3) | 628 ((and (eq jobname 'ediff-directories3) |
625 (string= dir2 dir3)) | 629 (string= dir2 dir3)) |
626 (error "Directories B and C are the same: %s" dir1))) | 630 (error "Directories B and C are the same: %s" dir1))) |
627 | 631 |
628 (let (diffs ; var where ediff-intersect-directories returns the diff list | 632 (let (diffs ; var where ediff-intersect-directories returns the diff list |
633 merge-autostore-dir | |
629 file-list meta-buf) | 634 file-list meta-buf) |
635 (if (and ediff-autostore-merges (ediff-merge-metajob jobname)) | |
636 (setq merge-autostore-dir | |
637 (ediff-read-file-name "Directory to save merged files:" | |
638 (if ediff-use-last-dir | |
639 ediff-last-merge-autostore-dir | |
640 (ediff-strip-last-dir dir1)) | |
641 nil))) | |
642 ;; verify we are not merging into an orig directory | |
643 (if (stringp merge-autostore-dir) | |
644 (cond ((and (stringp dir1) (string= merge-autostore-dir dir1)) | |
645 (or (y-or-n-p "Merge directory same as directory A, sure? ") | |
646 (error "Directory merge aborted"))) | |
647 ((and (stringp dir2) (string= merge-autostore-dir dir2)) | |
648 (or (y-or-n-p "Merge directory same as directory B, sure? ") | |
649 (error "Directory merge aborted"))) | |
650 ((and (stringp dir3) (string= merge-autostore-dir dir3)) | |
651 (or (y-or-n-p | |
652 "Merge directory same as ancestor directory, sure? ") | |
653 (error "Directory merge aborted"))))) | |
654 | |
630 (setq file-list (ediff-intersect-directories | 655 (setq file-list (ediff-intersect-directories |
631 jobname 'diffs regexp dir1 dir2 dir3)) | 656 jobname 'diffs |
657 regexp dir1 dir2 dir3 merge-autostore-dir)) | |
632 (setq startup-hooks | 658 (setq startup-hooks |
633 ;; this sets various vars in the meta buffer inside | 659 ;; this sets various vars in the meta buffer inside |
634 ;; ediff-prepare-meta-buffer | 660 ;; ediff-prepare-meta-buffer |
635 (cons (` (lambda () | 661 (cons (` (lambda () |
636 ;; tell what to do if the user clicks on a session record | 662 ;; tell what to do if the user clicks on a session record |
649 )) | 675 )) |
650 | 676 |
651 (defun ediff-directory-revisions-internal (dir1 regexp action jobname | 677 (defun ediff-directory-revisions-internal (dir1 regexp action jobname |
652 &optional startup-hooks) | 678 &optional startup-hooks) |
653 (setq dir1 (if (file-directory-p dir1) dir1 (file-name-directory dir1))) | 679 (setq dir1 (if (file-directory-p dir1) dir1 (file-name-directory dir1))) |
654 (let (file-list meta-buf) | 680 |
681 (let (file-list meta-buf merge-autostore-dir) | |
682 (if (and ediff-autostore-merges (ediff-merge-metajob jobname)) | |
683 (setq merge-autostore-dir | |
684 (ediff-read-file-name "Directory to save merged files:" | |
685 (if ediff-use-last-dir | |
686 ediff-last-merge-autostore-dir | |
687 (ediff-strip-last-dir dir1)) | |
688 nil))) | |
689 ;; verify merge-autostore-dir != dir1 | |
690 (if (and (stringp merge-autostore-dir) | |
691 (stringp dir1) | |
692 (string= merge-autostore-dir dir1)) | |
693 (or (y-or-n-p | |
694 "Directory for saving merges is the same as directory A. Sure? ") | |
695 (error "Merge of directory revisions aborted"))) | |
696 | |
655 (setq file-list | 697 (setq file-list |
656 (ediff-get-directory-files-under-revision jobname regexp dir1)) | 698 (ediff-get-directory-files-under-revision |
699 jobname regexp dir1 merge-autostore-dir)) | |
657 (setq startup-hooks | 700 (setq startup-hooks |
658 ;; this sets various vars in the meta buffer inside | 701 ;; this sets various vars in the meta buffer inside |
659 ;; ediff-prepare-meta-buffer | 702 ;; ediff-prepare-meta-buffer |
660 (cons (` (lambda () | 703 (cons (` (lambda () |
661 ;; tell what to do if the user clicks on a session record | 704 ;; tell what to do if the user clicks on a session record |
802 | 845 |
803 (set-buffer buffer-B) | 846 (set-buffer buffer-B) |
804 (setq reg-B-beg (region-beginning) | 847 (setq reg-B-beg (region-beginning) |
805 reg-B-end (region-end)) | 848 reg-B-end (region-end)) |
806 ;; enlarge the region to hold full lines | 849 ;; enlarge the region to hold full lines |
807 (goto-char reg-A-beg) | |
808 (goto-char reg-B-beg) | 850 (goto-char reg-B-beg) |
809 (beginning-of-line) | 851 (beginning-of-line) |
810 (setq reg-B-beg (point)) | 852 (setq reg-B-beg (point)) |
811 (goto-char reg-B-end) | 853 (goto-char reg-B-end) |
812 (end-of-line) | 854 (end-of-line) |
1050 (if (stringp file) | 1092 (if (stringp file) |
1051 (file-name-nondirectory file) "current buffer")))) | 1093 (file-name-nondirectory file) "current buffer")))) |
1052 (ediff-load-version-control) | 1094 (ediff-load-version-control) |
1053 ;; ancestor-revision=nil | 1095 ;; ancestor-revision=nil |
1054 (funcall | 1096 (funcall |
1055 (intern (format "%S-ediff-merge-internal" ediff-version-control-package)) | 1097 (intern (format "ediff-%S-merge-internal" ediff-version-control-package)) |
1056 rev1 rev2 nil startup-hooks))) | 1098 rev1 rev2 nil startup-hooks))) |
1057 | 1099 |
1058 | 1100 |
1059 ;;;###autoload | 1101 ;;;###autoload |
1060 (defun ediff-merge-revisions-with-ancestor (&optional file startup-hooks) | 1102 (defun ediff-merge-revisions-with-ancestor (&optional file startup-hooks) |
1082 "Ancestor version (default: %s): " | 1124 "Ancestor version (default: %s): " |
1083 (if (stringp file) | 1125 (if (stringp file) |
1084 (file-name-nondirectory file) "current buffer")))) | 1126 (file-name-nondirectory file) "current buffer")))) |
1085 (ediff-load-version-control) | 1127 (ediff-load-version-control) |
1086 (funcall | 1128 (funcall |
1087 (intern (format "%S-ediff-merge-internal" ediff-version-control-package)) | 1129 (intern (format "ediff-%S-merge-internal" ediff-version-control-package)) |
1088 rev1 rev2 ancestor-rev startup-hooks))) | 1130 rev1 rev2 ancestor-rev startup-hooks))) |
1089 | 1131 |
1090 ;;;###autoload | 1132 ;;;###autoload |
1091 (defun run-ediff-from-cvs-buffer (pos) | 1133 (defun run-ediff-from-cvs-buffer (pos) |
1092 "Run Ediff-merge on appropriate revisions of the selected file. | 1134 "Run Ediff-merge on appropriate revisions of the selected file. |
1166 (format "Version 2 to compare (default: %s): " | 1208 (format "Version 2 to compare (default: %s): " |
1167 (if (stringp file) | 1209 (if (stringp file) |
1168 (file-name-nondirectory file) "current buffer")))) | 1210 (file-name-nondirectory file) "current buffer")))) |
1169 (ediff-load-version-control) | 1211 (ediff-load-version-control) |
1170 (funcall | 1212 (funcall |
1171 (intern (format "%S-ediff-internal" ediff-version-control-package)) | 1213 (intern (format "ediff-%S-internal" ediff-version-control-package)) |
1172 rev1 rev2 startup-hooks) | 1214 rev1 rev2 startup-hooks) |
1173 )) | 1215 )) |
1174 | 1216 |
1175 | 1217 |
1176 ;; Test if version control package is loaded and load if not | 1218 ;; Test if version control package is loaded and load if not |
1196 (message (ediff-version)) | 1238 (message (ediff-version)) |
1197 (format "Ediff %s of %s" ediff-version ediff-date))) | 1239 (format "Ediff %s of %s" ediff-version ediff-date))) |
1198 | 1240 |
1199 | 1241 |
1200 ;;;###autoload | 1242 ;;;###autoload |
1201 (defun ediff-documentation () | 1243 (defun ediff-documentation (&optional node) |
1202 "Display Ediff's manual." | 1244 "Display Ediff's manual. |
1245 With optional NODE, goes to that node." | |
1203 (interactive) | 1246 (interactive) |
1204 (let ((ctl-window ediff-control-window) | 1247 (let ((ctl-window ediff-control-window) |
1205 (ctl-buf ediff-control-buffer)) | 1248 (ctl-buf ediff-control-buffer)) |
1206 | 1249 |
1207 (ediff-skip-unsuitable-frames) | 1250 (ediff-skip-unsuitable-frames) |
1208 (condition-case nil | 1251 (condition-case nil |
1209 (progn | 1252 (progn |
1210 (pop-to-buffer (get-buffer-create "*info*")) | 1253 (pop-to-buffer (get-buffer-create "*info*")) |
1211 (info (if ediff-xemacs-p "ediff.info" "ediff")) | 1254 (info (if ediff-xemacs-p "ediff.info" "ediff")) |
1212 (message "Type `i' to search for a specific topic")) | 1255 (if node |
1256 (Info-goto-node node) | |
1257 (message "Type `i' to search for a specific topic")) | |
1258 (raise-frame (selected-frame))) | |
1213 (error (beep 1) | 1259 (error (beep 1) |
1214 (with-output-to-temp-buffer ediff-msg-buffer | 1260 (with-output-to-temp-buffer ediff-msg-buffer |
1215 (princ (format " | 1261 (princ ediff-BAD-INFO)) |
1216 The Info file for Ediff does not seem to be installed. | |
1217 | |
1218 This file is part of the distribution of %sEmacs. | |
1219 Please contact your system administrator. " | |
1220 (if ediff-xemacs-p "X" "")))) | |
1221 (if (window-live-p ctl-window) | 1262 (if (window-live-p ctl-window) |
1222 (progn | 1263 (progn |
1223 (select-window ctl-window) | 1264 (select-window ctl-window) |
1224 (set-window-buffer ctl-window ctl-buf))))))) | 1265 (set-window-buffer ctl-window ctl-buf))))))) |
1225 | 1266 |
1227 | 1268 |
1228 | 1269 |
1229 ;;; Local Variables: | 1270 ;;; Local Variables: |
1230 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) | 1271 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) |
1231 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) | 1272 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) |
1273 ;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body)) | |
1232 ;;; End: | 1274 ;;; End: |
1233 | 1275 |
1234 (provide 'ediff) | 1276 (provide 'ediff) |
1235 (require 'ediff-util) | 1277 (require 'ediff-util) |
1236 | 1278 |