emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ssh-deploy 567e1d5 120/133: Work on feature to automati


From: Stefan Monnier
Subject: [elpa] externals/ssh-deploy 567e1d5 120/133: Work on feature to automatically update revisions
Date: Sat, 27 Mar 2021 14:48:56 -0400 (EDT)

branch: externals/ssh-deploy
commit 567e1d55ffdb022752d3854f67ca6c5fe669f24d
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    Work on feature to automatically update revisions
---
 ssh-deploy-diff-mode.el |  8 +-------
 ssh-deploy-test.el      | 44 ++++++++++++++++++++++++--------------------
 ssh-deploy.el           | 10 ++++++++--
 3 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/ssh-deploy-diff-mode.el b/ssh-deploy-diff-mode.el
index 52abf6f..debed5d 100644
--- a/ssh-deploy-diff-mode.el
+++ b/ssh-deploy-diff-mode.el
@@ -23,13 +23,7 @@
 
 ;;; Code:
 
-
-(autoload 'ssh-deploy-diff-directories "ssh-deploy")
-(autoload 'ssh-deploy-upload "ssh-deploy")
-(autoload 'ssh-deploy-download "ssh-deploy")
-(autoload 'ssh-deploy-delete-both "ssh-deploy")
-(autoload 'ssh-deploy-delete "ssh-deploy")
-(autoload 'ssh-deploy-diff-files "ssh-deploy")
+(require 'ssh-deploy)
 
 (defconst ssh-deploy-diff-mode--keywords
   '(
diff --git a/ssh-deploy-test.el b/ssh-deploy-test.el
index 9cfa927..ce507e6 100644
--- a/ssh-deploy-test.el
+++ b/ssh-deploy-test.el
@@ -29,23 +29,8 @@
 
 (autoload 'should "ert")
 
-(autoload 'ssh-deploy-diff-mode "ssh-deploy-diff-mode")
-(autoload 'ssh-deploy--diff-directories-data "ssh-deploy-diff-mode")
-(autoload 'ssh-deploy--diff-files "ssh-deploy")
-(autoload 'ssh-deploy "ssh-deploy")
-(autoload 'ssh-deploy--get-revision-path "ssh-deploy")
-(autoload 'ssh-deploy--file-is-in-path-p "ssh-deploy")
-(autoload 'ssh-deploy--is-not-empty-string-p "ssh-deploy")
-(autoload 'ssh-deploy-download "ssh-deploy")
-(autoload 'ssh-deploy-upload "ssh-deploy")
-(autoload 'ssh-deploy-rename "ssh-deploy")
-(autoload 'ssh-deploy-delete-both "ssh-deploy")
-(autoload 'ssh-deploy-add-after-save-hook "ssh-deploy")
-(autoload 'ssh-deploy-add-after-save-hook "ssh-deploy")
-(autoload 'ssh-deploy-upload-handler "ssh-deploy")
-(autoload 'ssh-deploy--remote-changes-data "ssh-deploy")
-(autoload 'ssh-deploy-download-handler "ssh-deploy")
-(autoload 'ssh-deploy--async-process "ssh-deploy")
+(require 'ssh-deploy)
+(require 'ssh-deploy-diff-mode)
 
 (defun ssh-deploy-test--download (async async-with-threads)
   "Test downloads asynchronously if ASYNC is above zero, with threads if 
ASYNC-WITH-THREADS is above zero."
@@ -276,7 +261,8 @@
            (ssh-deploy-on-explicit-save 1)
            (ssh-deploy-debug 0)
            (ssh-deploy-async async)
-           (ssh-deploy-async-with-threads async-with-threads))
+           (ssh-deploy-async-with-threads async-with-threads)
+           (revision-file (ssh-deploy--get-revision-path file-a 
ssh-deploy-revision-folder)))
 
       ;; Just bypass the linter here
       (when (and ssh-deploy-root-local
@@ -297,14 +283,16 @@
         ;; Verify that both files have equal contents
         (should (equal t (nth 0 (ssh-deploy--diff-files file-a file-b))))
 
+        ;; Modify local revision here
+
         ;; Update should not trigger upload
-        (find-file file-b)
+        (find-file revision-file)
         (insert "Random blob")
         (save-buffer)
         (kill-buffer)
 
         ;; Verify that both files don't have equal contents
-        (should (equal nil (nth 0 (ssh-deploy--diff-files file-a file-b))))
+        (should (equal nil (nth 0 (ssh-deploy--diff-files file-a 
revision-file))))
 
         ;; Remote file should signal change now
         (if (> async 0)
@@ -316,6 +304,22 @@
               (sleep-for 1))
           (should (equal 5 (nth 0 (ssh-deploy--remote-changes-data file-a)))))
 
+        ;; Update should now trigger upload
+        (find-file file-a)
+        (insert "Random blob")
+        (save-buffer)
+        (kill-buffer)
+        
+        ;; Remote file should signal change now
+        (if (> async 0)
+            (progn
+              (ssh-deploy--async-process
+               (lambda() (ssh-deploy--remote-changes-data file-a))
+               (lambda(response) (should (equal 8 (nth 0 response))))
+               async-with-threads)
+              (sleep-for 1))
+          (should (equal 8 (nth 0 (ssh-deploy--remote-changes-data file-a)))))
+
         ;; Open file-a and download remote
         (find-file file-a)
         (ssh-deploy-download-handler)
diff --git a/ssh-deploy.el b/ssh-deploy.el
index 5258406..0c7e0cd 100644
--- a/ssh-deploy.el
+++ b/ssh-deploy.el
@@ -796,7 +796,11 @@
      (when (> verbose 0) (message (nth 1 response))))
     (7
      ;; Remote file has changed in comparison with local file
-     (display-warning 'ssh-deploy (nth 1 response) :warning))))
+     (display-warning 'ssh-deploy (nth 1 response) :warning))
+    (8
+     ;; Remote file has changed in comparison with local revision but not 
local file
+     (copy-file (nth 2 response) (nth 3 response) t t t t)
+     (when (> verbose 0) (message (nth 1 response))))))
 
 (defun ssh-deploy--remote-changes-data (path-local &optional root-local 
root-remote revision-folder exclude-list)
   "Check if a local revision for PATH-LOCAL on ROOT-LOCAL and if remote file 
has changed on ROOT-REMOTE, check for copies in REVISION-FOLDER and skip if 
path is in EXCLUDE-LIST.  Should only return status-code and message."
@@ -822,7 +826,9 @@
 
                           (if (nth 0 (ssh-deploy--diff-files revision-path 
path-remote))
                               (list 4 (format "Remote file '%s' has not 
changed." path-remote) path-local)
-                            (list 5 (format "Remote file '%s' has changed 
compared to local revision, please download or diff." path-remote) path-local 
revision-path))
+                            (if (nth 0 (ssh-deploy--diff-files path-local 
path-remote))
+                                (list 5 (format "Remote file '%s' has changed 
compared to local revision and local file, please download or diff." 
path-remote) path-local revision-path)
+                              (list 8 (format "Remote file '%s' has changed 
compared to local revision but not local file, copied local file to local 
revision." path-remote) path-local revision-path)))
 
                         (if (nth 0 (ssh-deploy--diff-files path-local 
path-remote))
                             (list 6 (format "Remote file '%s' has not changed 
compared to local file, created local revision." path-remote) path-local 
revision-path)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]