Commit Diff


commit - c27df03ea824ff238691d3e4c20f662611e3fe10
commit + a96df0e8b9c0b1f0170a9d1f4a3a17c35d0d0529
blob - 261eeb11b2a6160b351b36d662c6e398d8fefad1
blob + 2c991ad02c071c26b8d9d099e1cae7e34f4a5582
--- vc-got.el
+++ 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
@@ -325,6 +324,15 @@ DIR-OR-FILE."
   (apply #'vc-got--call "diff"
          (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
@@ -433,6 +441,14 @@ DIR-OR-FILE."
 (defun vc-got-register (files &optional _comment)
   "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)
 
@@ -619,6 +635,10 @@ Value is returned as floating point fractional number 
       (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))