merge emacs changes.
--- a/contrib/mercurial.el
+++ b/contrib/mercurial.el
@@ -380,7 +380,7 @@ Handle frickin' frackin' gratuitous even
(save-excursion
(while hg-prev-buffer
(set-buffer hg-prev-buffer))
- (let ((path (or default (buffer-file-name))))
+ (let ((path (or default (buffer-file-name) default-directory)))
(if (or (not path) current-prefix-arg)
(expand-file-name
(eval (list* 'read-file-name
@@ -712,7 +712,8 @@ code by typing `M-x find-library mercuri
(let ((pos (point)))
(insert (documentation 'hg-mode))
(goto-char pos)
- (kill-line))
+ (end-of-line 1)
+ (delete-region pos (point)))
(cd (hg-root))))
(defun hg-add (path)
@@ -901,38 +902,55 @@ Key bindings
(defun hg-diff (path &optional rev1 rev2)
"Show the differences between REV1 and REV2 of PATH.
When called interactively, the default behaviour is to treat REV1 as
-the tip revision, REV2 as the current edited version of the file, and
+the \"parent\" revision, REV2 as the current edited version of the file, and
PATH as the file edited in the current buffer.
With a prefix argument, prompt for all of these."
(interactive (list (hg-read-file-name " to diff")
- (hg-read-rev " to start with")
+ (let ((rev1 (hg-read-rev " to start with" 'parent)))
+ (and (not (eq rev1 'parent)) rev1))
(let ((rev2 (hg-read-rev " to end with" 'working-dir)))
(and (not (eq rev2 'working-dir)) rev2))))
(hg-sync-buffers path)
(let ((a-path (hg-abbrev-file-name path))
- (r1 (or rev1 "tip"))
+ ;; none revision is specified explicitly
+ (none (and (not rev1) (not rev2)))
+ ;; only one revision is specified explicitly
+ (one (or (and (or (equal rev1 rev2) (not rev2)) rev1)
+ (and (not rev1) rev2)))
diff)
(hg-view-output ((cond
- ((and (equal r1 "tip") (not rev2))
- (format "Mercurial: Diff against tip of %s" a-path))
- ((equal r1 rev2)
- (format "Mercurial: Diff of rev %s of %s" r1 a-path))
+ (none
+ (format "Mercurial: Diff against parent of %s" a-path))
+ (one
+ (format "Mercurial: Diff of rev %s of %s" one a-path))
(t
(format "Mercurial: Diff from rev %s to %s of %s"
- r1 (or rev2 "Current") a-path))))
- (if rev2
- (call-process (hg-binary) nil t nil "diff" "-r" r1 "-r" rev2 path)
- (call-process (hg-binary) nil t nil "diff" "-r" r1 path))
+ rev1 rev2 a-path))))
+ (cond
+ (none
+ (call-process (hg-binary) nil t nil "diff" path))
+ (one
+ (call-process (hg-binary) nil t nil "diff" "-r" one path))
+ (t
+ (call-process (hg-binary) nil t nil "diff" "-r" rev1 "-r" rev2 path)))
(diff-mode)
(setq diff (not (= (point-min) (point-max))))
(font-lock-fontify-buffer)
(cd (hg-root path)))
diff))
-(defun hg-diff-repo ()
- "Show the differences between the working copy and the tip revision."
- (interactive)
- (hg-diff (hg-root)))
+(defun hg-diff-repo (path &optional rev1 rev2)
+ "Show the differences between REV1 and REV2 of repository containing PATH.
+When called interactively, the default behaviour is to treat REV1 as
+the \"parent\" revision, REV2 as the current edited version of the file, and
+PATH as the `hg-root' of the current buffer.
+With a prefix argument, prompt for all of these."
+ (interactive (list (hg-read-file-name " to diff")
+ (let ((rev1 (hg-read-rev " to start with" 'parent)))
+ (and (not (eq rev1 'parent)) rev1))
+ (let ((rev2 (hg-read-rev " to end with" 'working-dir)))
+ (and (not (eq rev2 'working-dir)) rev2))))
+ (hg-diff (hg-root path) rev1 rev2))
(defun hg-forget (path)
"Lose track of PATH, which has been added, but not yet committed.
@@ -971,8 +989,8 @@ With a prefix argument, prompt for the p
(defun hg-log-mode ()
"Mode for viewing a Mercurial change log."
(goto-char (point-min))
- (when (looking-at "^searching for changes")
- (kill-entire-line))
+ (when (looking-at "^searching for changes.*$")
+ (delete-region (match-beginning 0) (match-end 0)))
(run-hooks 'hg-log-mode-hook))
(defun hg-log (path &optional rev1 rev2 log-limit)
@@ -1101,7 +1119,11 @@ prompts for a path to check."
(interactive (list (hg-read-file-name)))
(if (or path (not hg-root))
(let ((root (do ((prev nil dir)
- (dir (file-name-directory (or path buffer-file-name ""))
+ (dir (file-name-directory
+ (or
+ path
+ buffer-file-name
+ (expand-file-name default-directory)))
(file-name-directory (directory-file-name dir))))
((equal prev dir))
(when (file-directory-p (concat dir ".hg"))