Mercurial > hg > mercurial-crew-with-dirclash
annotate contrib/mercurial.el @ 965:a425123e6afe
Use post-expanded clone pathname as default
author | mpm@selenic.com |
---|---|
date | Fri, 19 Aug 2005 22:48:43 -0800 |
parents | d845a1f174bb |
children | 1e4b009b379e |
rev | line source |
---|---|
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1 ;;; mercurial.el --- Emacs support for the Mercurial distributed SCM |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
2 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
3 ;; Copyright (C) 2005 Bryan O'Sullivan |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
4 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
5 ;; Author: Bryan O'Sullivan <bos@serpentine.com> |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
6 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
7 ;; $Id$ |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
8 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
9 ;; mercurial.el is free software; you can redistribute it and/or |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
10 ;; modify it under the terms of version 2 of the GNU General Public |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
11 ;; License as published by the Free Software Foundation. |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
12 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
13 ;; mercurial.el is distributed in the hope that it will be useful, but |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
16 ;; General Public License for more details. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
17 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
18 ;; You should have received a copy of the GNU General Public License |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
19 ;; along with mercurial.el, GNU Emacs, or XEmacs; see the file COPYING |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
20 ;; (`C-h C-l'). If not, write to the Free Software Foundation, Inc., |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
21 ;; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
22 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
23 ;;; Commentary: |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
24 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
25 ;; This mode builds upon Emacs's VC mode to provide flexible |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
26 ;; integration with the Mercurial distributed SCM tool. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
27 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
28 ;; To get going as quickly as possible, load mercurial.el into Emacs and |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
29 ;; type `C-c h h'; this runs hg-help-overview, which prints a helpful |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
30 ;; usage overview. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
31 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
32 ;; Much of the inspiration for mercurial.el comes from Rajesh |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
33 ;; Vaidheeswarran's excellent p4.el, which does an admirably thorough |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
34 ;; job for the commercial Perforce SCM product. In fact, substantial |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
35 ;; chunks of code are adapted from p4.el. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
36 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
37 ;; This code has been developed under XEmacs 21.5, and may will not |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
38 ;; work as well under GNU Emacs (albeit tested under 21.2). Patches |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
39 ;; to enhance the portability of this code, fix bugs, and add features |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
40 ;; are most welcome. You can clone a Mercurial repository for this |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
41 ;; package from http://www.serpentine.com/hg/hg-emacs |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
42 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
43 ;; Please send problem reports and suggestions to bos@serpentine.com. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
44 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
45 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
46 ;;; Code: |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
47 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
48 (require 'advice) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
49 (require 'cl) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
50 (require 'diff-mode) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
51 (require 'easymenu) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
52 (require 'vc) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
53 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
54 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
55 ;;; XEmacs has view-less, while GNU Emacs has view. Joy. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
56 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
57 (condition-case nil |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
58 (require 'view-less) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
59 (error nil)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
60 (condition-case nil |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
61 (require 'view) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
62 (error nil)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
63 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
64 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
65 ;;; Variables accessible through the custom system. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
66 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
67 (defgroup mercurial nil |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
68 "Mercurial distributed SCM." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
69 :group 'tools) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
70 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
71 (defcustom hg-binary |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
72 (dolist (path '("~/bin/hg" |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
73 "/usr/bin/hg" |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
74 "/usr/local/bin/hg")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
75 (when (file-executable-p path) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
76 (return path))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
77 "The path to Mercurial's hg executable." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
78 :type '(file :must-match t) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
79 :group 'mercurial) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
80 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
81 (defcustom hg-mode-hook nil |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
82 "Hook run when a buffer enters hg-mode." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
83 :type 'sexp |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
84 :group 'mercurial) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
85 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
86 (defcustom hg-global-prefix "\C-ch" |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
87 "The global prefix for Mercurial keymap bindings." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
88 :type 'sexp |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
89 :group 'mercurial) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
90 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
91 (defcustom hg-rev-completion-limit 100 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
92 "The maximum number of revisions that hg-read-rev will offer to complete. |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
93 This affects memory usage and performance when prompting for revisions |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
94 in a repository with a lot of history." |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
95 :type 'integer |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
96 :group 'mercurial) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
97 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
98 (defcustom hg-log-limit 50 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
99 "The maximum number of revisions that hg-log will display." |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
100 :type 'integer |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
101 :group 'mercurial) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
102 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
103 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
104 ;;; Other variables. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
105 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
106 (defconst hg-running-xemacs (string-match "XEmacs" emacs-version) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
107 "Is mercurial.el running under XEmacs?") |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
108 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
109 (defvar hg-mode nil |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
110 "Is this file managed by Mercurial?") |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
111 (make-variable-buffer-local 'hg-mode) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
112 (put 'hg-mode 'permanent-local t) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
113 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
114 (defvar hg-status nil) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
115 (make-variable-buffer-local 'hg-status) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
116 (put 'hg-status 'permanent-local t) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
117 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
118 (defvar hg-output-buffer-name "*Hg*" |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
119 "The name to use for Mercurial output buffers.") |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
120 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
121 (defvar hg-file-history nil) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
122 (defvar hg-rev-history nil) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
123 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
124 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
125 ;;; hg-mode keymap. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
126 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
127 (defvar hg-prefix-map |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
128 (let ((map (copy-keymap vc-prefix-map))) |
958 | 129 (if (functionp 'set-keymap-name) |
130 (set-keymap-name map 'hg-prefix-map)); XEmacs | |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
131 map) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
132 "This keymap overrides some default vc-mode bindings.") |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
133 (fset 'hg-prefix-map hg-prefix-map) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
134 (define-key hg-prefix-map "=" 'hg-diff) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
135 (define-key hg-prefix-map "c" 'hg-undo) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
136 (define-key hg-prefix-map "g" 'hg-annotate) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
137 (define-key hg-prefix-map "l" 'hg-log) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
138 (define-key hg-prefix-map "n" 'hg-commit-file) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
139 ;; (define-key hg-prefix-map "r" 'hg-update) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
140 (define-key hg-prefix-map "u" 'hg-revert-file) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
141 (define-key hg-prefix-map "~" 'hg-version-other-window) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
142 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
143 (defvar hg-mode-map (make-sparse-keymap)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
144 (define-key hg-mode-map "\C-xv" 'hg-prefix-map) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
145 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
146 (add-minor-mode 'hg-mode 'hg-mode hg-mode-map) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
147 |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
148 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
149 ;;; Global keymap. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
150 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
151 (global-set-key "\C-xvi" 'hg-add) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
152 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
153 (defvar hg-global-map (make-sparse-keymap)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
154 (fset 'hg-global-map hg-global-map) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
155 (global-set-key hg-global-prefix 'hg-global-map) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
156 (define-key hg-global-map "," 'hg-incoming) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
157 (define-key hg-global-map "." 'hg-outgoing) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
158 (define-key hg-global-map "<" 'hg-pull) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
159 (define-key hg-global-map "=" 'hg-diff) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
160 (define-key hg-global-map ">" 'hg-push) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
161 (define-key hg-global-map "?" 'hg-help-overview) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
162 (define-key hg-global-map "A" 'hg-addremove) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
163 (define-key hg-global-map "U" 'hg-revert) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
164 (define-key hg-global-map "a" 'hg-add) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
165 (define-key hg-global-map "c" 'hg-commit) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
166 (define-key hg-global-map "f" 'hg-forget) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
167 (define-key hg-global-map "h" 'hg-help-overview) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
168 (define-key hg-global-map "i" 'hg-init) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
169 (define-key hg-global-map "l" 'hg-log) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
170 (define-key hg-global-map "r" 'hg-root) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
171 (define-key hg-global-map "s" 'hg-status) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
172 (define-key hg-global-map "u" 'hg-update) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
173 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
174 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
175 ;;; View mode keymap. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
176 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
177 (defvar hg-view-mode-map |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
178 (let ((map (copy-keymap (if (boundp 'view-minor-mode-map) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
179 view-minor-mode-map |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
180 view-mode-map)))) |
958 | 181 (if (functionp 'set-keymap-name) |
182 (set-keymap-name map 'hg-view-mode-map)); XEmacs | |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
183 map)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
184 (fset 'hg-view-mode-map hg-view-mode-map) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
185 (define-key hg-view-mode-map |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
186 (if hg-running-xemacs [button2] [mouse-2]) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
187 'hg-buffer-mouse-clicked) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
188 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
189 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
190 ;;; Convenience functions. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
191 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
192 (defun hg-binary () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
193 (if hg-binary |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
194 hg-binary |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
195 (error "No `hg' executable found!"))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
196 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
197 (defun hg-replace-in-string (str regexp newtext &optional literal) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
198 "Replace all matches in STR for REGEXP with NEWTEXT string. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
199 Return the new string. Optional LITERAL non-nil means do a literal |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
200 replacement. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
201 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
202 This function bridges yet another pointless impedance gap between |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
203 XEmacs and GNU Emacs." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
204 (if (fboundp 'replace-in-string) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
205 (replace-in-string str regexp newtext literal) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
206 (replace-regexp-in-string regexp newtext str nil literal))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
207 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
208 (defun hg-chomp (str) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
209 "Strip trailing newlines from a string." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
210 (hg-replace-in-string str "[\r\n]+$" "")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
211 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
212 (defun hg-run-command (command &rest args) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
213 "Run the shell command COMMAND, returning (EXIT-CODE . COMMAND-OUTPUT). |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
214 The list ARGS contains a list of arguments to pass to the command." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
215 (let* (exit-code |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
216 (output |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
217 (with-output-to-string |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
218 (with-current-buffer |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
219 standard-output |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
220 (setq exit-code |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
221 (apply 'call-process command nil t nil args)))))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
222 (cons exit-code output))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
223 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
224 (defun hg-run (command &rest args) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
225 "Run the Mercurial command COMMAND, returning (EXIT-CODE . COMMAND-OUTPUT)." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
226 (apply 'hg-run-command (hg-binary) command args)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
227 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
228 (defun hg-run0 (command &rest args) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
229 "Run the Mercurial command COMMAND, returning its output. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
230 If the command does not exit with a zero status code, raise an error." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
231 (let ((res (apply 'hg-run-command (hg-binary) command args))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
232 (if (not (eq (car res) 0)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
233 (error "Mercurial command failed %s - exit code %s" |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
234 (cons command args) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
235 (car res)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
236 (cdr res)))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
237 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
238 (defun hg-buffer-commands (pnt) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
239 "Use the properties of a character to do something sensible." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
240 (interactive "d") |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
241 (let ((rev (get-char-property pnt 'rev)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
242 (file (get-char-property pnt 'file)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
243 (date (get-char-property pnt 'date)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
244 (user (get-char-property pnt 'user)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
245 (host (get-char-property pnt 'host)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
246 (prev-buf (current-buffer))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
247 (cond |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
248 (file |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
249 (find-file-other-window file)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
250 (rev |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
251 (hg-diff hg-view-file-name rev rev prev-buf)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
252 ((message "I don't know how to do that yet"))))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
253 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
254 (defun hg-buffer-mouse-clicked (event) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
255 "Translate the mouse clicks in a HG log buffer to character events. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
256 These are then handed off to `hg-buffer-commands'. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
257 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
258 Handle frickin' frackin' gratuitous event-related incompatibilities." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
259 (interactive "e") |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
260 (if hg-running-xemacs |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
261 (progn |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
262 (select-window (event-window event)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
263 (hg-buffer-commands (event-point event))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
264 (select-window (posn-window (event-end event))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
265 (hg-buffer-commands (posn-point (event-start event))))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
266 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
267 (unless (fboundp 'view-minor-mode) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
268 (defun view-minor-mode (prev-buffer exit-func) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
269 (view-mode))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
270 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
271 (defun hg-abbrev-file-name (file) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
272 (if hg-running-xemacs |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
273 (abbreviate-file-name file t) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
274 (abbreviate-file-name file))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
275 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
276 (defun hg-read-file-name (&optional prompt default) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
277 "Read a file or directory name, or a pattern, to use with a command." |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
278 (let ((path (or default (buffer-file-name)))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
279 (if (or (not path) current-prefix-arg) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
280 (expand-file-name |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
281 (read-file-name (format "File, directory or pattern%s: " |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
282 (or prompt "")) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
283 (and path (file-name-directory path)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
284 nil nil |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
285 (and path (file-name-nondirectory path)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
286 'hg-file-history)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
287 path))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
288 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
289 (defun hg-read-rev (&optional prompt default) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
290 "Read a revision or tag, offering completions." |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
291 (let ((rev (or default "tip"))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
292 (if (or (not rev) current-prefix-arg) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
293 (let ((revs (split-string (hg-chomp |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
294 (hg-run0 "-q" "log" "-r" |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
295 (format "-%d" |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
296 hg-rev-completion-limit) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
297 "-r" "tip")) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
298 "[\n:]"))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
299 (dolist (line (split-string (hg-chomp (hg-run0 "tags")) "\n")) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
300 (setq revs (cons (car (split-string line "\\s-")) revs))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
301 (completing-read (format "Revision%s (%s): " |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
302 (or prompt "") |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
303 (or default "tip")) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
304 (map 'list 'cons revs revs) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
305 nil |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
306 nil |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
307 nil |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
308 'hg-rev-history |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
309 (or default "tip"))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
310 rev))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
311 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
312 ;;; View mode bits. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
313 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
314 (defun hg-exit-view-mode (buf) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
315 "Exit from hg-view-mode. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
316 We delete the current window if entering hg-view-mode split the |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
317 current frame." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
318 (when (and (eq buf (current-buffer)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
319 (> (length (window-list)) 1)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
320 (delete-window)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
321 (when (buffer-live-p buf) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
322 (kill-buffer buf))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
323 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
324 (defun hg-view-mode (prev-buffer &optional file-name) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
325 (goto-char (point-min)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
326 (set-buffer-modified-p nil) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
327 (toggle-read-only t) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
328 (view-minor-mode prev-buffer 'hg-exit-view-mode) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
329 (use-local-map hg-view-mode-map) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
330 (setq truncate-lines t) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
331 (when file-name |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
332 (set (make-local-variable 'hg-view-file-name) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
333 (hg-abbrev-file-name file-name)))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
334 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
335 (defun hg-file-status (file) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
336 "Return status of FILE, or nil if FILE does not exist or is unmanaged." |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
337 (let* ((s (hg-run "status" file)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
338 (exit (car s)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
339 (output (cdr s))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
340 (if (= exit 0) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
341 (let ((state (assoc (substring output 0 (min (length output) 2)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
342 '(("M " . modified) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
343 ("A " . added) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
344 ("R " . removed))))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
345 (if state |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
346 (cdr state) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
347 'normal))))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
348 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
349 (defun hg-tip () |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
350 (split-string (hg-chomp (hg-run0 "-q" "tip")) ":")) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
351 |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
352 (defmacro hg-view-output (args &rest body) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
353 "Execute BODY in a clean buffer, then quickly display that buffer. |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
354 If the buffer contains one line, its contents are displayed in the |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
355 minibuffer. Otherwise, the buffer is displayed in view-mode. |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
356 ARGS is of the form (BUFFER-NAME &optional FILE), where BUFFER-NAME is |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
357 the name of the buffer to create, and FILE is the name of the file |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
358 being viewed." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
359 (let ((prev-buf (gensym "prev-buf-")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
360 (v-b-name (car args)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
361 (v-m-rest (cdr args))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
362 `(let ((view-buf-name ,v-b-name) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
363 (,prev-buf (current-buffer))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
364 (get-buffer-create view-buf-name) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
365 (kill-buffer view-buf-name) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
366 (get-buffer-create view-buf-name) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
367 (set-buffer view-buf-name) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
368 (save-excursion |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
369 ,@body) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
370 (case (count-lines (point-min) (point-max)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
371 ((0) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
372 (kill-buffer view-buf-name) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
373 (message "(No output)")) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
374 ((1) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
375 (let ((msg (hg-chomp (buffer-substring (point-min) (point-max))))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
376 (kill-buffer view-buf-name) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
377 (message "%s" msg))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
378 (t |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
379 (pop-to-buffer view-buf-name) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
380 (hg-view-mode ,prev-buf ,@v-m-rest)))))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
381 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
382 (put 'hg-view-output 'lisp-indent-function 1) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
383 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
384 ;;; Hooks. |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
385 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
386 (defun hg-mode-line () |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
387 (when (hg-root) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
388 (let ((status (hg-file-status buffer-file-name))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
389 (setq hg-status status |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
390 hg-mode (and status (concat " Hg:" |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
391 (car (hg-tip)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
392 (cdr (assq status |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
393 '((normal . "") |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
394 (removed . "r") |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
395 (added . "a") |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
396 (modified . "m"))))))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
397 status))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
398 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
399 (defun hg-find-file-hook () |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
400 (when (hg-mode-line) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
401 (run-hooks 'hg-mode-hook))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
402 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
403 (add-hook 'find-file-hooks 'hg-find-file-hook) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
404 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
405 (defun hg-after-save-hook () |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
406 (let ((old-status hg-status)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
407 (hg-mode-line) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
408 (if (and (not old-status) hg-status) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
409 (run-hooks 'hg-mode-hook)))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
410 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
411 (add-hook 'after-save-hook 'hg-after-save-hook) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
412 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
413 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
414 ;;; User interface functions. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
415 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
416 (defun hg-help-overview () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
417 "This is an overview of the Mercurial SCM mode for Emacs. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
418 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
419 You can find the source code, license (GPL v2), and credits for this |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
420 code by typing `M-x find-library mercurial RET'. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
421 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
422 The Mercurial mode user interface is based on that of the older VC |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
423 mode, so if you're already familiar with VC, the same keybindings and |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
424 functions will generally work. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
425 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
426 Below is a list of common SCM tasks, with the key bindings needed to |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
427 perform them, and the command names. This list is not exhaustive. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
428 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
429 In the list below, `G/L' indicates whether a key binding is global (G) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
430 or local (L). Global keybindings work on any file inside a Mercurial |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
431 repository. Local keybindings only apply to files under the control |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
432 of Mercurial. Many commands take a prefix argument. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
433 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
434 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
435 SCM Task G/L Key Binding Command Name |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
436 -------- --- ----------- ------------ |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
437 Help overview (what you are reading) G C-c h h hg-help-overview |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
438 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
439 Tell Mercurial to manage a file G C-c h a hg-add |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
440 Commit changes to current file only L C-x v n hg-commit |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
441 Undo changes to file since commit L C-x v u hg-revert-file |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
442 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
443 Diff file vs last checkin L C-x v = hg-diff |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
444 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
445 View file change history L C-x v l hg-log |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
446 View annotated file L C-x v a hg-annotate |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
447 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
448 Diff repo vs last checkin G C-c h = hg-diff |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
449 View status of files in repo G C-c h s hg-status |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
450 Commit all changes G C-c h c hg-commit |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
451 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
452 Undo all changes since last commit G C-c h U hg-revert |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
453 View repo change history G C-c h l hg-log |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
454 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
455 See changes that can be pulled G C-c h , hg-incoming |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
456 Pull changes G C-c h < hg-pull |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
457 Update working directory after pull G C-c h u hg-update |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
458 See changes that can be pushed G C-c h . hg-outgoing |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
459 Push changes G C-c h > hg-push" |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
460 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
461 (hg-view-output ("Mercurial Help Overview") |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
462 (insert (documentation 'hg-help-overview)))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
463 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
464 (defun hg-add (path) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
465 (interactive (list (hg-read-file-name " to add"))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
466 (let ((buf (current-buffer)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
467 (update (equal buffer-file-name path))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
468 (hg-view-output (hg-output-buffer-name) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
469 (apply 'call-process (hg-binary) nil t nil (list "add" path))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
470 (when update |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
471 (with-current-buffer buf |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
472 (hg-mode-line))))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
473 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
474 (defun hg-addremove () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
475 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
476 (error "not implemented")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
477 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
478 (defun hg-annotate () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
479 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
480 (error "not implemented")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
481 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
482 (defun hg-commit () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
483 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
484 (error "not implemented")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
485 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
486 (defun hg-diff (path &optional rev1 rev2) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
487 (interactive (list (hg-read-file-name " to diff") |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
488 (hg-read-rev " to start with") |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
489 (let ((rev2 (hg-read-rev " to end with" 'working-dir))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
490 (and (not (eq rev2 'working-dir)) rev2)))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
491 (let ((a-path (hg-abbrev-file-name path))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
492 (hg-view-output ((if (equal rev1 rev2) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
493 (format "Mercurial: Rev %s of %s" rev1 a-path) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
494 (format "Mercurial: Rev %s to %s of %s" |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
495 rev1 (or rev2 "Current") a-path))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
496 (if rev2 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
497 (call-process (hg-binary) nil t nil "diff" "-r" rev1 "-r" rev2 path) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
498 (call-process (hg-binary) nil t nil "diff" "-r" rev1 path)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
499 (diff-mode) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
500 (font-lock-fontify-buffer)))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
501 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
502 (defun hg-forget (path) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
503 (interactive (list (hg-read-file-name " to forget"))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
504 (let ((buf (current-buffer)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
505 (update (equal buffer-file-name path))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
506 (hg-view-output (hg-output-buffer-name) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
507 (apply 'call-process (hg-binary) nil t nil (list "forget" path))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
508 (when update |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
509 (with-current-buffer buf |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
510 (hg-mode-line))))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
511 |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
512 (defun hg-incoming () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
513 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
514 (error "not implemented")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
515 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
516 (defun hg-init () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
517 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
518 (error "not implemented")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
519 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
520 (defun hg-log (path &optional rev1 rev2) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
521 (interactive (list (hg-read-file-name " to log") |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
522 (hg-read-rev " to start with" "-1") |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
523 (hg-read-rev " to end with" (format "-%d" hg-log-limit)))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
524 (message "log %s %s" rev1 rev2) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
525 (sit-for 1) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
526 (let ((a-path (hg-abbrev-file-name path))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
527 (hg-view-output ((if (equal rev1 rev2) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
528 (format "Mercurial: Rev %s of %s" rev1 a-path) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
529 (format "Mercurial: Rev %s to %s of %s" |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
530 rev1 (or rev2 "Current") a-path))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
531 (call-process (hg-binary) nil t nil "log" "-r" rev1 "-r" rev2 path) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
532 (diff-mode) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
533 (font-lock-fontify-buffer)))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
534 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
535 (defun hg-outgoing () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
536 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
537 (error "not implemented")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
538 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
539 (defun hg-pull () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
540 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
541 (error "not implemented")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
542 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
543 (defun hg-push () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
544 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
545 (error "not implemented")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
546 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
547 (defun hg-revert () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
548 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
549 (error "not implemented")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
550 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
551 (defun hg-revert-file () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
552 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
553 (error "not implemented")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
554 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
555 (defun hg-root (&optional path) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
556 (interactive (list (hg-read-file-name))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
557 (let ((root (do ((prev nil dir) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
558 (dir (file-name-directory (or path (buffer-file-name))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
559 (file-name-directory (directory-file-name dir)))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
560 ((equal prev dir)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
561 (when (file-directory-p (concat dir ".hg")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
562 (return dir))))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
563 (when (interactive-p) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
564 (if root |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
565 (message "The root of this repository is `%s'." root) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
566 (message "The path `%s' is not in a Mercurial repository." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
567 (abbreviate-file-name path t)))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
568 root)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
569 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
570 (defun hg-status (path) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
571 (interactive (list (hg-read-file-name " for status" (hg-root)))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
572 (let ((root (hg-root))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
573 (hg-view-output (hg-output-buffer-name) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
574 (apply 'call-process (hg-binary) nil t nil |
955 | 575 (list "--cwd" root "status" path))))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
576 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
577 (defun hg-undo () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
578 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
579 (error "not implemented")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
580 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
581 (defun hg-version-other-window () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
582 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
583 (error "not implemented")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
584 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
585 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
586 (provide 'mercurial) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
587 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
588 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
589 ;;; Local Variables: |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
590 ;;; mode: emacs-lisp |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
591 ;;; prompt-to-byte-compile: nil |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
592 ;;; end: |