comparison contrib/mercurial.el @ 1027:cb31576ed3e4

Emacs: fix up hg-log and hg-diff to operate more uniformly.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue, 23 Aug 2005 16:46:10 -0700
parents a5539638c5a3
children b5f0ccad8917
comparison
equal deleted inserted replaced
1026:a5539638c5a3 1027:cb31576ed3e4
796 With a prefix argument, prompt for all of these." 796 With a prefix argument, prompt for all of these."
797 (interactive (list (hg-read-file-name " to diff") 797 (interactive (list (hg-read-file-name " to diff")
798 (hg-read-rev " to start with") 798 (hg-read-rev " to start with")
799 (let ((rev2 (hg-read-rev " to end with" 'working-dir))) 799 (let ((rev2 (hg-read-rev " to end with" 'working-dir)))
800 (and (not (eq rev2 'working-dir)) rev2)))) 800 (and (not (eq rev2 'working-dir)) rev2))))
801 (unless rev1
802 (setq rev1 "-1"))
803 (hg-sync-buffers path) 801 (hg-sync-buffers path)
804 (let ((a-path (hg-abbrev-file-name path)) 802 (let ((a-path (hg-abbrev-file-name path))
803 (r1 (or rev1 "tip"))
805 diff) 804 diff)
806 (hg-view-output ((if (equal rev1 rev2) 805 (hg-view-output ((cond
807 (format "Mercurial: Rev %s of %s" rev1 a-path) 806 ((and (equal r1 "tip") (not rev2))
808 (format "Mercurial: Rev %s to %s of %s" 807 (format "Mercurial: Diff against tip of %s" a-path))
809 rev1 (or rev2 "Current") a-path))) 808 ((equal r1 rev2)
809 (format "Mercurial: Diff of rev %s of %s" r1 a-path))
810 (t
811 (format "Mercurial: Diff from rev %s to %s of %s"
812 r1 (or rev2 "Current") a-path))))
810 (if rev2 813 (if rev2
811 (call-process (hg-binary) nil t nil "diff" "-r" rev1 "-r" rev2 path) 814 (call-process (hg-binary) nil t nil "diff" "-r" r1 "-r" rev2 path)
812 (call-process (hg-binary) nil t nil "diff" "-r" rev1 path)) 815 (call-process (hg-binary) nil t nil "diff" "-r" r1 path))
813 (diff-mode) 816 (diff-mode)
814 (setq diff (not (= (point-min) (point-max)))) 817 (setq diff (not (= (point-min) (point-max))))
815 (font-lock-fontify-buffer)) 818 (font-lock-fontify-buffer))
816 diff)) 819 diff))
817 820
842 (interactive) 845 (interactive)
843 (error "not implemented")) 846 (error "not implemented"))
844 847
845 (defun hg-log (path &optional rev1 rev2) 848 (defun hg-log (path &optional rev1 rev2)
846 "Display the revision history of PATH, between REV1 and REV2. 849 "Display the revision history of PATH, between REV1 and REV2.
847 REV1 defaults to the initial revision, while REV2 defaults to the tip. 850 REV1 defaults to hg-log-limit changes from the tip revision, while
848 With a prefix argument, prompt for each parameter. 851 REV2 defaults to the tip.
849 Variable hg-log-limit controls the number of log entries displayed." 852 With a prefix argument, prompt for each parameter."
850 (interactive (list (hg-read-file-name " to log") 853 (interactive (list (hg-read-file-name " to log")
851 (hg-read-rev " to start with" "-1") 854 (hg-read-rev " to start with" "-1")
852 (hg-read-rev " to end with" (format "-%d" hg-log-limit)))) 855 (hg-read-rev " to end with" (format "-%d" hg-log-limit))))
853 (let ((a-path (hg-abbrev-file-name path))) 856 (let ((a-path (hg-abbrev-file-name path))
854 (hg-view-output ((if (equal rev1 rev2) 857 (r1 (or rev1 (format "-%d" hg-log-limit)))
855 (format "Mercurial: Rev %s of %s" rev1 a-path) 858 (r2 (or rev2 rev1 "-1")))
856 (format "Mercurial: Rev %s to %s of %s" 859 (hg-view-output ((if (equal r1 r2)
857 rev1 (or rev2 "Current") a-path))) 860 (format "Mercurial: Log of rev %s of %s" rev1 a-path)
861 (format "Mercurial: Log from rev %s to %s of %s"
862 r1 r2 a-path)))
858 (if (> (length path) (length (hg-root path))) 863 (if (> (length path) (length (hg-root path)))
859 (call-process (hg-binary) nil t nil "log" "-r" rev1 "-r" rev2 path) 864 (call-process (hg-binary) nil t nil "log" "-r" r1 "-r" r2 path)
860 (call-process (hg-binary) nil t nil "log" "-r" rev1 "-r" rev2)) 865 (call-process (hg-binary) nil t nil "log" "-r" r1 "-r" r2))
861 (font-lock-fontify-buffer)))) 866 (font-lock-fontify-buffer))))
862 867
863 (defun hg-log-repo (path &optional rev1 rev2) 868 (defun hg-log-repo (path &optional rev1 rev2)
864 "Display the revision history of the repository containing PATH. 869 "Display the revision history of the repository containing PATH.
865 History is displayed between REV1, which defaults to the tip, and 870 History is displayed between REV1, which defaults to the tip, and