I want an analog of git show $REV
/ hg diff -c $REV
/ svn diff -c $REV
in Emacs when I know $REV
.
Currently I open full history via C-x v L
and search for specific revision and then type d
or l
((
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityvc-diff-internal
doesn't show single changeset but always diff between two revisions.
vc-diff-build-argument-list-internal
function used by commands vc-version-diff
and vc-root-version-diff
will ask for revisions to compare.
log-view-diff-common
used to view diff from log view compute previous revision by calling backend for previous revision so we can do the same:
(require 'vc)
(require 'vc-hooks)
(defun my/vc-view-diff-single-rev (rev)
"Show diff for REV."
(interactive "sRevision: ")
(let ((backend (vc-responsible-backend default-directory)))
(when backend
(let ((rev-from (vc-call-backend backend 'previous-revision nil rev)))
(when rev-from
(vc-diff-internal t (list backend nil) rev-from rev))))))
git show $REV
, hg log -p -r $REV
, svn log -p -c $REV
. Calling previous-revision
discloses VC weakness... BTW I looked to the same source code but stopped at necessity to call previous-revision
((
Magit solution:
magit-show-commit
Show the commit at point. If there is no commit at point or with a prefix argument, prompt for a commit.
In VC internals I can't see direct solution for the problem. vc-git-diff
requires fileset, I am unable to get it works:
(vc-git-diff (cadr (vc-deduce-fileset t)) (vc-read-revision "Rev: "))