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

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

[elpa] externals/vc-got a96df0e 056/145: provide unregister and delete-f


From: ELPA Syncer
Subject: [elpa] externals/vc-got a96df0e 056/145: provide unregister and delete-file commands (#7)
Date: Thu, 9 Sep 2021 15:58:32 -0400 (EDT)

branch: externals/vc-got
commit a96df0e8b9c0b1f0170a9d1f4a3a17c35d0d0529
Author: Timo Myyrä <timo.myyra@bittivirhe.fi>
Commit: GitHub <noreply@github.com>

    provide unregister and delete-file commands (#7)
    
    * provide unregister and delete-file commands
    
    * re-order functions
    
    * avoid error 'vc-dir is read-only' on file deletion
    
    * use temp buffer around got rm call, we don't need the output
---
 vc-got.el | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/vc-got.el b/vc-got.el
index 261eeb1..2c991ad 100755
--- a/vc-got.el
+++ b/vc-got.el
@@ -48,8 +48,7 @@
 ;; * register                           DONE
 ;; - responsible-p                      DONE
 ;; - receive-file                       NOT IMPLEMENTED
-;; - unregister                         NOT IMPLEMENTED
-;;      use remove?
+;; - unregister                         DONE
 ;; * checkin                            DONE
 ;; * find-revision                      DONE
 ;; * checkout                           NOT IMPLEMENTED
@@ -101,7 +100,7 @@
 ;; - next-revision                      DONE
 ;; - log-edit-mode                      NOT IMPLEMENTED
 ;; - check-headers                      NOT IMPLEMENTED
-;; - delete-file                        NOT IMPLEMENTED
+;; - delete-file                        DONE
 ;; - rename-file                        NOT IMPLEMENTED
 ;; - find-file-hook                     NOT IMPLEMENTED
 ;; - extra-menu                         NOT IMPLEMENTED
@@ -326,6 +325,15 @@ DIR-OR-FILE."
          (append (vc-switches 'got 'diff)
                  (mapcar #'file-relative-name args))))
 
+(defun vc-got--remove (file &optional force keep-local)
+  "Internal helper to removing FILE from got."
+  (vc-got-with-worktree (or file default-directory)
+    (with-temp-buffer
+      (vc-got--call "remove"
+                    (when force "-f")
+                    (when keep-local "-k")
+                    file))))
+
 
 ;; Backend properties
 
@@ -434,6 +442,14 @@ DIR-OR-FILE."
   "Register FILES, passing `vc-register-switches' to the backend command."
   (vc-got--add files))
 
+(defun vc-got-unregister (file)
+  "Unregister given FILE, i.e. remove file if it was versioned
+file or revert it if it was added but not committed."
+  (pcase ((status (cdr (vc-got--parse-status (vc-got--status file)))))
+    ('unregistered nil) ;; no need for action
+    ((or 'added 'missing) (vc-got--revert file))
+    (default (vc-got--remove file))))
+
 (defalias 'vc-got-responsible-p #'vc-got-root)
 
 (defun vc-got-checkin (files comment &optional _rev)
@@ -619,6 +635,10 @@ Value is returned as floating point fractional number of 
days."
       (when (looking-at vc-got--commit-re)
         (match-string-no-properties 1)))))
 
+(defun vc-got-delete-file (file)
+  "Delete FILE locally and mark it deleted in work tree."
+  (vc-got--remove file t))
+
 (defun vc-got-conflicted-files (dir)
   "Return the list of files with conflicts in directory DIR."
   (let* ((root (vc-got-root dir))



reply via email to

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