Function: ediff-directories-internal

ediff-directories-internal is a byte-compiled function defined in ediff.el.gz.

Signature

(ediff-directories-internal DIR1 DIR2 DIR3 REGEXP ACTION JOBNAME &optional STARTUP-HOOKS MERGE-AUTOSTORE-DIR)

Source Code

;; Defined in /usr/src/emacs/lisp/vc/ediff.el.gz
;; Run ediff-action (ediff-files, ediff-merge, ediff-merge-with-ancestors)
;; on a pair of directories (three directories, in case of ancestor).
;; The third argument, REGEXP, is nil or a regular expression;
;; only file names that match the regexp are considered.
;; JOBNAME is the symbol indicating the meta-job to be performed.
;; MERGE-AUTOSTORE-DIR is the directory in which to store merged files.
(defun ediff-directories-internal (dir1 dir2 dir3 regexp action jobname
					&optional startup-hooks
					merge-autostore-dir)
  (if (stringp dir3)
      (setq dir3 (if (file-directory-p dir3) dir3 (file-name-directory dir3))))

  (cond ((string= dir1 dir2)
	 (user-error "Directories A and B are the same: %s" dir1))
	((and (eq jobname 'ediff-directories3)
	      (string= dir1 dir3))
	 (user-error "Directories A and C are the same: %s" dir1))
	((and (eq jobname 'ediff-directories3)
	      (string= dir2 dir3))
	 (user-error "Directories B and C are the same: %s" dir1)))

  (if merge-autostore-dir
      (or (stringp merge-autostore-dir)
	  (error "%s: Directory for storing merged files must be a string"
		 jobname)))
  (let (;; dir-diff-struct is of the form (common-list diff-list)
	;; It is a structure where ediff-intersect-directories returns
	;; commonalities and differences among directories
	dir-diff-struct
	meta-buf)
    (if (and ediff-autostore-merges
	     (ediff-merge-metajob jobname)
	     (not merge-autostore-dir))
	(setq merge-autostore-dir
	      (read-directory-name "Save merged files in directory: "
			      (if ediff-use-last-dir
					ediff-last-merge-autostore-dir
				      (ediff-strip-last-dir dir1))
			      nil
			      'must-match)))
    ;; verify we are not merging into an orig directory
    (if merge-autostore-dir
	(cond ((and (stringp dir1) (string= merge-autostore-dir dir1))
	       (or (y-or-n-p
		    "Directory for saving merged files = Directory A.  Sure? ")
		   (user-error "Directory merge aborted")))
	      ((and (stringp dir2) (string= merge-autostore-dir dir2))
	       (or (y-or-n-p
		    "Directory for saving merged files = Directory B.  Sure? ")
		   (user-error "Directory merge aborted")))
	      ((and (stringp dir3) (string= merge-autostore-dir dir3))
	       (or (y-or-n-p
		    "Directory for saving merged files = Ancestor Directory.  Sure? ")
		   (user-error "Directory merge aborted")))))

    (setq dir-diff-struct (ediff-intersect-directories
			   jobname
			   regexp dir1 dir2 dir3 merge-autostore-dir))
    ;; this sets various vars in the meta buffer inside
    ;; ediff-prepare-meta-buffer
    (push (lambda ()
	    ;; tell what to do if the user clicks on a session record
	    (setq ediff-session-action-function action)
	    ;; set ediff-dir-difference-list
	    (setq ediff-dir-difference-list
		  (cdr dir-diff-struct)))
	  startup-hooks)
    (setq meta-buf (ediff-prepare-meta-buffer
		    #'ediff-filegroup-action
		    (car dir-diff-struct)
		    "*Ediff Session Group Panel"
		    #'ediff-redraw-directory-group-buffer
		    jobname
		    startup-hooks))
    (ediff-show-meta-buffer meta-buf)
    ))