/[emacs]/emacs/lisp/ediff-diff.el
ViewVC logotype

Diff of /emacs/lisp/ediff-diff.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.40 by uid65627, Sat Jan 3 12:11:21 2004 UTC revision 1.41 by kifer, Sat Feb 19 04:46:24 2005 UTC
# Line 534  one optional arguments, diff-number to r Line 534  one optional arguments, diff-number to r
534  (defun ediff-set-diff-overlays-in-one-buffer (buf-type diff-list)  (defun ediff-set-diff-overlays-in-one-buffer (buf-type diff-list)
535    (let* ((current-diff -1)    (let* ((current-diff -1)
536           (buff (ediff-get-buffer buf-type))           (buff (ediff-get-buffer buf-type))
537             (ctl-buf ediff-control-buffer)
538           ;; ediff-extract-diffs puts the type of diff-list as the first elt           ;; ediff-extract-diffs puts the type of diff-list as the first elt
539           ;; of this list. The type is either 'points or 'words           ;; of this list. The type is either 'points or 'words
540           (diff-list-type (car diff-list))           (diff-list-type (car diff-list))
# Line 580  one optional arguments, diff-number to r Line 581  one optional arguments, diff-number to r
581        (if (eq diff-list-type 'words)        (if (eq diff-list-type 'words)
582            (progn            (progn
583              (ediff-with-current-buffer buff (goto-char pt-saved))              (ediff-with-current-buffer buff (goto-char pt-saved))
584              (setq begin (ediff-goto-word (1+ begin) buff)              (ediff-with-current-buffer ctl-buf
585                    end (ediff-goto-word end buff 'end))                (setq begin (ediff-goto-word (1+ begin) buff)
586                        end (ediff-goto-word end buff 'end)))
587              (if (> end limit) (setq end limit))              (if (> end limit) (setq end limit))
588              (if (> begin end) (setq begin end))              (if (> begin end) (setq begin end))
589              (setq pt-saved (ediff-with-current-buffer buff (point)))))              (setq pt-saved (ediff-with-current-buffer buff (point)))))
# Line 864  delimiter regions")) Line 866  delimiter regions"))
866    (let* ((current-diff -1)    (let* ((current-diff -1)
867           (reg-start (ediff-get-diff-posn buf-type 'beg region-num))           (reg-start (ediff-get-diff-posn buf-type 'beg region-num))
868           (buff (ediff-get-buffer buf-type))           (buff (ediff-get-buffer buf-type))
869             (ctl-buf ediff-control-buffer)
870           combined-merge-diff-list           combined-merge-diff-list
871           diff-overlay-list list-element           diff-overlay-list list-element
872           begin end overlay)           begin end overlay)
# Line 892  delimiter regions")) Line 895  delimiter regions"))
895              () ; skip this diff              () ; skip this diff
896            ;; Put overlays at appropriate places in buffers            ;; Put overlays at appropriate places in buffers
897            ;; convert lines to points, if necessary            ;; convert lines to points, if necessary
898            (setq begin (ediff-goto-word (1+ begin) buff)            (ediff-with-current-buffer ctl-buf
899                  end (ediff-goto-word end buff 'end))              (setq begin (ediff-goto-word (1+ begin) buff)
900                      end (ediff-goto-word end buff 'end)))
901            (setq overlay (ediff-make-bullet-proof-overlay begin end buff))            (setq overlay (ediff-make-bullet-proof-overlay begin end buff))
902            ;; record all overlays for this difference region            ;; record all overlays for this difference region
903            (setq diff-overlay-list (nconc diff-overlay-list (list overlay))))            (setq diff-overlay-list (nconc diff-overlay-list (list overlay))))
# Line 1326  arguments to `skip-chars-forward'." Line 1330  arguments to `skip-chars-forward'."
1330          (while (> n 1)          (while (> n 1)
1331            (funcall fwd-word-fun)            (funcall fwd-word-fun)
1332            (skip-chars-forward ediff-whitespace)            (skip-chars-forward ediff-whitespace)
1333            (setq n (1- n))))            (setq n (1- n)))
1334        (if (and flag (> n 0))          (if (and flag (> n 0))
1335            (funcall fwd-word-fun))              (funcall fwd-word-fun)))
1336        (point))))        (point))))
1337    
1338  (defun ediff-same-file-contents (f1 f2)  (defun ediff-same-file-contents (f1 f2)
1339    "Return t if F1 and F2 have identical contents."    "Return t if files F1 and F2 have identical contents."
1340    (let ((res    (if (and (not (file-directory-p f1))
1341           (apply 'call-process ediff-cmp-program nil nil nil             (not (file-directory-p f2)))
1342                  (append ediff-cmp-options (list f1 f2)))))        (let ((res
1343      (and (numberp res) (eq res 0))))               (apply 'call-process ediff-cmp-program nil nil nil
1344                        (append ediff-cmp-options (list f1 f2)))))
1345            (and (numberp res) (eq res 0))))
1346      )
1347    
1348    
1349    (defun ediff-same-contents (d1 d2 &optional filter-re)
1350      "Returns t iff D1 and D2 have the same content.
1351    D1 and D2 can either be both directories or both regular files.
1352    Symlinks and the likes are not handled.
1353    If FILTER-RE is non-nil, recursive checking in directories
1354    affects only files whose names match the expression."
1355      ;; Normalize empty filter RE to nil.
1356      (unless (length filter-re) (setq filter-re nil))
1357      ;; Indicate progress
1358      (message "Comparing '%s' and '%s' modulo '%s'" d1 d2 filter-re)
1359      (cond
1360       ;; D1 & D2 directories => recurse
1361       ((and (file-directory-p d1)
1362             (file-directory-p d2))
1363        (if (null ediff-recurse-to-subdirectories)
1364            (if (y-or-n-p "Compare subdirectories recursively? ")
1365                (setq ediff-recurse-to-subdirectories 'yes)
1366              (setq ediff-recurse-to-subdirectories 'no)))
1367        (if (eq ediff-recurse-to-subdirectories 'yes)
1368            (let* ((all-entries-1 (directory-files d1 t filter-re))
1369                   (all-entries-2 (directory-files d2 t filter-re))
1370                   (entries-1 (remove-if (lambda (s)
1371                                           (string-match "^\\.\\.?$"
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                   )
1379              ;; First, check only the names (works quickly and ensures a
1380              ;; precondition for subsequent code)
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              ))
1392        ) ; end of the directories case
1393       ;; D1 & D2 are both files => compare directly
1394       ((and (file-regular-p d1)
1395             (file-regular-p d2))
1396        (ediff-same-file-contents d1 d2))
1397       ;; Otherwise => false: unequal contents
1398       )
1399      )
1400    
1401    
1402  ;;; Local Variables:  ;;; Local Variables:

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.41

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26