branch: master commit 6018029ba2f376ffede082bba171c0344e307385 Author: Alexey Veretennikov <txm.four...@gmail.com> Commit: Alexey Veretennikov <alexey.veretenni...@afconsult.com>
Started updating diff logic to include ignored files --- ztree-diff-model.el | 22 ++++++++++++---------- ztree-diff.el | 33 ++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/ztree-diff-model.el b/ztree-diff-model.el index e06e82f..712f8ae 100644 --- a/ztree-diff-model.el +++ b/ztree-diff-model.el @@ -53,7 +53,7 @@ ;; right-path is the full path of the right side, ;; short-name - is the file or directory name ;; children - list of nodes - files or directories if the node is a directory -;; different = {nil, 'new, 'diff} - means comparison status +;; different = {nil, 'new, 'diff, 'ignore} - means comparison status (ztree-defrecord ztree-diff-node (parent left-path right-path short-name right-short-name children different)) (defun ztree-diff-model-ignore-p (node) @@ -67,6 +67,7 @@ (cond ((stringp x) x) ((eq x 'new) "new") ((eq x 'diff) "different") + ((eq x 'ignore) "ignored") (t (ztree-diff-node-short-name x))) "(empty)"))) (children (ztree-diff-node-children node)) @@ -202,15 +203,16 @@ Argument SIDE either 'left or 'right side." (defun ztree-diff-node-update-diff-from-children (node) "Set the diff status for the NODE based on its children." - (let ((children (ztree-diff-node-children node)) - (diff nil)) - (dolist (child children) - (unless (ztree-diff-model-ignore-p child) - (setq diff - (ztree-diff-model-update-diff - diff - (ztree-diff-node-different child))))) - (ztree-diff-node-set-different node diff))) + (unless (eq (ztree-diff-node-different node 'ignore)) + (let ((children (ztree-diff-node-children node)) + (diff nil)) + (dolist (child children) + (unless (ztree-diff-model-ignore-p child) + (setq diff + (ztree-diff-model-update-diff + diff + (ztree-diff-node-different child))))) + (ztree-diff-node-set-different node diff)))) (defun ztree-diff-node-update-all-parents-diff (node) "Recursively update all parents diff status for the NODE." diff --git a/ztree-diff.el b/ztree-diff.el index b95af1b..c2ad76f 100644 --- a/ztree-diff.el +++ b/ztree-diff.el @@ -117,7 +117,7 @@ By default paths starting with dot (like .git) are ignored") (defun ztree-diff-node-face (node) "Return the face for the NODE depending on diff status." (let ((diff (ztree-diff-node-different node))) - (cond ((ztree-diff-node-ignore-p node) ztreep-diff-model-ignored-face) + (cond ((eq diff 'ignore) ztreep-diff-model-ignored-face) ((eq diff 'diff) ztreep-diff-model-diff-face) ((eq diff 'new) ztreep-diff-model-add-face) (t ztreep-diff-model-normal-face)))) @@ -143,7 +143,11 @@ By default paths starting with dot (like .git) are ignored") (insert "\n") (ztree-insert-with-face " Mismatch file " ztreep-diff-model-diff-face) (ztree-insert-with-face "- different from other side" ztreep-diff-header-small-face) + (insert "\n ") + (ztree-insert-with-face "Ignored file" ztreep-diff-model-ignored-face) + (ztree-insert-with-face " - ignored from comparison" ztreep-diff-header-small-face) (insert "\n") + (ztree-insert-with-face "==============" ztreep-diff-header-face) (insert "\n")) @@ -261,8 +265,9 @@ COPY-TO-RIGHT specifies which side of the NODE to update." (if err (message (concat "Error: " (nth 2 err))) (progn ; otherwise: ;; assuming all went ok when left and right nodes are the same - ;; set both as not different - (ztree-diff-node-set-different node nil) + ;; set both as not different if they were not ignored + (unless (eq (ztree-diff-node-different node) 'ignore) + (ztree-diff-node-set-different node nil)) ;; update left/right paths (if copy-to-right (ztree-diff-node-set-right-path node target-path) @@ -441,16 +446,18 @@ unless it is a parent node." (defun ztree-node-is-visible (node) "Determine if the NODE should be visible." - ;; visible then - ;; 1) either it is a parent - (or (not (ztree-diff-node-parent node)) ; parent is always visible - (and - ;; 2.1) or it is not in ignore list and - (or ztree-diff-show-filtered-files ; show filtered files regardless - (not (ztree-diff-node-ignore-p node))) - ;; 2.2) it has different status - (or ztree-diff-show-equal-files ; show equal files regardless - (ztree-diff-node-different node))))) + (let ((diff (ztree-diff-node-different node))) + ;; visible then + ;; 1) either it is a parent + (or (ztree-diff-node-parent node) ; parent is always visible + ;; 2.1) or it is not in ignore list and + (and (eq diff 'ignore) + ztree-diff-show-filtered-files) ; show filtered files regardless + ;; 2.2) it has different status + (and ztree-diff-show-equal-files ; show equal files regardless + (not diff)) + (or (eq diff 'new) + (eq diff 'diff))))) (defun ztree-diff-toggle-show-equal-files () "Toggle visibility of the equal files."