emacs-31 afda8c2779b: Fix vc-hg-diff arguments to diff vs empty tree
Sean Whitton <[email protected]> Mon, 3 Aug 2026 05:25:44 -0400 (EDT)
| Newsgroups | gmane.emacs.diffs |
|---|---|
| Message-ID | <[email protected]> |
branch: emacs-31 commit afda8c2779b297ada39379a38e0056cb2b21b1fb Author: Aaron L. Zeng <[email protected]> Commit: Sean Whitton <[email protected]> Fix vc-hg-diff arguments to diff vs empty tree * lisp/vc/vc-hg.el (vc-hg-diff): Fix behavior according to backend function specification (bug#81527). * test/lisp/vc/vc-hg-tests.el (vc-hg-diff-revision-arguments): New test. --- lisp/vc/vc-hg.el | 2 +- test/lisp/vc/vc-hg-tests.el | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index c0d92533241..51f353cdc29 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -567,7 +567,7 @@ This requires hg 4.4 or later, for the \"-L\" option of \"hg log\"." (when (and (not newvers) (member oldvers (list working "."))) (setq oldvers nil)) (when (and newvers (not oldvers)) - (setq oldvers working)) + (setq oldvers "null")) (apply #'vc-hg-command (or buffer "*vc-diff*") (if async 'async 1) diff --git a/test/lisp/vc/vc-hg-tests.el b/test/lisp/vc/vc-hg-tests.el index 0216c23eebe..09891f10b22 100644 --- a/test/lisp/vc/vc-hg-tests.el +++ b/test/lisp/vc/vc-hg-tests.el @@ -88,4 +88,21 @@ R foo" ("foo2" added #s(vc-hg-extra-fileinfo renamed-from "foo")) ("bar2" added #s(vc-hg-extra-fileinfo renamed-from "bar"))))) +(ert-deftest vc-hg-diff-revision-arguments () + "Test `vc-hg-diff' revision arguments." + (cl-letf (((symbol-function 'vc-hg-command) #'list) + (vc-hg-diff-switches t)) + ;; REV1 REV2 both nil: diff file against working revision + (should (equal (vc-hg-diff '("foo") nil nil) + '("*vc-diff*" 1 ("foo") "diff"))) + ;; REV1 nil and REV2 non-nil: diff REV2 against empty tree + (should (equal (vc-hg-diff '("foo") nil "22222") + '("*vc-diff*" 1 ("foo") "diff" "-r" "null" "-r" "22222"))) + ;; REV1 non-nil and REV2 nil: diff working copy against older revision + (should (equal (vc-hg-diff '("foo") "11111" nil) + '("*vc-diff*" 1 ("foo") "diff" "-r" "11111"))) + ;; REV1 REV2 both non-nil: diff two revisions + (should (equal (vc-hg-diff '("foo") "11111" "22222") + '("*vc-diff*" 1 ("foo") "diff" "-r" "11111" "-r" "22222"))))) + ;;; vc-hg-tests.el ends here