aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/ediff-diff.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/ediff-diff.el')
-rw-r--r--lisp/ediff-diff.el62
1 files changed, 41 insertions, 21 deletions
diff --git a/lisp/ediff-diff.el b/lisp/ediff-diff.el
index 4c13e6fc0e1..ec496301405 100644
--- a/lisp/ediff-diff.el
+++ b/lisp/ediff-diff.el
@@ -1353,7 +1353,7 @@ Symlinks and the likes are not handled.
1353If FILTER-RE is non-nil, recursive checking in directories 1353If FILTER-RE is non-nil, recursive checking in directories
1354affects only files whose names match the expression." 1354affects only files whose names match the expression."
1355 ;; Normalize empty filter RE to nil. 1355 ;; Normalize empty filter RE to nil.
1356 (unless (length filter-re) (setq filter-re nil)) 1356 (unless (> (length filter-re) 0) (setq filter-re nil))
1357 ;; Indicate progress 1357 ;; Indicate progress
1358 (message "Comparing '%s' and '%s' modulo '%s'" d1 d2 filter-re) 1358 (message "Comparing '%s' and '%s' modulo '%s'" d1 d2 filter-re)
1359 (cond 1359 (cond
@@ -1367,27 +1367,11 @@ affects only files whose names match the expression."
1367 (if (eq ediff-recurse-to-subdirectories 'yes) 1367 (if (eq ediff-recurse-to-subdirectories 'yes)
1368 (let* ((all-entries-1 (directory-files d1 t filter-re)) 1368 (let* ((all-entries-1 (directory-files d1 t filter-re))
1369 (all-entries-2 (directory-files d2 t filter-re)) 1369 (all-entries-2 (directory-files d2 t filter-re))
1370 (entries-1 (remove-if (lambda (s) 1370 (entries-1 (ediff-delete-all-matches "^\\.\\.?$" all-entries-1))
1371 (string-match "^\\.\\.?$" 1371 (entries-2 (ediff-delete-all-matches "^\\.\\.?$" all-entries-2))
1372 (file-name-nondirectory s)))
1373 all-entries-1))
1374 (entries-2 (remove-if (lambda (s)
1375 (string-match "^\\.\\.?$"
1376 (file-name-nondirectory s)))
1377 all-entries-2))
1378 ) 1372 )
1379 ;; First, check only the names (works quickly and ensures a 1373
1380 ;; precondition for subsequent code) 1374 (ediff-same-file-contents-lists entries-1 entries-2 filter-re)
1381 (if (and (= (length entries-1) (length entries-2))
1382 (every (lambda (a b) (equal (file-name-nondirectory a)
1383 (file-name-nondirectory b)))
1384 entries-1 entries-2))
1385 ;; With name equality established, compare the entries
1386 ;; through recursion.
1387 (every (lambda (a b)
1388 (ediff-same-contents a b filter-re))
1389 entries-1 entries-2)
1390 )
1391 )) 1375 ))
1392 ) ; end of the directories case 1376 ) ; end of the directories case
1393 ;; D1 & D2 are both files => compare directly 1377 ;; D1 & D2 are both files => compare directly
@@ -1398,6 +1382,42 @@ affects only files whose names match the expression."
1398 ) 1382 )
1399 ) 1383 )
1400 1384
1385;; If lists have the same length and names of files are pairwise equal
1386;; (removing the directories) then compare contents pairwise.
1387;; True if all contents are the same; false otherwise
1388(defun ediff-same-file-contents-lists (entries-1 entries-2 filter-re)
1389 ;; First, check only the names (works quickly and ensures a
1390 ;; precondition for subsequent code)
1391 (if (and (= (length entries-1) (length entries-2))
1392 (equal (mapcar 'file-name-nondirectory entries-1)
1393 (mapcar 'file-name-nondirectory entries-2)))
1394 ;; With name equality established, compare the entries
1395 ;; through recursion.
1396 (let ((continue t))
1397 (while (and entries-1 continue)
1398 (if (ediff-same-contents
1399 (car entries-1) (car entries-2) filter-re)
1400 (setq entries-1 (cdr entries-1)
1401 entries-2 (cdr entries-2))
1402 (setq continue nil))
1403 )
1404 ;; if reached the end then lists are equal
1405 (null entries-1))
1406 )
1407 )
1408
1409
1410;; ARG1 is a regexp, ARG2 is a list of full-filenames
1411;; Delete all entries that match the regexp
1412(defun ediff-delete-all-matches (regex file-list-list)
1413 (let (result elt)
1414 (while file-list-list
1415 (setq elt (car file-list-list))
1416 (or (string-match regex (file-name-nondirectory elt))
1417 (setq result (cons elt result)))
1418 (setq file-list-list (cdr file-list-list)))
1419 (reverse result)))
1420
1401 1421
1402;;; Local Variables: 1422;;; Local Variables:
1403;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) 1423;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)