##// END OF EJS Templates
Emacs: follow the revision usage policy of "hg diff" command....
FUJIWARA Katsunori -
r2455:ff831123 default
parent child Browse files
Show More
@@ -895,37 +895,54 b' Key bindings'
895 (defun hg-diff (path &optional rev1 rev2)
895 (defun hg-diff (path &optional rev1 rev2)
896 "Show the differences between REV1 and REV2 of PATH.
896 "Show the differences between REV1 and REV2 of PATH.
897 When called interactively, the default behaviour is to treat REV1 as
897 When called interactively, the default behaviour is to treat REV1 as
898 the tip revision, REV2 as the current edited version of the file, and
898 the \"parent\" revision, REV2 as the current edited version of the file, and
899 PATH as the file edited in the current buffer.
899 PATH as the file edited in the current buffer.
900 With a prefix argument, prompt for all of these."
900 With a prefix argument, prompt for all of these."
901 (interactive (list (hg-read-file-name " to diff")
901 (interactive (list (hg-read-file-name " to diff")
902 (hg-read-rev " to start with")
902 (let ((rev1 (hg-read-rev " to start with" 'parent)))
903 (and (not (eq rev1 'parent)) rev1))
903 (let ((rev2 (hg-read-rev " to end with" 'working-dir)))
904 (let ((rev2 (hg-read-rev " to end with" 'working-dir)))
904 (and (not (eq rev2 'working-dir)) rev2))))
905 (and (not (eq rev2 'working-dir)) rev2))))
905 (hg-sync-buffers path)
906 (hg-sync-buffers path)
906 (let ((a-path (hg-abbrev-file-name path))
907 (let ((a-path (hg-abbrev-file-name path))
907 (r1 (or rev1 "tip"))
908 ;; none revision is specified explicitly
909 (none (and (not rev1) (not rev2)))
910 ;; only one revision is specified explicitly
911 (one (or (and (or (equal rev1 rev2) (not rev2)) rev1)
912 (and (not rev1) rev2)))
908 diff)
913 diff)
909 (hg-view-output ((cond
914 (hg-view-output ((cond
910 ((and (equal r1 "tip") (not rev2))
915 (none
911 (format "Mercurial: Diff against tip of %s" a-path))
916 (format "Mercurial: Diff against parent of %s" a-path))
912 ((equal r1 rev2)
917 (one
913 (format "Mercurial: Diff of rev %s of %s" r1 a-path))
918 (format "Mercurial: Diff of rev %s of %s" one a-path))
914 (t
919 (t
915 (format "Mercurial: Diff from rev %s to %s of %s"
920 (format "Mercurial: Diff from rev %s to %s of %s"
916 r1 (or rev2 "Current") a-path))))
921 rev1 rev2 a-path))))
917 (if rev2
922 (cond
918 (call-process (hg-binary) nil t nil "diff" "-r" r1 "-r" rev2 path)
923 (none
919 (call-process (hg-binary) nil t nil "diff" "-r" r1 path))
924 (call-process (hg-binary) nil t nil "diff" path))
925 (one
926 (call-process (hg-binary) nil t nil "diff" "-r" one path))
927 (t
928 (call-process (hg-binary) nil t nil "diff" "-r" rev1 "-r" rev2 path)))
920 (diff-mode)
929 (diff-mode)
921 (setq diff (not (= (point-min) (point-max))))
930 (setq diff (not (= (point-min) (point-max))))
922 (font-lock-fontify-buffer))
931 (font-lock-fontify-buffer))
923 diff))
932 diff))
924
933
925 (defun hg-diff-repo ()
934 (defun hg-diff-repo (path &optional rev1 rev2)
926 "Show the differences between the working copy and the tip revision."
935 "Show the differences between REV1 and REV2 of repository containing PATH.
927 (interactive)
936 When called interactively, the default behaviour is to treat REV1 as
928 (hg-diff (hg-root)))
937 the \"parent\" revision, REV2 as the current edited version of the file, and
938 PATH as the `hg-root' of the current buffer.
939 With a prefix argument, prompt for all of these."
940 (interactive (list (hg-read-file-name " to diff")
941 (let ((rev1 (hg-read-rev " to start with" 'parent)))
942 (and (not (eq rev1 'parent)) rev1))
943 (let ((rev2 (hg-read-rev " to end with" 'working-dir)))
944 (and (not (eq rev2 'working-dir)) rev2))))
945 (hg-diff (hg-root path) rev1 rev2))
929
946
930 (defun hg-forget (path)
947 (defun hg-forget (path)
931 "Lose track of PATH, which has been added, but not yet committed.
948 "Lose track of PATH, which has been added, but not yet committed.
General Comments 0
You need to be logged in to leave comments. Login now