[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master a27dbbd 22/36: Started to fix issues with delete file
From: |
Alexey Veretennikov |
Subject: |
[elpa] master a27dbbd 22/36: Started to fix issues with delete file |
Date: |
Wed, 27 Jan 2016 23:50:56 +0000 |
branch: master
commit a27dbbdd209273bdf737b128d8afd59415277977
Author: Alexey Veretennikov <address@hidden>
Commit: Alexey Veretennikov <address@hidden>
Started to fix issues with delete file
---
ztree-diff-model.el | 7 +----
ztree-diff.el | 69 +++++++++++++++++++++++++++++++--------------------
2 files changed, 43 insertions(+), 33 deletions(-)
diff --git a/ztree-diff-model.el b/ztree-diff-model.el
index fd762b4..6165fe2 100644
--- a/ztree-diff-model.el
+++ b/ztree-diff-model.el
@@ -156,8 +156,6 @@ Filters out . and .."
(defun ztree-diff-model-partial-rescan (node)
"Rescan the NODE."
- ;; assuming what parent is always exists
- ;; otherwise the UI shall force the full rescan
(let ((parent (ztree-diff-node-parent node))
(isdir (ztree-diff-node-is-directory node))
(left (ztree-diff-node-left-path node))
@@ -341,7 +339,7 @@ if parent has ignored status - ignore"
;; finally set different status based on all children
;; depending if the node should participate in overall result
(unless should-ignore
- (ztree-diff-node-set-different node
+ (ztree-diff-node-set-different node
(cl-reduce 'ztree-diff-model-update-diff
children
:initial-value 'same
@@ -368,9 +366,6 @@ from comparison."
nil
nil)))
(ztree-diff-node-recreate model)
- (message (ztree-diff-node-to-string model))
- (dolist (c (ztree-diff-node-children model))
- (message (ztree-diff-node-to-string c)))
(message "Done.")
model))
diff --git a/ztree-diff.el b/ztree-diff.el
index 89bc2c5..16c730d 100644
--- a/ztree-diff.el
+++ b/ztree-diff.el
@@ -292,7 +292,12 @@ COPY-TO-RIGHT specifies which side of the NODE to update."
nil)
(error error-trap))))
;; error message if failed
- (if err (message (concat "Error: " (nth 1 err)))
+ (if err
+ (progn
+ (message (concat "Error: " (nth 1 err)))
+ ;; and do rescan of the node
+ (ztree-diff-do-partial-rescan node))
+ ;; if everything is ok, update statuses
(progn
(message target-full-path)
(if copy-to-right
@@ -379,24 +384,23 @@ COPY-TO-RIGHT specifies which side of the NODE to update."
(let* ((node (car found))
(side (cdr found))
(node-side (ztree-diff-node-side node))
- (delete-from-left t)
- (remove-path nil)
- (parent (ztree-diff-node-parent node)))
- (when parent ; do not delete the root node
- ;; algorithm for determining what to delete similar to copy:
- ;; 1. if the file is present on both sides, delete
- ;; from the side currently selected
- (setq delete-from-left (if (eq node-side 'both)
- (eq side 'left)
- ;; 2) if one of sides is absent, delete
- ;; from the side where the file is present
- (eq node-side 'left)))
- (setq remove-path (if delete-from-left
+ (parent (ztree-diff-node-parent node))
+ ;; algorithm for determining what to delete similar to copy:
+ ;; 1. if the file is present on both sides, delete
+ ;; from the side currently selected
+ ;; 2. if one of sides is absent, delete
+ ;; from the side where the file is present
+ (delete-from-left
+ (or (eql node-side 'left)
+ (and (eql node-side 'both)
+ (eql side 'left))))
+ (remove-path (if delete-from-left
(ztree-diff-node-left-path node)
- (ztree-diff-node-right-path node)))
- (when (yes-or-no-p (format "Delete the file [%s]%s ?"
- (if delete-from-left "LEFT" "RIGHT")
- remove-path))
+ (ztree-diff-node-right-path node))))
+ (when (and parent ; do not delete the root node
+ (yes-or-no-p (format "Delete the file [%s]%s ?"
+ (if delete-from-left "LEFT" "RIGHT")
+ remove-path)))
(let* ((delete-command
(if (file-directory-p remove-path)
#'delete-directory
@@ -417,16 +421,27 @@ COPY-TO-RIGHT specifies which side of the NODE to update."
;; of this node
(when (file-directory-p remove-path)
(ztree-diff-model-partial-rescan node)))
- ;; if everything ok
- (progn
- ;; remove the node from children
- (setq children (ztree-filter
- #'(lambda (x) (not (ztree-diff-node-equal x
node)))
- children))
- (ztree-diff-node-set-children parent children)))
+ ;; if everything ok
+ ;; if was only on one side
+ ;; remove the node from children
+ (if (or (and (eql node-side 'left)
+ delete-from-left)
+ (and (eql node-side 'right)
+ (not delete-from-left)))
+ (ztree-diff-node-set-children parent
+ (ztree-filter
+ (lambda (x) (not
(ztree-diff-node-equal x node)))
+ children))
+ ;; otherwise update only one side
+ (if delete-from-left
+ (ztree-diff-node-set-left-path node nil)
+ (ztree-diff-node-set-right-path node nil))
+ ;; and update diff status
+ ;; if was ignored keep the old status
+ (unless (eql (ztree-diff-node-different node) 'ignore)
+ (ztree-diff-node-set-different node 'new))))
(ztree-diff-node-update-all-parents-diff node)
- ;;(ztree-diff-model-partial-rescan node)
- (ztree-refresh-buffer (line-number-at-pos)))))))))
+ (ztree-refresh-buffer (line-number-at-pos))))))))
- [elpa] master 4a935ee 07/36: Reshuffled readme, (continued)
- [elpa] master 4a935ee 07/36: Reshuffled readme, Alexey Veretennikov, 2016/01/27
- [elpa] master 6018029 11/36: Started updating diff logic to include ignored files, Alexey Veretennikov, 2016/01/27
- [elpa] master c227ed8 12/36: Added debug output and some other changes, Alexey Veretennikov, 2016/01/27
- [elpa] master 64d3960 13/36: Added face for ignored files, Alexey Veretennikov, 2016/01/27
- [elpa] master 45dda44 14/36: Started updating diff logic to include ignored files, Alexey Veretennikov, 2016/01/27
- [elpa] master 2dc412f 15/36: Added debug output and some other changes, Alexey Veretennikov, 2016/01/27
- [elpa] master 9408ca1 17/36: Fixed ztree-node-is-visible, Alexey Veretennikov, 2016/01/27
- [elpa] master eea3c2b 19/36: added comments, Alexey Veretennikov, 2016/01/27
- [elpa] master cef7d95 20/36: Functions with errors still:, Alexey Veretennikov, 2016/01/27
- [elpa] master 653a7f1 21/36: Fixed ignored files, Alexey Veretennikov, 2016/01/27
- [elpa] master a27dbbd 22/36: Started to fix issues with delete file,
Alexey Veretennikov <=
- [elpa] master c3144bd 16/36: Updated model - ignored files still not handled, Alexey Veretennikov, 2016/01/27
- [elpa] master bc6a12a 18/36: Traverse function now supports ignored, Alexey Veretennikov, 2016/01/27
- [elpa] master b021697 29/36: Added comment to not to forget to update copy procedure., Alexey Veretennikov, 2016/01/27
- [elpa] master da721ab 33/36: Fixed compile warnings, Alexey Veretennikov, 2016/01/27
- [elpa] master be4e000 24/36: Fix typo in value of Created header keyword, Alexey Veretennikov, 2016/01/27
- [elpa] master b5b2d02 32/36: removed test files, Alexey Veretennikov, 2016/01/27
- [elpa] master 74899aa 30/36: Merge branch 'master' of github.com:fourier/ztree, Alexey Veretennikov, 2016/01/27
- [elpa] master 6d7ce1f 28/36: Fixed Delete method, Alexey Veretennikov, 2016/01/27
- [elpa] master 3d70aef 25/36: Merge pull request #30 from tarsius/fix-typo, Alexey Veretennikov, 2016/01/27
- [elpa] master 159ddbd 26/36: Fixed partial update, Alexey Veretennikov, 2016/01/27