##// END OF EJS Templates
errors: remove unnecessary varargs handling from OutOfBandError...
errors: remove unnecessary varargs handling from OutOfBandError In my recent D10465, I moved some code over from scmutil into `OutOfBandError.__init__`. The code was written to deal with an arbitrary number of `message` arguments to the constructor. It turns out that we only ever pass 0 or 1. Given that, let's simplify it. Differential Revision: https://phab.mercurial-scm.org/D10483

File last commit:

r17533:927d704d default
r47743:abd18d63 default
Show More
mercurial.el
1293 lines | 43.2 KiB | text/x-common-lisp | EmacsLispLexer
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 ;;; mercurial.el --- Emacs support for the Mercurial distributed SCM
Bryan O'Sullivan
mercurial.el: get rid of unportable, unperformant use of replace-regexp.
r2997 ;; Copyright (C) 2005, 2006 Bryan O'Sullivan
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
;; Author: Bryan O'Sullivan <bos@serpentine.com>
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 ;; mercurial.el is free software; you can redistribute it and/or
Martin Geisler
mercurial.el: add forgotten version number...
r10268 ;; modify it under the terms of the GNU General Public License version
;; 2 or any later version.
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 ;; mercurial.el is distributed in the hope that it will be useful, but
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 ;; along with mercurial.el, GNU Emacs, or XEmacs; see the file COPYING
Martin Geisler
Remove FSF mailing address from GPL headers...
r15782 ;; (`C-h C-l'). If not, see <http://www.gnu.org/licenses/>.
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
;;; Commentary:
bos@serpentine.internal.keyresearch.com
Emacs: improved GNU Emacs support.
r1004 ;; mercurial.el builds upon Emacs's VC mode to provide flexible
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 ;; integration with the Mercurial distributed SCM tool.
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 ;; To get going as quickly as possible, load mercurial.el into Emacs and
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 ;; type `C-c h h'; this runs hg-help-overview, which prints a helpful
;; usage overview.
;; Much of the inspiration for mercurial.el comes from Rajesh
;; Vaidheeswarran's excellent p4.el, which does an admirably thorough
;; job for the commercial Perforce SCM product. In fact, substantial
;; chunks of code are adapted from p4.el.
bos@serpentine.internal.keyresearch.com
Emacs: improved GNU Emacs support.
r1004 ;; This code has been developed under XEmacs 21.5, and may not work as
;; well under GNU Emacs (albeit tested under 21.4). Patches to
;; enhance the portability of this code, fix bugs, and add features
Bryan O'Sullivan
mercurial.el: note new Emacs VC mode support
r6390 ;; are most welcome.
;; As of version 22.3, GNU Emacs's VC mode has direct support for
;; Mercurial, so this package may not prove as useful there.
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
;; Please send problem reports and suggestions to bos@serpentine.com.
;;; Code:
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (eval-when-compile (require 'cl))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 (require 'diff-mode)
(require 'easymenu)
bos@serpentine.internal.keyresearch.com
Sync buffers prior to doing a diff.
r1024 (require 'executable)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 (require 'vc)
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (defmacro hg-feature-cond (&rest clauses)
"Test CLAUSES for feature at compile time.
Each clause is (FEATURE BODY...)."
(dolist (x clauses)
(let ((feature (car x))
(body (cdr x)))
(when (or (eq feature t)
(featurep feature))
(return (cons 'progn body))))))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
;;; XEmacs has view-less, while GNU Emacs has view. Joy.
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (hg-feature-cond
(xemacs (require 'view-less))
(t (require 'view)))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
;;; Variables accessible through the custom system.
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (defgroup mercurial nil
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 "Mercurial distributed SCM."
:group 'tools)
(defcustom hg-binary
bos@serpentine.internal.keyresearch.com
Emacs: search for hg in path before looking in funny places.
r1011 (or (executable-find "hg")
(dolist (path '("~/bin/hg" "/usr/bin/hg" "/usr/local/bin/hg"))
(when (file-executable-p path)
(return path))))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 "The path to Mercurial's hg executable."
:type '(file :must-match t)
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 :group 'mercurial)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
(defcustom hg-mode-hook nil
"Hook run when a buffer enters hg-mode."
:type 'sexp
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 :group 'mercurial)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (defcustom hg-commit-mode-hook nil
"Hook run when a buffer is created to prepare a commit."
:type 'sexp
:group 'mercurial)
(defcustom hg-pre-commit-hook nil
"Hook run before a commit is performed.
If you want to prevent the commit from proceeding, raise an error."
:type 'sexp
:group 'mercurial)
Bryan O'Sullivan
Emacs: implement hg-incoming, hg-outgoing and hg-push.
r1029 (defcustom hg-log-mode-hook nil
"Hook run after a buffer is filled with log information."
:type 'sexp
:group 'mercurial)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 (defcustom hg-global-prefix "\C-ch"
"The global prefix for Mercurial keymap bindings."
:type 'sexp
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 :group 'mercurial)
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 (defcustom hg-commit-allow-empty-message nil
"Whether to allow changes to be committed with empty descriptions."
:type 'boolean
:group 'mercurial)
(defcustom hg-commit-allow-empty-file-list nil
"Whether to allow changes to be committed without any modified files."
:type 'boolean
:group 'mercurial)
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (defcustom hg-rev-completion-limit 100
"The maximum number of revisions that hg-read-rev will offer to complete.
This affects memory usage and performance when prompting for revisions
in a repository with a lot of history."
:type 'integer
:group 'mercurial)
(defcustom hg-log-limit 50
"The maximum number of revisions that hg-log will display."
:type 'integer
:group 'mercurial)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995 (defcustom hg-update-modeline t
"Whether to update the modeline with the status of a file after every save.
Set this to nil on platforms with poor process management, such as Windows."
:type 'boolean
:group 'mercurial)
Bryan O'Sullivan
Emacs: implement hg-incoming, hg-outgoing and hg-push.
r1029 (defcustom hg-incoming-repository "default"
"The repository from which changes are pulled from by default.
This should be a symbolic repository name, since it is used for all
repository-related commands."
:type 'string
:group 'mercurial)
Azhagu Selvan SP
mercurial.el: fix hg-outgoing path when 'default-push' is not defined...
r12796 (defcustom hg-outgoing-repository ""
Bryan O'Sullivan
Emacs: implement hg-incoming, hg-outgoing and hg-push.
r1029 "The repository to which changes are pushed to by default.
This should be a symbolic repository name, since it is used for all
repository-related commands."
:type 'string
:group 'mercurial)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
;;; Other variables.
(defvar hg-mode nil
"Is this file managed by Mercurial?")
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (make-variable-buffer-local 'hg-mode)
(put 'hg-mode 'permanent-local t)
(defvar hg-status nil)
(make-variable-buffer-local 'hg-status)
(put 'hg-status 'permanent-local t)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (defvar hg-prev-buffer nil)
(make-variable-buffer-local 'hg-prev-buffer)
(put 'hg-prev-buffer 'permanent-local t)
(defvar hg-root nil)
(make-variable-buffer-local 'hg-root)
(put 'hg-root 'permanent-local t)
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (defvar hg-view-mode nil)
(make-variable-buffer-local 'hg-view-mode)
(put 'hg-view-mode 'permanent-local t)
(defvar hg-view-file-name nil)
(make-variable-buffer-local 'hg-view-file-name)
(put 'hg-view-file-name 'permanent-local t)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 (defvar hg-output-buffer-name "*Hg*"
"The name to use for Mercurial output buffers.")
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (defvar hg-file-history nil)
Bryan O'Sullivan
Emacs: implement hg-incoming, hg-outgoing and hg-push.
r1029 (defvar hg-repo-history nil)
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (defvar hg-rev-history nil)
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (defvar hg-repo-completion-table nil) ; shut up warnings
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 ;;; Random constants.
(defconst hg-commit-message-start
"--- Enter your commit message. Type `C-c C-c' to commit. ---\n")
(defconst hg-commit-message-end
"--- Files in bold will be committed. Click to toggle selection. ---\n")
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (defconst hg-state-alist
'((?M . modified)
(?A . added)
(?R . removed)
(?! . deleted)
(?C . normal)
(?I . ignored)
(?? . nil)))
Bryan O'Sullivan
Emacs: first cut at commit support.
r999
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 ;;; hg-mode keymap.
(defvar hg-prefix-map
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (let ((map (make-sparse-keymap)))
(hg-feature-cond (xemacs (set-keymap-name map 'hg-prefix-map))) ; XEmacs
(set-keymap-parent map vc-prefix-map)
(define-key map "=" 'hg-diff)
(define-key map "c" 'hg-undo)
(define-key map "g" 'hg-annotate)
(define-key map "i" 'hg-add)
(define-key map "l" 'hg-log)
(define-key map "n" 'hg-commit-start)
;; (define-key map "r" 'hg-update)
(define-key map "u" 'hg-revert-buffer)
(define-key map "~" 'hg-version-other-window)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 map)
"This keymap overrides some default vc-mode bindings.")
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433
(defvar hg-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-xv" hg-prefix-map)
map))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (add-minor-mode 'hg-mode 'hg-mode hg-mode-map)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
;;; Global keymap.
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (defvar hg-global-map
(let ((map (make-sparse-keymap)))
(define-key map "," 'hg-incoming)
(define-key map "." 'hg-outgoing)
(define-key map "<" 'hg-pull)
(define-key map "=" 'hg-diff-repo)
(define-key map ">" 'hg-push)
(define-key map "?" 'hg-help-overview)
(define-key map "A" 'hg-addremove)
(define-key map "U" 'hg-revert)
(define-key map "a" 'hg-add)
(define-key map "c" 'hg-commit-start)
(define-key map "f" 'hg-forget)
(define-key map "h" 'hg-help-overview)
(define-key map "i" 'hg-init)
(define-key map "l" 'hg-log-repo)
(define-key map "r" 'hg-root)
(define-key map "s" 'hg-status)
(define-key map "u" 'hg-update)
map))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (global-set-key hg-global-prefix hg-global-map)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
;;; View mode keymap.
(defvar hg-view-mode-map
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (let ((map (make-sparse-keymap)))
(hg-feature-cond (xemacs (set-keymap-name map 'hg-view-mode-map))) ; XEmacs
(define-key map (hg-feature-cond (xemacs [button2])
(t [mouse-2]))
'hg-buffer-mouse-clicked)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 map))
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433
(add-minor-mode 'hg-view-mode "" hg-view-mode-map)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 ;;; Commit mode keymaps.
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (defvar hg-commit-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-c\C-c" 'hg-commit-finish)
(define-key map "\C-c\C-k" 'hg-commit-kill)
(define-key map "\C-xv=" 'hg-diff-repo)
map))
Bryan O'Sullivan
Emacs: first cut at commit support.
r999
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (defvar hg-commit-mode-file-map
(let ((map (make-sparse-keymap)))
(define-key map (hg-feature-cond (xemacs [button2])
(t [mouse-2]))
'hg-commit-mouse-clicked)
(define-key map " " 'hg-commit-toggle-file)
(define-key map "\r" 'hg-commit-toggle-file)
map))
Thomas Arendsen Hein
Cleanup of tabs and trailing spaces.
r1308
Bryan O'Sullivan
Emacs: first cut at commit support.
r999
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 ;;; Convenience functions.
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995 (defsubst hg-binary ()
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 (if hg-binary
hg-binary
(error "No `hg' executable found!")))
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995 (defsubst hg-replace-in-string (str regexp newtext &optional literal)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 "Replace all matches in STR for REGEXP with NEWTEXT string.
Return the new string. Optional LITERAL non-nil means do a literal
replacement.
This function bridges yet another pointless impedance gap between
XEmacs and GNU Emacs."
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (hg-feature-cond
(xemacs (replace-in-string str regexp newtext literal))
(t (replace-regexp-in-string regexp newtext str nil literal))))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 (defsubst hg-strip (str)
jdc@uwo.ca
Adjust hg-strip and hg-chomp regexps.
r1178 "Strip leading and trailing blank lines from a string."
(hg-replace-in-string (hg-replace-in-string str "[\r\n][ \t\r\n]*\\'" "")
"\\`[ \t\r\n]*[\r\n]" ""))
Bryan O'Sullivan
Emacs: first cut at commit support.
r999
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995 (defsubst hg-chomp (str)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 "Strip trailing newlines from a string."
Bryan O'Sullivan
mercurial.el: fix hg-chomp.
r2999 (hg-replace-in-string str "[\r\n]+\\'" ""))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
(defun hg-run-command (command &rest args)
"Run the shell command COMMAND, returning (EXIT-CODE . COMMAND-OUTPUT).
The list ARGS contains a list of arguments to pass to the command."
(let* (exit-code
(output
(with-output-to-string
(with-current-buffer
standard-output
(setq exit-code
(apply 'call-process command nil t nil args))))))
(cons exit-code output)))
(defun hg-run (command &rest args)
"Run the Mercurial command COMMAND, returning (EXIT-CODE . COMMAND-OUTPUT)."
(apply 'hg-run-command (hg-binary) command args))
(defun hg-run0 (command &rest args)
"Run the Mercurial command COMMAND, returning its output.
If the command does not exit with a zero status code, raise an error."
(let ((res (apply 'hg-run-command (hg-binary) command args)))
(if (not (eq (car res) 0))
(error "Mercurial command failed %s - exit code %s"
(cons command args)
(car res))
(cdr res))))
NIIMI Satoshi
mercurial.el: move defmacro of hg-do-across-repo before use...
r4412 (defmacro hg-do-across-repo (path &rest body)
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (let ((root-name (make-symbol "root-"))
(buf-name (make-symbol "buf-")))
NIIMI Satoshi
mercurial.el: move defmacro of hg-do-across-repo before use...
r4412 `(let ((,root-name (hg-root ,path)))
(save-excursion
(dolist (,buf-name (buffer-list))
(set-buffer ,buf-name)
(when (and hg-status (equal (hg-root buffer-file-name) ,root-name))
,@body))))))
(put 'hg-do-across-repo 'lisp-indent-function 1)
bos@serpentine.internal.keyresearch.com
Sync buffers prior to doing a diff.
r1024 (defun hg-sync-buffers (path)
"Sync buffers visiting PATH with their on-disk copies.
If PATH is not being visited, but is under the repository root, sync
all buffers visiting files in the repository."
(let ((buf (find-buffer-visiting path)))
(if buf
(with-current-buffer buf
(vc-buffer-sync))
(hg-do-across-repo path
(vc-buffer-sync)))))
Thomas Arendsen Hein
Cleanup of tabs and trailing spaces.
r1308
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 (defun hg-buffer-commands (pnt)
"Use the properties of a character to do something sensible."
(interactive "d")
(let ((rev (get-char-property pnt 'rev))
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (file (get-char-property pnt 'file)))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 (cond
(file
(find-file-other-window file))
(rev
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (hg-diff hg-view-file-name rev rev))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 ((message "I don't know how to do that yet")))))
bos@serpentine.internal.keyresearch.com
Emacs: improved GNU Emacs support.
r1004 (defsubst hg-event-point (event)
"Return the character position of the mouse event EVENT."
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (hg-feature-cond (xemacs (event-point event))
(t (posn-point (event-start event)))))
bos@serpentine.internal.keyresearch.com
Emacs: improved GNU Emacs support.
r1004
(defsubst hg-event-window (event)
"Return the window over which mouse event EVENT occurred."
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (hg-feature-cond (xemacs (event-window event))
(t (posn-window (event-start event)))))
bos@serpentine.internal.keyresearch.com
Emacs: improved GNU Emacs support.
r1004
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 (defun hg-buffer-mouse-clicked (event)
"Translate the mouse clicks in a HG log buffer to character events.
These are then handed off to `hg-buffer-commands'.
Handle frickin' frackin' gratuitous event-related incompatibilities."
(interactive "e")
bos@serpentine.internal.keyresearch.com
Emacs: improved GNU Emacs support.
r1004 (select-window (hg-event-window event))
(hg-buffer-commands (hg-event-point event)))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995 (defsubst hg-abbrev-file-name (file)
"Portable wrapper around abbreviate-file-name."
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (hg-feature-cond (xemacs (abbreviate-file-name file t))
(t (abbreviate-file-name file))))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (defun hg-read-file-name (&optional prompt default)
"Read a file or directory name, or a pattern, to use with a command."
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (save-excursion
(while hg-prev-buffer
(set-buffer hg-prev-buffer))
FUJIWARA Katsunori
Emacs: apply "expand-filename" on "default-directory"....
r2668 (let ((path (or default
(buffer-file-name)
(expand-file-name default-directory))))
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (if (or (not path) current-prefix-arg)
FUJIWARA Katsunori
Emacs: adapt read-file-name invocation for (non-X)Emacs 21.4....
r2315 (expand-file-name
(eval (list* 'read-file-name
(format "File, directory or pattern%s: "
(or prompt ""))
(and path (file-name-directory path))
nil nil
(and path (file-name-nondirectory path))
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (hg-feature-cond
(xemacs (cons (quote 'hg-file-history) nil))
(t nil)))))
FUJIWARA Katsunori
Emacs: adapt read-file-name invocation for (non-X)Emacs 21.4....
r2315 path))))
Bryan O'Sullivan
In-progress Emacs snapshot.
r947
FUJIWARA Katsunori
Emacs: separate limitations of revision range and shown changesets....
r2316 (defun hg-read-number (&optional prompt default)
"Read a integer value."
(save-excursion
(if (or (not default) current-prefix-arg)
(string-to-number
(eval (list* 'read-string
Thomas Arendsen Hein
Remove trailing spaces
r5081 (or prompt "")
FUJIWARA Katsunori
Emacs: separate limitations of revision range and shown changesets....
r2316 (if default (cons (format "%d" default) nil) nil))))
default)))
Bryan O'Sullivan
Emacs: implement hg-incoming, hg-outgoing and hg-push.
r1029 (defun hg-read-config ()
"Return an alist of (key . value) pairs of Mercurial config data.
Each key is of the form (section . name)."
(let (items)
(dolist (line (split-string (hg-chomp (hg-run0 "debugconfig")) "\n") items)
(string-match "^\\([^=]*\\)=\\(.*\\)" line)
(let* ((left (substring line (match-beginning 1) (match-end 1)))
(right (substring line (match-beginning 2) (match-end 2)))
(key (split-string left "\\."))
(value (hg-replace-in-string right "\\\\n" "\n" t)))
(setq items (cons (cons (cons (car key) (cadr key)) value) items))))))
Thomas Arendsen Hein
Cleanup of tabs and trailing spaces.
r1308
Bryan O'Sullivan
Emacs: implement hg-incoming, hg-outgoing and hg-push.
r1029 (defun hg-config-section (section config)
"Return an alist of (name . value) pairs for SECTION of CONFIG."
(let (items)
(dolist (item config items)
(when (equal (caar item) section)
(setq items (cons (cons (cdar item) (cdr item)) items))))))
(defun hg-string-starts-with (sub str)
"Indicate whether string STR starts with the substring or character SUB."
(if (not (stringp sub))
(and (> (length str) 0) (equal (elt str 0) sub))
(let ((sub-len (length sub)))
(and (<= sub-len (length str))
(string= sub (substring str 0 sub-len))))))
(defun hg-complete-repo (string predicate all)
"Attempt to complete a repository name.
We complete on either symbolic names from Mercurial's config or real
timeless@mozdev.org
en-us: penalize
r17533 directory names from the file system. We do not penalize URLs."
Bryan O'Sullivan
Emacs: implement hg-incoming, hg-outgoing and hg-push.
r1029 (or (if all
(all-completions string hg-repo-completion-table predicate)
(try-completion string hg-repo-completion-table predicate))
(let* ((str (expand-file-name string))
(dir (file-name-directory str))
(file (file-name-nondirectory str)))
(if all
(let (completions)
(dolist (name (delete "./" (file-name-all-completions file dir))
completions)
(let ((path (concat dir name)))
(when (file-directory-p path)
(setq completions (cons name completions))))))
(let ((comp (file-name-completion file dir)))
(if comp
(hg-abbrev-file-name (concat dir comp))))))))
(defun hg-read-repo-name (&optional prompt initial-contents default)
"Read the location of a repository."
(save-excursion
(while hg-prev-buffer
(set-buffer hg-prev-buffer))
(let (hg-repo-completion-table)
(if current-prefix-arg
(progn
(dolist (path (hg-config-section "paths" (hg-read-config)))
(setq hg-repo-completion-table
(cons (cons (car path) t) hg-repo-completion-table))
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (unless (hg-string-starts-with (hg-feature-cond
(xemacs directory-sep-char)
(t ?/))
(cdr path))
Bryan O'Sullivan
Emacs: implement hg-incoming, hg-outgoing and hg-push.
r1029 (setq hg-repo-completion-table
(cons (cons (cdr path) t) hg-repo-completion-table))))
(completing-read (format "Repository%s: " (or prompt ""))
'hg-complete-repo
nil
nil
initial-contents
'hg-repo-history
default))
default))))
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (defun hg-read-rev (&optional prompt default)
"Read a revision or tag, offering completions."
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (save-excursion
(while hg-prev-buffer
(set-buffer hg-prev-buffer))
(let ((rev (or default "tip")))
Bryan O'Sullivan
Emacs: implement hg-incoming, hg-outgoing and hg-push.
r1029 (if current-prefix-arg
Bryan O'Sullivan
Emacs: fix invocations of "hg log" to match current behaviour of log.
r1175 (let ((revs (split-string
(hg-chomp
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (hg-run0 "-q" "log" "-l"
(format "%d" hg-rev-completion-limit)))
Bryan O'Sullivan
Emacs: fix invocations of "hg log" to match current behaviour of log.
r1175 "[\n:]")))
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (dolist (line (split-string (hg-chomp (hg-run0 "tags")) "\n"))
(setq revs (cons (car (split-string line "\\s-")) revs)))
(completing-read (format "Revision%s (%s): "
(or prompt "")
(or default "tip"))
NIIMI Satoshi
mercurial.el, mq.el: remove runtime dependencies on CL package...
r5465 (mapcar (lambda (x) (cons x x)) revs)
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 nil
nil
nil
'hg-rev-history
(or default "tip")))
rev))))
Bryan O'Sullivan
Emacs: first cut at commit support.
r999
Bryan O'Sullivan
mercurial.el: speed up mode line updates.
r3002 (defun hg-parents-for-mode-line (root)
"Format the parents of the working directory for the mode line."
(let ((parents (split-string (hg-chomp
(hg-run0 "--cwd" root "parents" "--template"
"{rev}\n")) "\n")))
(mapconcat 'identity parents "+")))
(defun hg-buffers-visiting-repo (&optional path)
"Return a list of buffers visiting the repository containing PATH."
(let ((root-name (hg-root (or path (buffer-file-name))))
bufs)
(save-excursion
(dolist (buf (buffer-list) bufs)
(set-buffer buf)
(let ((name (buffer-file-name)))
(when (and hg-status name (equal (hg-root name) root-name))
(setq bufs (cons buf bufs))))))))
(defun hg-update-mode-lines (path)
"Update the mode lines of all buffers visiting the same repository as PATH."
(let* ((root (hg-root path))
(parents (hg-parents-for-mode-line root)))
(save-excursion
(dolist (info (hg-path-status
root
(mapcar
(function
(lambda (buf)
(substring (buffer-file-name buf) (length root))))
(hg-buffers-visiting-repo root))))
(let* ((name (car info))
(status (cdr info))
(buf (find-buffer-visiting (concat root name))))
(when buf
(set-buffer buf)
(hg-mode-line-internal status parents)))))))
Thomas Arendsen Hein
Remove trailing spaces
r5081
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
;;; View mode bits.
(defun hg-exit-view-mode (buf)
"Exit from hg-view-mode.
We delete the current window if entering hg-view-mode split the
current frame."
(when (and (eq buf (current-buffer))
(> (length (window-list)) 1))
(delete-window))
(when (buffer-live-p buf)
(kill-buffer buf)))
(defun hg-view-mode (prev-buffer &optional file-name)
(goto-char (point-min))
(set-buffer-modified-p nil)
(toggle-read-only t)
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (hg-feature-cond (xemacs (view-minor-mode prev-buffer 'hg-exit-view-mode))
(t (view-mode-enter nil 'hg-exit-view-mode)))
(setq hg-view-mode t)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 (setq truncate-lines t)
(when file-name
Thomas Arendsen Hein
Remove trailing spaces
r5081 (setq hg-view-file-name
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (hg-abbrev-file-name file-name))))
Thomas Arendsen Hein
Cleanup of tabs and trailing spaces.
r1308
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (defun hg-file-status (file)
"Return status of FILE, or nil if FILE does not exist or is unmanaged."
(let* ((s (hg-run "status" file))
(exit (car s))
(output (cdr s)))
(if (= exit 0)
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (let ((state (and (>= (length output) 2)
(= (aref output 1) ? )
(assq (aref output 0) hg-state-alist))))
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (if state
(cdr state)
'normal)))))
Bryan O'Sullivan
mercurial.el: speed up mode line updates.
r3002 (defun hg-path-status (root paths)
"Return status of PATHS in repo ROOT as an alist.
Bryan O'Sullivan
mercurial.el: add hg-status.
r3001 Each entry is a pair (FILE-NAME . STATUS)."
Bryan O'Sullivan
mercurial.el: speed up mode line updates.
r3002 (let ((s (apply 'hg-run "--cwd" root "status" "-marduc" paths))
Bryan O'Sullivan
mercurial.el: deal with more vagaries of "hg status"....
r3005 result)
(dolist (entry (split-string (hg-chomp (cdr s)) "\n") (nreverse result))
(let (state name)
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (cond ((= (aref entry 1) ? )
(setq state (assq (aref entry 0) hg-state-alist)
name (substring entry 2)))
((string-match "\\(.*\\): " entry)
(setq name (match-string 1 entry))))
Bryan O'Sullivan
mercurial.el: deal with more vagaries of "hg status"....
r3005 (setq result (cons (cons name state) result))))))
Bryan O'Sullivan
mercurial.el: add hg-status.
r3001
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 (defmacro hg-view-output (args &rest body)
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 "Execute BODY in a clean buffer, then quickly display that buffer.
If the buffer contains one line, its contents are displayed in the
minibuffer. Otherwise, the buffer is displayed in view-mode.
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 ARGS is of the form (BUFFER-NAME &optional FILE), where BUFFER-NAME is
the name of the buffer to create, and FILE is the name of the file
being viewed."
NIIMI Satoshi
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups...
r4433 (let ((prev-buf (make-symbol "prev-buf-"))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 (v-b-name (car args))
(v-m-rest (cdr args)))
`(let ((view-buf-name ,v-b-name)
(,prev-buf (current-buffer)))
(get-buffer-create view-buf-name)
(kill-buffer view-buf-name)
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (get-buffer-create view-buf-name)
(set-buffer view-buf-name)
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 (save-excursion
,@body)
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (case (count-lines (point-min) (point-max))
((0)
(kill-buffer view-buf-name)
(message "(No output)"))
((1)
(let ((msg (hg-chomp (buffer-substring (point-min) (point-max)))))
(kill-buffer view-buf-name)
(message "%s" msg)))
(t
(pop-to-buffer view-buf-name)
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (setq hg-prev-buffer ,prev-buf)
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (hg-view-mode ,prev-buf ,@v-m-rest))))))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
(put 'hg-view-output 'lisp-indent-function 1)
Bryan O'Sullivan
In-progress Emacs snapshot.
r947
Bryan O'Sullivan
mercurial.el: deal with more vagaries of "hg status"....
r3005 ;;; Context save and restore across revert and other operations.
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995
(defun hg-position-context (pos)
"Return information to help find the given position again."
(let* ((end (min (point-max) (+ pos 98))))
(list pos
(buffer-substring (max (point-min) (- pos 2)) end)
(- end pos))))
(defun hg-buffer-context ()
"Return information to help restore a user's editing context.
This is useful across reverts and merges, where a context is likely
to have moved a little, but not really changed."
(let ((point-context (hg-position-context (point)))
(mark-context (let ((mark (mark-marker)))
NIIMI Satoshi
mercurial.el: mark-marker() returns non-nil with no active mark on GNU Emacs
r5467 (and mark
;; make sure active mark
(marker-buffer mark)
(marker-position mark)
(hg-position-context mark)))))
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995 (list point-context mark-context)))
Thomas Arendsen Hein
Cleanup of tabs and trailing spaces.
r1308
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995 (defun hg-find-context (ctx)
"Attempt to find a context in the given buffer.
Always returns a valid, hopefully sane, position."
(let ((pos (nth 0 ctx))
(str (nth 1 ctx))
(fixup (nth 2 ctx)))
(save-excursion
(goto-char (max (point-min) (- pos 15000)))
(if (and (not (equal str ""))
(search-forward str nil t))
(- (point) fixup)
(max pos (point-min))))))
(defun hg-restore-context (ctx)
"Attempt to restore the user's editing context."
(let ((point-context (nth 0 ctx))
(mark-context (nth 1 ctx)))
(goto-char (hg-find-context point-context))
(when mark-context
(set-mark (hg-find-context mark-context)))))
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 ;;; Hooks.
Bryan O'Sullivan
mercurial.el: speed up mode line updates.
r3002 (defun hg-mode-line-internal (status parents)
(setq hg-status status
hg-mode (and status (concat " Hg:"
parents
(cdr (assq status
'((normal . "")
(removed . "r")
(added . "a")
(deleted . "!")
(modified . "m"))))))))
Thomas Arendsen Hein
Remove trailing spaces
r5081
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995 (defun hg-mode-line (&optional force)
"Update the modeline with the current status of a file.
An update occurs if optional argument FORCE is non-nil,
hg-update-modeline is non-nil, or we have not yet checked the state of
the file."
Bryan O'Sullivan
mercurial.el: speed up mode line updates.
r3002 (let ((root (hg-root)))
(when (and root (or force hg-update-modeline (not hg-mode)))
(let ((status (hg-file-status buffer-file-name))
(parents (hg-parents-for-mode-line root)))
(hg-mode-line-internal status parents)
status))))
Bryan O'Sullivan
In-progress Emacs snapshot.
r947
Robin Farine
emacs minor mode optional argument...
r1371 (defun hg-mode (&optional toggle)
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 "Minor mode for Mercurial distributed SCM integration.
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 The Mercurial mode user interface is based on that of VC mode, so if
you're already familiar with VC, the same keybindings and functions
will generally work.
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Vadim Gelfer
mercurial.el: inhibit backups for files managed by mercurial
r2517 Below is a list of many common SCM tasks. In the list, `G/L\'
Brendan Cully
Unconfuse font-lock
r4411 indicates whether a key binding is global (G) to a repository or
local (L) to a file. Many commands take a prefix argument.
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
SCM Task G/L Key Binding Command Name
-------- --- ----------- ------------
Help overview (what you are reading) G C-c h h hg-help-overview
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 Tell Mercurial to manage a file G C-c h a hg-add
jdc@uwo.ca
Fix mercurial.el help.
r1179 Commit changes to current file only L C-x v n hg-commit-start
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995 Undo changes to file since commit L C-x v u hg-revert-buffer
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 Diff file vs last checkin L C-x v = hg-diff
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 View file change history L C-x v l hg-log
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 View annotated file L C-x v a hg-annotate
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 Diff repo vs last checkin G C-c h = hg-diff-repo
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 View status of files in repo G C-c h s hg-status
jdc@uwo.ca
Fix mercurial.el help.
r1179 Commit all changes G C-c h c hg-commit-start
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Undo all changes since last commit G C-c h U hg-revert
jdc@uwo.ca
Fix mercurial.el help.
r1179 View repo change history G C-c h l hg-log-repo
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
See changes that can be pulled G C-c h , hg-incoming
Pull changes G C-c h < hg-pull
Update working directory after pull G C-c h u hg-update
See changes that can be pushed G C-c h . hg-outgoing
Push changes G C-c h > hg-push"
Vadim Gelfer
mercurial.el: inhibit backups for files managed by mercurial
r2517 (unless vc-make-backup-files
(set (make-local-variable 'backup-inhibited) t))
Vadim Gelfer
mercurial.el: fix misleading indent of code....
r2518 (run-hooks 'hg-mode-hook))
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003
(defun hg-find-file-hook ()
NIIMI Satoshi
mercurial.el: don't raise an error from find-file-hook...
r4413 (ignore-errors
(when (hg-mode-line)
(hg-mode))))
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003
(add-hook 'find-file-hooks 'hg-find-file-hook)
(defun hg-after-save-hook ()
NIIMI Satoshi
mercurial.el: ignore errors on hg-after-save-hook()...
r4694 (ignore-errors
(let ((old-status hg-status))
(hg-mode-line)
(if (and (not old-status) hg-status)
(hg-mode)))))
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003
(add-hook 'after-save-hook 'hg-after-save-hook)
;;; User interface functions.
(defun hg-help-overview ()
"This is an overview of the Mercurial SCM mode for Emacs.
Matt Mackall
Update license to GPLv2+
r10263 You can find the source code, license (GPLv2+), and credits for this
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 code by typing `M-x find-library mercurial RET'."
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 (interactive)
(hg-view-output ("Mercurial Help Overview")
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (insert (documentation 'hg-help-overview))
(let ((pos (point)))
(insert (documentation 'hg-mode))
(goto-char pos)
FUJIWARA Katsunori
Emacs: use delete-region instead of kill-* functions....
r2452 (end-of-line 1)
Vadim Gelfer
merge emacs changes.
r2457 (delete-region pos (point)))
Giorgos Keramidas
avoid calling (cd ...) with `nil' as a directory name...
r2737 (let ((hg-root-dir (hg-root)))
(if (not hg-root-dir)
(error "error: %s: directory is not part of a Mercurial repository."
default-directory)
Giorgos Keramidas
Use cached hg-root-dir instead of rediscovering...
r2877 (cd hg-root-dir)))))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
mercurial.el: get rid of unportable, unperformant use of replace-regexp.
r2997 (defun hg-fix-paths ()
"Fix paths reported by some Mercurial commands."
(save-excursion
(goto-char (point-min))
(while (re-search-forward " \\.\\.." nil t)
(replace-match " " nil nil))))
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (defun hg-add (path)
Bryan O'Sullivan
Emacs: document existing functions.
r996 "Add PATH to the Mercurial repository on the next commit.
With a prefix argument, prompt for the path to add."
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (interactive (list (hg-read-file-name " to add")))
(let ((buf (current-buffer))
(update (equal buffer-file-name path)))
(hg-view-output (hg-output-buffer-name)
FUJIWARA Katsunori
Emacs: change directory of output buffer to the root of the repository.
r2454 (apply 'call-process (hg-binary) nil t nil (list "add" path))
Bryan O'Sullivan
mercurial.el: get rid of unportable, unperformant use of replace-regexp.
r2997 (hg-fix-paths)
Bryan O'Sullivan
mercurial.el: fix calls to goto-char.
r2998 (goto-char (point-min))
FUJIWARA Katsunori
Emacs: change directory of output buffer to the root of the repository.
r2454 (cd (hg-root path)))
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (when update
Vadim Gelfer
mercurial.el: inhibit backups for files managed by mercurial
r2517 (unless vc-make-backup-files
(set (make-local-variable 'backup-inhibited) t))
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (with-current-buffer buf
(hg-mode-line)))))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
(defun hg-addremove ()
(interactive)
(error "not implemented"))
(defun hg-annotate ()
(interactive)
(error "not implemented"))
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 (defun hg-commit-toggle-file (pos)
"Toggle whether or not the file at POS will be committed."
(interactive "d")
(save-excursion
(goto-char pos)
Jonathan Kotta
allow toggling when the cursor is on the correct line instead of just the filename text in hg-commit-toggle-file
r8370 (let (face
bos@serpentine.internal.keyresearch.com
Emacs: improved GNU Emacs support.
r1004 (inhibit-read-only t)
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 bol)
(beginning-of-line)
(setq bol (+ (point) 4))
Jonathan Kotta
allow toggling when the cursor is on the correct line instead of just the filename text in hg-commit-toggle-file
r8370 (setq face (get-text-property bol 'face))
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 (end-of-line)
(if (eq face 'bold)
(progn
(remove-text-properties bol (point) '(face nil))
(message "%s will not be committed"
(buffer-substring bol (point))))
(add-text-properties bol (point) '(face bold))
(message "%s will be committed"
(buffer-substring bol (point)))))))
Thomas Arendsen Hein
Cleanup of tabs and trailing spaces.
r1308
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 (defun hg-commit-mouse-clicked (event)
"Toggle whether or not the file at POS will be committed."
(interactive "@e")
bos@serpentine.internal.keyresearch.com
Emacs: improved GNU Emacs support.
r1004 (hg-commit-toggle-file (hg-event-point event)))
Bryan O'Sullivan
Emacs: first cut at commit support.
r999
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (defun hg-commit-kill ()
"Kill the commit currently being prepared."
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 (interactive)
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (when (or (not (buffer-modified-p)) (y-or-n-p "Really kill this commit? "))
(let ((buf hg-prev-buffer))
(kill-buffer nil)
(switch-to-buffer buf))))
Bryan O'Sullivan
Emacs: first cut at commit support.
r999
(defun hg-commit-finish ()
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 "Finish preparing a commit, and perform the actual commit.
The hook hg-pre-commit-hook is run before anything else is done. If
the commit message is empty and hg-commit-allow-empty-message is nil,
an error is raised. If the list of files to commit is empty and
hg-commit-allow-empty-file-list is nil, an error is raised."
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 (interactive)
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (let ((root hg-root))
(save-excursion
(run-hooks 'hg-pre-commit-hook)
(goto-char (point-min))
(search-forward hg-commit-message-start)
(let (message files)
(let ((start (point)))
(goto-char (point-max))
(search-backward hg-commit-message-end)
(setq message (hg-strip (buffer-substring start (point)))))
(when (and (= (length message) 0)
(not hg-commit-allow-empty-message))
(error "Cannot proceed - commit message is empty"))
(forward-line 1)
(beginning-of-line)
(while (< (point) (point-max))
(let ((pos (+ (point) 4)))
(end-of-line)
(when (eq (get-text-property pos 'face) 'bold)
(end-of-line)
(setq files (cons (buffer-substring pos (point)) files))))
(forward-line 1))
(when (and (= (length files) 0)
(not hg-commit-allow-empty-file-list))
(error "Cannot proceed - no files to commit"))
(setq message (concat message "\n"))
(apply 'hg-run0 "--cwd" hg-root "commit" "-m" message files))
(let ((buf hg-prev-buffer))
(kill-buffer nil)
(switch-to-buffer buf))
Bryan O'Sullivan
mercurial.el: speed up mode line updates.
r3002 (hg-update-mode-lines root))))
Bryan O'Sullivan
Emacs: first cut at commit support.
r999
(defun hg-commit-mode ()
"Mode for describing a commit of changes to a Mercurial repository.
This involves two actions: describing the changes with a commit
message, and choosing the files to commit.
To describe the commit, simply type some text in the designated area.
By default, all modified, added and removed files are selected for
committing. Files that will be committed are displayed in bold face\;
those that will not are displayed in normal face.
To toggle whether a file will be committed, move the cursor over a
particular file and hit space or return. Alternatively, middle click
on the file.
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 Key bindings
------------
\\[hg-commit-finish] proceed with commit
\\[hg-commit-kill] kill commit
\\[hg-diff-repo] view diff of pending changes"
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 (interactive)
(use-local-map hg-commit-mode-map)
(set-syntax-table text-mode-syntax-table)
(setq local-abbrev-table text-mode-abbrev-table
major-mode 'hg-commit-mode
mode-name "Hg-Commit")
(set-buffer-modified-p nil)
(setq buffer-undo-list nil)
(run-hooks 'text-mode-hook 'hg-commit-mode-hook))
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (defun hg-commit-start ()
"Prepare a commit of changes to the repository containing the current file."
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 (interactive)
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (while hg-prev-buffer
(set-buffer hg-prev-buffer))
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 (let ((root (hg-root))
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (prev-buffer (current-buffer))
modified-files)
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 (unless root
(error "Cannot commit outside a repository!"))
bos@serpentine.internal.keyresearch.com
Sync buffers prior to doing a diff.
r1024 (hg-sync-buffers root)
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (setq modified-files (hg-chomp (hg-run0 "--cwd" root "status" "-arm")))
(when (and (= (length modified-files) 0)
(not hg-commit-allow-empty-file-list))
(error "No pending changes to commit"))
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 (let* ((buf-name (format "*Mercurial: Commit %s*" root)))
(pop-to-buffer (get-buffer-create buf-name))
(when (= (point-min) (point-max))
(set (make-local-variable 'hg-root) root)
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (setq hg-prev-buffer prev-buffer)
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 (insert "\n")
(let ((bol (point)))
(insert hg-commit-message-end)
bos@serpentine.internal.keyresearch.com
Emacs: improved GNU Emacs support.
r1004 (add-text-properties bol (point) '(face bold-italic)))
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 (let ((file-area (point)))
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (insert modified-files)
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 (goto-char file-area)
(while (< (point) (point-max))
(let ((bol (point)))
(forward-char 1)
(insert " ")
(end-of-line)
(add-text-properties (+ bol 4) (point)
'(face bold mouse-face highlight)))
(forward-line 1))
(goto-char file-area)
(add-text-properties (point) (point-max)
bos@serpentine.internal.keyresearch.com
Emacs: improved GNU Emacs support.
r1004 `(keymap ,hg-commit-mode-file-map))
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 (goto-char (point-min))
(insert hg-commit-message-start)
bos@serpentine.internal.keyresearch.com
Emacs: improved GNU Emacs support.
r1004 (add-text-properties (point-min) (point) '(face bold-italic))
Bryan O'Sullivan
Emacs: first cut at commit support.
r999 (insert "\n\n")
(forward-line -1)
bos@serpentine.internal.keyresearch.com
Emacs: improved GNU Emacs support.
r1004 (save-excursion
(goto-char (point-max))
(search-backward hg-commit-message-end)
(add-text-properties (match-beginning 0) (point-max)
'(read-only t))
(goto-char (point-min))
(search-forward hg-commit-message-start)
(add-text-properties (match-beginning 0) (match-end 0)
'(read-only t)))
FUJIWARA Katsunori
Emacs: change directory of output buffer to the root of the repository.
r2454 (hg-commit-mode)
(cd root))))))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (defun hg-diff (path &optional rev1 rev2)
Bryan O'Sullivan
Emacs: document existing functions.
r996 "Show the differences between REV1 and REV2 of PATH.
When called interactively, the default behaviour is to treat REV1 as
FUJIWARA Katsunori
Emacs: follow the revision usage policy of "hg diff" command....
r2455 the \"parent\" revision, REV2 as the current edited version of the file, and
Bryan O'Sullivan
Emacs: document existing functions.
r996 PATH as the file edited in the current buffer.
With a prefix argument, prompt for all of these."
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (interactive (list (hg-read-file-name " to diff")
FUJIWARA Katsunori
Emacs: follow the revision usage policy of "hg diff" command....
r2455 (let ((rev1 (hg-read-rev " to start with" 'parent)))
(and (not (eq rev1 'parent)) rev1))
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (let ((rev2 (hg-read-rev " to end with" 'working-dir)))
(and (not (eq rev2 'working-dir)) rev2))))
bos@serpentine.internal.keyresearch.com
Sync buffers prior to doing a diff.
r1024 (hg-sync-buffers path)
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995 (let ((a-path (hg-abbrev-file-name path))
FUJIWARA Katsunori
Emacs: follow the revision usage policy of "hg diff" command....
r2455 ;; none revision is specified explicitly
(none (and (not rev1) (not rev2)))
;; only one revision is specified explicitly
Thomas Arendsen Hein
Remove trailing spaces
r5081 (one (or (and (or (equal rev1 rev2) (not rev2)) rev1)
FUJIWARA Katsunori
Emacs: follow the revision usage policy of "hg diff" command....
r2455 (and (not rev1) rev2)))
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995 diff)
Bryan O'Sullivan
Emacs: fix up hg-log and hg-diff to operate more uniformly.
r1027 (hg-view-output ((cond
FUJIWARA Katsunori
Emacs: follow the revision usage policy of "hg diff" command....
r2455 (none
(format "Mercurial: Diff against parent of %s" a-path))
(one
(format "Mercurial: Diff of rev %s of %s" one a-path))
Bryan O'Sullivan
Emacs: fix up hg-log and hg-diff to operate more uniformly.
r1027 (t
(format "Mercurial: Diff from rev %s to %s of %s"
FUJIWARA Katsunori
Emacs: follow the revision usage policy of "hg diff" command....
r2455 rev1 rev2 a-path))))
(cond
Thomas Arendsen Hein
Remove trailing spaces
r5081 (none
FUJIWARA Katsunori
Emacs: follow the revision usage policy of "hg diff" command....
r2455 (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)))
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (diff-mode)
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995 (setq diff (not (= (point-min) (point-max))))
FUJIWARA Katsunori
Emacs: change directory of output buffer to the root of the repository.
r2454 (font-lock-fontify-buffer)
(cd (hg-root path)))
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995 diff))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
FUJIWARA Katsunori
Emacs: follow the revision usage policy of "hg diff" command....
r2455 (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))
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (defun hg-forget (path)
Bryan O'Sullivan
Emacs: document existing functions.
r996 "Lose track of PATH, which has been added, but not yet committed.
This will prevent the file from being incorporated into the Mercurial
repository on the next commit.
With a prefix argument, prompt for the path to forget."
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (interactive (list (hg-read-file-name " to forget")))
(let ((buf (current-buffer))
(update (equal buffer-file-name path)))
(hg-view-output (hg-output-buffer-name)
FUJIWARA Katsunori
Emacs: change directory of output buffer to the root of the repository.
r2454 (apply 'call-process (hg-binary) nil t nil (list "forget" path))
;; "hg forget" shows pathes relative NOT TO ROOT BUT TO REPOSITORY
Bryan O'Sullivan
mercurial.el: get rid of unportable, unperformant use of replace-regexp.
r2997 (hg-fix-paths)
Bryan O'Sullivan
mercurial.el: fix calls to goto-char.
r2998 (goto-char (point-min))
FUJIWARA Katsunori
Emacs: change directory of output buffer to the root of the repository.
r2454 (cd (hg-root path)))
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (when update
(with-current-buffer buf
FUJIWARA Katsunori
Emacs: apply kill-local-variable instead of make-local-variable to FORGET
r2667 (when (local-variable-p 'backup-inhibited)
(kill-local-variable 'backup-inhibited))
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (hg-mode-line)))))
Thomas Arendsen Hein
Cleanup of tabs and trailing spaces.
r1308
Bryan O'Sullivan
Emacs: implement hg-incoming, hg-outgoing and hg-push.
r1029 (defun hg-incoming (&optional repo)
"Display changesets present in REPO that are not present locally."
(interactive (list (hg-read-repo-name " where changes would come from")))
(hg-view-output ((format "Mercurial: Incoming from %s to %s"
(hg-abbrev-file-name (hg-root))
(hg-abbrev-file-name
(or repo hg-incoming-repository))))
(call-process (hg-binary) nil t nil "incoming"
(or repo hg-incoming-repository))
FUJIWARA Katsunori
Emacs: change directory of output buffer to the root of the repository.
r2454 (hg-log-mode)
(cd (hg-root))))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
(defun hg-init ()
(interactive)
(error "not implemented"))
Bryan O'Sullivan
Emacs: implement hg-incoming, hg-outgoing and hg-push.
r1029 (defun hg-log-mode ()
"Mode for viewing a Mercurial change log."
(goto-char (point-min))
FUJIWARA Katsunori
Emacs: use delete-region instead of kill-* functions....
r2452 (when (looking-at "^searching for changes.*$")
(delete-region (match-beginning 0) (match-end 0)))
Bryan O'Sullivan
Emacs: implement hg-incoming, hg-outgoing and hg-push.
r1029 (run-hooks 'hg-log-mode-hook))
FUJIWARA Katsunori
Emacs: separate limitations of revision range and shown changesets....
r2316 (defun hg-log (path &optional rev1 rev2 log-limit)
"Display the revision history of PATH.
History is displayed between REV1 and REV2.
Number of displayed changesets is limited to LOG-LIMIT.
NIIMI Satoshi
mercurial.el: change default log range to tip:0...
r4693 REV1 defaults to the tip, while REV2 defaults to 0.
FUJIWARA Katsunori
Emacs: separate limitations of revision range and shown changesets....
r2316 LOG-LIMIT defaults to `hg-log-limit'.
Bryan O'Sullivan
Emacs: fix up hg-log and hg-diff to operate more uniformly.
r1027 With a prefix argument, prompt for each parameter."
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (interactive (list (hg-read-file-name " to log")
FUJIWARA Katsunori
Emacs: separate limitations of revision range and shown changesets....
r2316 (hg-read-rev " to start with"
"tip")
(hg-read-rev " to end with"
NIIMI Satoshi
mercurial.el: change default log range to tip:0...
r4693 "0")
FUJIWARA Katsunori
Emacs: separate limitations of revision range and shown changesets....
r2316 (hg-read-number "Output limited to: "
hg-log-limit)))
Bryan O'Sullivan
Emacs: fix up hg-log and hg-diff to operate more uniformly.
r1027 (let ((a-path (hg-abbrev-file-name path))
NIIMI Satoshi
mercurial.el: change default log range to tip:0...
r4693 (r1 (or rev1 "tip"))
(r2 (or rev2 "0"))
FUJIWARA Katsunori
Emacs: separate limitations of revision range and shown changesets....
r2316 (limit (format "%d" (or log-limit hg-log-limit))))
Bryan O'Sullivan
Emacs: fix up hg-log and hg-diff to operate more uniformly.
r1027 (hg-view-output ((if (equal r1 r2)
FUJIWARA Katsunori
Emacs: separate limitations of revision range and shown changesets....
r2316 (format "Mercurial: Log of rev %s of %s" rev1 a-path)
Thomas Arendsen Hein
Remove trailing spaces
r5081 (format
FUJIWARA Katsunori
Emacs: separate limitations of revision range and shown changesets....
r2316 "Mercurial: at most %s log(s) from rev %s to %s of %s"
limit r1 r2 a-path)))
(eval (list* 'call-process (hg-binary) nil t nil
"log"
"-r" (format "%s:%s" r1 r2)
"-l" limit
(if (> (length path) (length (hg-root path)))
(cons path nil)
nil)))
FUJIWARA Katsunori
Emacs: change directory of output buffer to the root of the repository.
r2454 (hg-log-mode)
(cd (hg-root path)))))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
FUJIWARA Katsunori
Emacs: separate limitations of revision range and shown changesets....
r2316 (defun hg-log-repo (path &optional rev1 rev2 log-limit)
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 "Display the revision history of the repository containing PATH.
FUJIWARA Katsunori
Emacs: separate limitations of revision range and shown changesets....
r2316 History is displayed between REV1 and REV2.
Number of displayed changesets is limited to LOG-LIMIT,
NIIMI Satoshi
mercurial.el: change default log range to tip:0...
r4693 REV1 defaults to the tip, while REV2 defaults to 0.
FUJIWARA Katsunori
Emacs: separate limitations of revision range and shown changesets....
r2316 LOG-LIMIT defaults to `hg-log-limit'.
With a prefix argument, prompt for each parameter."
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (interactive (list (hg-read-file-name " to log")
FUJIWARA Katsunori
Emacs: separate limitations of revision range and shown changesets....
r2316 (hg-read-rev " to start with"
"tip")
Thomas Arendsen Hein
Remove trailing spaces
r5081 (hg-read-rev " to end with"
NIIMI Satoshi
mercurial.el: change default log range to tip:0...
r4693 "0")
FUJIWARA Katsunori
Emacs: separate limitations of revision range and shown changesets....
r2316 (hg-read-number "Output limited to: "
hg-log-limit)))
(hg-log (hg-root path) rev1 rev2 log-limit))
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003
Bryan O'Sullivan
Emacs: implement hg-incoming, hg-outgoing and hg-push.
r1029 (defun hg-outgoing (&optional repo)
"Display changesets present locally that are not present in REPO."
(interactive (list (hg-read-repo-name " where changes would go to" nil
hg-outgoing-repository)))
(hg-view-output ((format "Mercurial: Outgoing from %s to %s"
(hg-abbrev-file-name (hg-root))
(hg-abbrev-file-name
(or repo hg-outgoing-repository))))
(call-process (hg-binary) nil t nil "outgoing"
(or repo hg-outgoing-repository))
FUJIWARA Katsunori
Emacs: change directory of output buffer to the root of the repository.
r2454 (hg-log-mode)
(cd (hg-root))))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
mercurial.el: implement hg-pull, and stub in hg-update.
r1246 (defun hg-pull (&optional repo)
"Pull changes from repository REPO.
This does not update the working directory."
(interactive (list (hg-read-repo-name " to pull from")))
(hg-view-output ((format "Mercurial: Pull to %s from %s"
(hg-abbrev-file-name (hg-root))
(hg-abbrev-file-name
(or repo hg-incoming-repository))))
(call-process (hg-binary) nil t nil "pull"
FUJIWARA Katsunori
Emacs: change directory of output buffer to the root of the repository.
r2454 (or repo hg-incoming-repository))
(cd (hg-root))))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
Emacs: implement hg-incoming, hg-outgoing and hg-push.
r1029 (defun hg-push (&optional repo)
"Push changes to repository REPO."
(interactive (list (hg-read-repo-name " to push to")))
(hg-view-output ((format "Mercurial: Push from %s to %s"
(hg-abbrev-file-name (hg-root))
(hg-abbrev-file-name
(or repo hg-outgoing-repository))))
(call-process (hg-binary) nil t nil "push"
FUJIWARA Katsunori
Emacs: change directory of output buffer to the root of the repository.
r2454 (or repo hg-outgoing-repository))
(cd (hg-root))))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995 (defun hg-revert-buffer-internal ()
(let ((ctx (hg-buffer-context)))
(message "Reverting %s..." buffer-file-name)
(hg-run0 "revert" buffer-file-name)
(revert-buffer t t t)
(hg-restore-context ctx)
(hg-mode-line)
(message "Reverting %s...done" buffer-file-name)))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995 (defun hg-revert-buffer ()
Bryan O'Sullivan
Emacs: document existing functions.
r996 "Revert current buffer's file back to the latest committed version.
If the file has not changed, nothing happens. Otherwise, this
displays a diff and asks for confirmation before reverting."
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944 (interactive)
Bryan O'Sullivan
Emacs support: add hg-revert-buffer.
r995 (let ((vc-suppress-confirm nil)
(obuf (current-buffer))
diff)
(vc-buffer-sync)
(unwind-protect
(setq diff (hg-diff buffer-file-name))
(when diff
(unless (yes-or-no-p "Discard changes? ")
(error "Revert cancelled")))
(when diff
(let ((buf (current-buffer)))
(delete-window (selected-window))
(kill-buffer buf))))
(set-buffer obuf)
(when diff
(hg-revert-buffer-internal))))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
(defun hg-root (&optional path)
Bryan O'Sullivan
Emacs: document existing functions.
r996 "Return the root of the repository that contains the given path.
If the path is outside a repository, return nil.
When called interactively, the root is printed. A prefix argument
prompts for a path to check."
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (interactive (list (hg-read-file-name)))
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (if (or path (not hg-root))
(let ((root (do ((prev nil dir)
FUJIWARA Katsunori
Emacs: use `default-directory' if `buffer-file-name' is null....
r2453 (dir (file-name-directory
(or
path
buffer-file-name
(expand-file-name default-directory)))
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 (file-name-directory (directory-file-name dir))))
((equal prev dir))
(when (file-directory-p (concat dir ".hg"))
(return dir)))))
(when (interactive-p)
(if root
(message "The root of this repository is `%s'." root)
(message "The path `%s' is not in a Mercurial repository."
Bryan O'Sullivan
Emacs: implement hg-incoming, hg-outgoing and hg-push.
r1029 (hg-abbrev-file-name path))))
bos@serpentine.internal.keyresearch.com
Emacs support: numerous changes....
r1003 root)
hg-root))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
Bryan O'Sullivan
mercurial.el: add hg-cwd
r3003 (defun hg-cwd (&optional path)
"Return the current directory of PATH within the repository."
(do ((stack nil (cons (file-name-nondirectory
(directory-file-name dir))
stack))
(prev nil dir)
(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"))
(let ((cwd (mapconcat 'identity stack "/")))
(unless (equal cwd "")
(return (file-name-as-directory cwd)))))))
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (defun hg-status (path)
Bryan O'Sullivan
Emacs: document existing functions.
r996 "Print revision control status of a file or directory.
With prefix argument, prompt for the path to give status for.
Names are displayed relative to the repository root."
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (interactive (list (hg-read-file-name " for status" (hg-root))))
(let ((root (hg-root)))
Bryan O'Sullivan
Emacs: document existing functions.
r996 (hg-view-output ((format "Mercurial: Status of %s in %s"
(let ((name (substring (expand-file-name path)
(length root))))
(if (> (length name) 0)
name
"*"))
(hg-abbrev-file-name root)))
Bryan O'Sullivan
In-progress Emacs snapshot.
r947 (apply 'call-process (hg-binary) nil t nil
FUJIWARA Katsunori
Emacs: change directory of output buffer to the root of the repository.
r2454 (list "--cwd" root "status" path))
(cd (hg-root path)))))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
(defun hg-undo ()
(interactive)
(error "not implemented"))
Bryan O'Sullivan
mercurial.el: implement hg-pull, and stub in hg-update.
r1246 (defun hg-update ()
(interactive)
(error "not implemented"))
jon.christopher@Rigaku.com
Re: mercurial.el and hg-version-other-window...
r4875 (defun hg-version-other-window (rev)
"Visit version REV of the current file in another window.
If the current file is named `F', the version is named `F.~REV~'.
If `F.~REV~' already exists, use it instead of checking it out again."
(interactive "sVersion to visit (default is workfile version): ")
(let* ((file buffer-file-name)
(version (if (string-equal rev "")
"tip"
rev))
(automatic-backup (vc-version-backup-file-name file version))
(manual-backup (vc-version-backup-file-name file version 'manual)))
(unless (file-exists-p manual-backup)
(if (file-exists-p automatic-backup)
(rename-file automatic-backup manual-backup nil)
(hg-run0 "-q" "cat" "-r" version "-o" manual-backup file)))
(find-file-other-window manual-backup)))
Bryan O'Sullivan
Initial skeleton for mercurial.el.
r944
(provide 'mercurial)
;;; Local Variables:
;;; prompt-to-byte-compile: nil
;;; end: