Function: vc--remove-revisions-from-end
vc--remove-revisions-from-end is a byte-compiled function defined in
vc.el.gz.
Signature
(vc--remove-revisions-from-end REV DELETE PROMPT BACKEND)
Documentation
Delete revisions newer than REV.
DELETE non-nil means to remove the changes from the working tree.
DELETE discard means to silently discard uncommitted changes.
PROMPT non-nil means to always get confirmation. (This is passed by
log-view-uncommit-revisions-from-end and log-view-delete-revisions
because they have single-letter bindings and don't otherwise prompt, so
might be easy to use accidentally.)
BACKEND is the VC backend.
Source Code
;; Defined in /usr/src/emacs/lisp/vc/vc.el.gz
(defun vc--remove-revisions-from-end (rev delete prompt backend)
"Delete revisions newer than REV.
DELETE non-nil means to remove the changes from the working tree.
DELETE `discard' means to silently discard uncommitted changes.
PROMPT non-nil means to always get confirmation. (This is passed by
`log-view-uncommit-revisions-from-end' and `log-view-delete-revisions'
because they have single-letter bindings and don't otherwise prompt, so
might be easy to use accidentally.)
BACKEND is the VC backend."
(let ((backend (or backend (vc-responsible-backend default-directory))))
(unless (eq (vc-call-backend backend 'revision-granularity)
'repository)
(error "Requires VCS with whole-repository revision granularity"))
(unless (vc-find-backend-function backend 'revision-published-p)
(signal 'vc-not-supported (list 'revision-published-p backend)))
;; Rewinding the end of the branch to REV does not in itself mean
;; rewriting public history because a subsequent pull will generally
;; undo the rewinding. Rewinding and then making new commits before
;; syncing with the upstream will necessitate merging, but that's
;; just part of the normal workflow with a distributed VCS.
;; Therefore we don't prompt about deleting published revisions (and
;; so we ignore `vc-allow-rewriting-published-history').
;; We do care about deleting *unpublished* revisions, however,
;; because that could potentially mean losing work permanently.
(when (if (vc-call-backend backend 'revision-published-p
(vc-call-backend backend
'working-revision-symbol))
(and prompt
(not (y-or-n-p
(format "Uncommit revisions newer than %s?"
rev))))
;; FIXME: Actually potentially not all revisions newer than
;; REV would be permanently deleted -- only those which are
;; unpushed. So this prompt is a little misleading.
(not (yes-or-no-p
(format "Permanently delete revisions newer than %s?"
rev))))
(user-error "Aborted"))
(if delete
;; FIXME: As discussed in bug#79408, instead of just failing if
;; the user declines reverting the changes, we would leave
;; behind some sort of conflict for the user to resolve, like we
;; do when there is a merge conflict.
(let ((root (vc-root-dir)))
(when (vc-dir-status-files root nil backend)
(if (eq delete 'discard)
(vc-revert-file root)
(let ((vc-buffer-overriding-fileset `(,backend (,root))))
(vc-revert))))
(vc-call-backend backend 'delete-revisions-from-end rev))
(vc-call-backend backend 'uncommit-revisions-from-end rev))))