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

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

[elpa] externals/ssh-deploy 9c73fef 110/133: Added support for asynchron


From: Stefan Monnier
Subject: [elpa] externals/ssh-deploy 9c73fef 110/133: Added support for asynchronous file difference check
Date: Sat, 27 Mar 2021 14:48:54 -0400 (EDT)

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

    Added support for asynchronous file difference check
---
 ssh-deploy-test.el | 24 +++++++++++-------------
 ssh-deploy.el      | 34 +++++++++++++++++++++++++---------
 2 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/ssh-deploy-test.el b/ssh-deploy-test.el
index e10443a..6a62d13 100644
--- a/ssh-deploy-test.el
+++ b/ssh-deploy-test.el
@@ -1,6 +1,6 @@
 ;;; ssh-deploy-test.el --- Unit and integration tests for ssh-deploy.  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2017-2018  Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019  Free Software Foundation, Inc.
 
 ;; This file is not part of GNU Emacs.
 
@@ -29,11 +29,9 @@
 
 (autoload 'should "ert")
 
-(autoload 'ediff-same-file-contents "ediff-util")
-
 (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")
@@ -94,7 +92,7 @@
           (sleep-for 1))
 
         ;; Verify that both files have equal contents
-        (should (equal t (ediff-same-file-contents file-a file-b)))
+        (should (equal t (nth 0 (ssh-deploy--diff-files file-a file-b))))
 
         (delete-file file-b)
         (delete-file file-a)))
@@ -223,7 +221,7 @@
           (sleep-for 1))
 
         ;; Verify that both files have equal contents
-        (should (equal t (ediff-same-file-contents file-a file-b)))
+        (should (equal t (nth 0 (ssh-deploy--diff-files file-a file-b))))
 
         ;; Turn of automatic uploads
         (let ((ssh-deploy-on-explicit-save 0))
@@ -237,7 +235,7 @@
               (sleep-for 1))
 
             ;; Verify that both files have equal contents
-            (should (equal nil (ediff-same-file-contents file-a file-b)))
+            (should (equal nil (nth 0 (ssh-deploy--diff-files file-a file-b))))
 
             (ssh-deploy-upload-handler)
             (when (> async 0)
@@ -245,7 +243,7 @@
             (kill-buffer)
 
             ;; Verify that both files have equal contents
-            (should (equal t (ediff-same-file-contents file-a file-b)))
+            (should (equal t (nth 0 (ssh-deploy--diff-files file-a file-b))))
 
             ;; Delete both test files
             (delete-file file-b)
@@ -297,7 +295,7 @@
         (kill-buffer)
 
         ;; Verify that both files have equal contents
-        (should (equal t (ediff-same-file-contents file-a file-b)))
+        (should (equal t (nth 0 (ssh-deploy--diff-files file-a file-b))))
 
         ;; Update should not trigger upload
         (find-file file-b)
@@ -306,7 +304,7 @@
         (kill-buffer)
 
         ;; Verify that both files don't have equal contents
-        (should (equal nil (ediff-same-file-contents file-a file-b)))
+        (should (equal nil (nth 0 (ssh-deploy--diff-files file-a file-b))))
 
         ;; Remote file should signal change now
         (if (> async 0)
@@ -394,7 +392,7 @@
         (kill-buffer)
 
         ;; Verify that both files have equal contents
-        (should (equal t (ediff-same-file-contents file-a-1 file-b-1)))
+        (should (equal t (nth 0 (ssh-deploy--diff-files file-a-1 file-b-1))))
 
         ;; Create file 2
         (find-file file-a-2)
@@ -405,7 +403,7 @@
         (kill-buffer)
 
         ;; Verify that both files have equal contents
-        (should (equal t (ediff-same-file-contents file-a-2 file-b-2)))
+        (should (equal t (nth 0 (ssh-deploy--diff-files file-a-2 file-b-2))))
 
         ;; Both files should equal
         (should (equal
@@ -419,7 +417,7 @@
         (kill-buffer)
 
         ;; Verify that both files have equal contents
-        (should (equal nil (ediff-same-file-contents file-a-2 file-b-2)))
+        (should (equal nil (nth 0 (ssh-deploy--diff-files file-a-2 file-b-2))))
 
         ;; Both files should equal
         (should (equal
diff --git a/ssh-deploy.el b/ssh-deploy.el
index 8112354..7c0c4c0 100644
--- a/ssh-deploy.el
+++ b/ssh-deploy.el
@@ -5,8 +5,8 @@
 ;; Author: Christian Johansson <christian@cvj.se>
 ;; Maintainer: Christian Johansson <christian@cvj.se>
 ;; Created: 5 Jul 2016
-;; Modified: 27 Apr 2019
-;; Version: 3.1.2
+;; Modified: 2 May 2019
+;; Version: 3.1.3
 ;; Keywords: tools, convenience
 ;; URL: https://github.com/cjohansson/emacs-ssh-deploy
 
@@ -692,6 +692,10 @@
     (set (make-local-variable 'ssh-deploy-automatically-detect-remote-changes) 
remote-changes)
     (set (make-local-variable 'ssh-deploy-exclude-list) exclude-list)))
 
+(defun ssh-deploy--diff-files (file-a file-b)
+  "Check difference between FILE-A and FILE-B."
+  (let ((result (ediff-same-file-contents file-a file-b)))
+    (list result file-a file-b)))
 
 ;; PUBLIC functions
 ;;
@@ -699,14 +703,26 @@
 ;; these functions MUST only use module variables as fall-backs for missing 
arguments.
 
 
-;; TODO Add support for async version of this function
 ;;;###autoload
-(defun ssh-deploy-diff-files (file-a file-b)
-  "Find difference between FILE-A and FILE-B."
+(defun ssh-deploy-diff-files (file-a file-b &optional async async-with-threads)
+  "Find difference between FILE-A and FILE-B, do it asynchronous if ASYNC is 
aboe zero and use threads if ASYNC-WITH-THREADS is above zero."
   (message "Comparing file '%s' to '%s'.." file-a file-b)
-  (if (ediff-same-file-contents file-a file-b)
-      (message "Files have identical contents.")
-    (ediff file-a file-b)))
+  (let ((async (or async ssh-deploy-async))
+        (async-with-threads (or async-with-threads 
ssh-deploy-async-with-threads)))
+    (if (> async 1)
+        (ssh-deploy--async-process
+         (lambda() (ssh-deploy--diff-files file-a file-b))
+         (lambda(result)
+           (if (nth 0 result)
+               (message "File '%s' and '%s' have identical contents. 
(asynchronously)" (nth 1 result) (nth 2 result))
+             (message "File '%s' and '%s' does not have identical contents, 
launching ediff.. (asynchronously)" file-a file-b)
+             (ediff file-a file-b)))
+         async-with-threads)
+      (let ((result (ssh-deploy--diff-files file-a file-b)))
+        (if (nth 0 result)
+            (message "File '%s' and '%s' have identical contents. 
(synchronously)" (nth 1 result) (nth 2 result))
+          (message "File '%s' and '%s' does not have identical contents, 
launching ediff.. (synchronously)" file-a file-b)
+          (ediff file-a file-b))))))
 
 ;;;###autoload
 
@@ -1024,7 +1040,7 @@
     (if (and (ssh-deploy--file-is-in-path-p path-local root-local)
              (ssh-deploy--file-is-included-p path-local exclude-list))
         (if file-or-directory
-            (ssh-deploy-diff-files path-local path-remote)
+            (ssh-deploy-diff-files path-local path-remote async 
async-with-threads)
           (ssh-deploy-diff-directories path-local path-remote on-explicit-save 
debug async async-with-threads revision-folder remote-changes exclude-list))
       (when debug (message "Path '%s' is not in the root '%s' or is excluded 
from it." path-local root-local)))))
 



reply via email to

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