diff options
author | Philip Kaludercic <philipk@posteo.net> | 2022-11-04 18:57:45 +0100 |
---|---|---|
committer | Philip Kaludercic <philipk@posteo.net> | 2022-11-04 18:57:45 +0100 |
commit | 5fa2f116799b8a7c17ff6eedd6e1b1af077c116b (patch) | |
tree | b42de964147653e6b0e6e5f2082618bf3634acc2 /lisp/vc | |
parent | 616aa23d8a130a664a2ce3bb05f3518ce0f5a018 (diff) | |
parent | f762c5bb2c96ec9608807bf3c1e3655fb59fc4d6 (diff) | |
download | emacs-5fa2f116799b8a7c17ff6eedd6e1b1af077c116b.tar.gz emacs-5fa2f116799b8a7c17ff6eedd6e1b1af077c116b.tar.bz2 emacs-5fa2f116799b8a7c17ff6eedd6e1b1af077c116b.zip |
Merge branch 'feature/package+vc'
Diffstat (limited to 'lisp/vc')
-rw-r--r-- | lisp/vc/vc-bzr.el | 6 | ||||
-rw-r--r-- | lisp/vc/vc-git.el | 19 | ||||
-rw-r--r-- | lisp/vc/vc-hg.el | 6 | ||||
-rw-r--r-- | lisp/vc/vc-svn.el | 7 | ||||
-rw-r--r-- | lisp/vc/vc.el | 51 |
5 files changed, 89 insertions, 0 deletions
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el index 6f77f995554..8f00441e816 100644 --- a/lisp/vc/vc-bzr.el +++ b/lisp/vc/vc-bzr.el @@ -532,6 +532,12 @@ in the branch repository (or whose status not be determined)." (add-hook 'after-save-hook #'vc-bzr-resolve-when-done nil t) (vc-message-unresolved-conflicts buffer-file-name))) +(defun vc-bzr-clone (remote directory rev) + (if rev + (vc-bzr-command nil 0 '() "branch" "-r" rev remote directory) + (vc-bzr-command nil 0 '() "branch" remote directory)) + directory) + (defun vc-bzr-version-dirstate (dir) "Try to return as a string the bzr revision ID of directory DIR. This uses the dirstate file's parent revision entry. diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 3c6afec0378..376892c7206 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1268,6 +1268,12 @@ This prompts for a branch to merge from." (add-hook 'after-save-hook #'vc-git-resolve-when-done nil 'local)) (vc-message-unresolved-conflicts buffer-file-name))) +(defun vc-git-clone (remote directory rev) + (if rev + (vc-git--out-ok "clone" "--branch" rev remote directory) + (vc-git--out-ok "clone" remote directory)) + directory) + ;;; HISTORY FUNCTIONS (autoload 'vc-setup-buffer "vc-dispatcher") @@ -1626,6 +1632,19 @@ This requires git 1.8.4 or later, for the \"-L\" option of \"git log\"." (expand-file-name fname (vc-git-root default-directory)))) revision))))) +(defun vc-git-last-change (file line) + (vc-buffer-sync) + (let ((file (file-relative-name file (vc-git-root (buffer-file-name))))) + (with-temp-buffer + (when (vc-git--out-ok + "blame" "--porcelain" + (format "-L%d,+1" line) + file) + (goto-char (point-min)) + (save-match-data + (when (looking-at "\\`\\([[:alnum:]]+\\)[[:space:]]+") + (match-string 1))))))) + ;;; TAG/BRANCH SYSTEM (declare-function vc-read-revision "vc" diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 1b1c1683dd5..90903255e02 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -1266,6 +1266,12 @@ REV is the revision to check out into WORKFILE." (add-hook 'after-save-hook #'vc-hg-resolve-when-done nil t) (vc-message-unresolved-conflicts buffer-file-name))) +(defun vc-hg-clone (remote directory rev) + (if rev + (vc-hg-command nil 0 '() "clone" "--rev" rev remote directory) + (vc-hg-command nil 0 '() "clone" remote directory)) + + directory) ;; Modeled after the similar function in vc-bzr.el (defun vc-hg-revert (file &optional contents-done) diff --git a/lisp/vc/vc-svn.el b/lisp/vc/vc-svn.el index b9ea8f15788..1b43ca57872 100644 --- a/lisp/vc/vc-svn.el +++ b/lisp/vc/vc-svn.el @@ -817,6 +817,13 @@ Set file properties accordingly. If FILENAME is non-nil, return its status." "info" "--show-item" "repos-root-url") (buffer-substring-no-properties (point-min) (1- (point-max)))))) +(defun vc-svn-clone (remote directory rev) + (if rev + (vc-svn-command nil 0 '() "checkout" "--revision" rev remote directory) + (vc-svn-command nil 0 '() "checkout" remote directory)) + + (file-name-concat directory "trunk")) + (provide 'vc-svn) ;;; vc-svn.el ends here diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 3e78b8cfe96..513fbb23fee 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -448,6 +448,11 @@ ;; - mergebase (rev1 &optional rev2) ;; ;; Return the common ancestor between REV1 and REV2 revisions. +;; +;; - last-change (file line) +;; +;; Return the most recent revision of FILE that made a change +;; on LINE. ;; TAG/BRANCH SYSTEM ;; @@ -584,6 +589,15 @@ ;; buffer should be inserted into an inline patch. If the two last ;; properties are omitted, `point-min' and `point-max' will ;; respectively be used instead. +;; +;; - clone (remote directory rev) +;; +;; Attempt to clone a REMOTE repository, into a local DIRECTORY. +;; Returns a string with the directory with the contents of the +;; repository if successful, otherwise nil. With a non-nil value +;; for REV the backend will attempt to check out a specific +;; revision, if possible without first checking out the default +;; branch. ;;; Changes from the pre-25.1 API: ;; @@ -3551,6 +3565,43 @@ to provide the `find-revision' operation instead." (interactive) (vc-call-backend (vc-backend buffer-file-name) 'check-headers)) +(defun vc-clone (remote &optional backend directory rev) + "Use BACKEND to clone REMOTE into DIRECTORY. +If successful, returns the a string with the directory of the +checkout. If BACKEND is nil, iterate through every known backend +in `vc-handled-backends' until one succeeds. If REV is non-nil, +it indicates a specific revision to check out." + (unless directory + (setq directory default-directory)) + (if backend + (progn + (unless (memq backend vc-handled-backends) + (error "Unknown VC backend %s" backend)) + (vc-call-backend backend 'clone remote directory rev)) + (catch 'ok + (dolist (backend vc-handled-backends) + (ignore-error vc-not-supported + (when-let ((res (vc-call-backend + backend 'clone + remote directory rev))) + (throw 'ok res))))))) + +(declare-function log-view-current-tag "log-view" (&optional pos)) +(defun vc-default-last-change (_backend file line) + "Default `last-change' implementation. +It returns the last revision that changed LINE number in FILE." + (unless (file-exists-p file) + (signal 'file-error "File doesn't exist")) + (with-temp-buffer + (vc-call-backend (vc-backend file) 'annotate-command + file (current-buffer)) + (goto-char (point-min)) + (forward-line (1- line)) + (let ((rev (vc-call-backend + (vc-backend file) + 'annotate-extract-revision-at-line))) + (if (consp rev) (car rev) rev)))) + ;; These things should probably be generally available |