Function: vc-retrieve-tag

vc-retrieve-tag is an autoloaded, interactive and byte-compiled function defined in vc.el.gz.

Signature

(vc-retrieve-tag DIR NAME &optional BRANCHP)

Documentation

For each file in or below DIR, retrieve their version identified by tag NAME.

NAME can name a branch, in which case this command will switch to the named branch in the directory DIR. Interactively, prompt for DIR only for VCS that works at file level; otherwise use the root directory of the current buffer's VC tree. If NAME is empty, it refers to the latest revisions of the current branch. If locking is used for the files in DIR, then there must not be any locked files at or below DIR (but if NAME is empty, locked files are allowed and simply skipped). If BRANCHP is non-nil (interactively, the prefix argument), switch to the branch and check out and update the files to their version on that branch. In this case NAME may not be empty. This function runs the hook vc-retrieve-tag-hook when finished.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc.el.gz
;;;###autoload
(defun vc-retrieve-tag (dir name &optional branchp)
  "For each file in or below DIR, retrieve their version identified by tag NAME.
NAME can name a branch, in which case this command will switch to the
named branch in the directory DIR.
Interactively, prompt for DIR only for VCS that works at file level;
otherwise use the root directory of the current buffer's VC tree.
If NAME is empty, it refers to the latest revisions of the current branch.
If locking is used for the files in DIR, then there must not be any
locked files at or below DIR (but if NAME is empty, locked files are
allowed and simply skipped).
If BRANCHP is non-nil (interactively, the prefix argument), switch to the
branch and check out and update the files to their version on that branch.
In this case NAME may not be empty.
This function runs the hook `vc-retrieve-tag-hook' when finished."
  (interactive
   (let* ((granularity
           (vc-call-backend (vc-responsible-backend default-directory)
                            'revision-granularity))
          (dir
           (if (eq granularity 'repository)
               ;; For VC's that do not work at file level, it's pointless
               ;; to ask for a directory, branches are created at repository level.
               ;; XXX: Either we call expand-file-name here, or use
               ;; file-in-directory-p inside vc-resynch-buffers-in-directory.
               (expand-file-name (vc-root-dir))
             (read-directory-name "Directory: " default-directory nil t))))
     (list dir
           (vc-read-revision (if current-prefix-arg
                                 "Switch to branch: "
                               (format-prompt "Tag name to retrieve"
                                              "latest revisions"))
                             (list dir)
                             (vc-responsible-backend dir))
           current-prefix-arg)))
  (unless (or (not branchp) (and name (not (string-empty-p name))))
    (user-error "Branch name required"))
  (let* ((backend (vc-responsible-backend dir))
         (update (when (vc-call-backend backend 'update-on-retrieve-tag)
                   (yes-or-no-p "Update any affected buffers? ")))
	 (msg (if (or (not name) (string= name ""))
		  (format "Updating %s... " (abbreviate-file-name dir))
                (format "Retrieving %s %s into %s... "
                        (if branchp "branch" "tag")
                        name (abbreviate-file-name dir)))))
    (message "%s" msg)
    (vc-call-backend backend 'retrieve-tag dir name update)
    (vc-resynch-buffer dir t t t)
    (run-hooks 'vc-retrieve-tag-hook)
    (message "%s" (concat msg "done"))))