Mercurial > hg
annotate contrib/mercurial.el @ 36043:223ed0b53f08
py3: more robustly cast UUID to bytes
The UUID type only has __str__ implemented. So we need to cast to
bytes on Python 3.
We need an actual bytes instance here (bytestr won't do) because
the re.escape() later iterates over characters and characters
need to behave like ints, not bytes instances of length 1.
Differential Revision: https://phab.mercurial-scm.org/D2144
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 11 Feb 2018 13:23:26 -0800 |
parents | 927d704d7847 |
children |
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 |
2997
48baf9fb1921
mercurial.el: get rid of unportable, unperformant use of replace-regexp.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2877
diff
changeset
|
3 ;; Copyright (C) 2005, 2006 Bryan O'Sullivan |
944
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 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
7 ;; mercurial.el is free software; you can redistribute it and/or |
10268
2fa95306d40c
mercurial.el: add forgotten version number
Martin Geisler <mg@lazybytes.net>
parents:
10263
diff
changeset
|
8 ;; modify it under the terms of the GNU General Public License version |
2fa95306d40c
mercurial.el: add forgotten version number
Martin Geisler <mg@lazybytes.net>
parents:
10263
diff
changeset
|
9 ;; 2 or any later version. |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
10 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
11 ;; 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
|
12 ;; WITHOUT ANY WARRANTY; without even the implied warranty of |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
13 ;; 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
|
14 ;; General Public License for more details. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
15 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
16 ;; 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
|
17 ;; along with mercurial.el, GNU Emacs, or XEmacs; see the file COPYING |
15782
7de7630053cb
Remove FSF mailing address from GPL headers
Martin Geisler <mg@aragost.com>
parents:
12796
diff
changeset
|
18 ;; (`C-h C-l'). If not, see <http://www.gnu.org/licenses/>. |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
19 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
20 ;;; Commentary: |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
21 |
1004
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
22 ;; mercurial.el builds upon Emacs's VC mode to provide flexible |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
23 ;; integration with the Mercurial distributed SCM tool. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
24 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
25 ;; 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
|
26 ;; 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
|
27 ;; usage overview. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
28 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
29 ;; 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
|
30 ;; 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
|
31 ;; 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
|
32 ;; chunks of code are adapted from p4.el. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
33 |
1004
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
34 ;; This code has been developed under XEmacs 21.5, and may not work as |
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
35 ;; well under GNU Emacs (albeit tested under 21.4). Patches to |
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
36 ;; enhance the portability of this code, fix bugs, and add features |
6390
67784cb38d58
mercurial.el: note new Emacs VC mode support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5467
diff
changeset
|
37 ;; are most welcome. |
67784cb38d58
mercurial.el: note new Emacs VC mode support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5467
diff
changeset
|
38 |
67784cb38d58
mercurial.el: note new Emacs VC mode support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5467
diff
changeset
|
39 ;; As of version 22.3, GNU Emacs's VC mode has direct support for |
67784cb38d58
mercurial.el: note new Emacs VC mode support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5467
diff
changeset
|
40 ;; Mercurial, so this package may not prove as useful there. |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
41 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
42 ;; 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
|
43 |
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 ;;; Code: |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
46 |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
47 (eval-when-compile (require 'cl)) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
48 (require 'diff-mode) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
49 (require 'easymenu) |
1024
5b257e419816
Sync buffers prior to doing a diff.
bos@serpentine.internal.keyresearch.com
parents:
1011
diff
changeset
|
50 (require 'executable) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
51 (require 'vc) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
52 |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
53 (defmacro hg-feature-cond (&rest clauses) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
54 "Test CLAUSES for feature at compile time. |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
55 Each clause is (FEATURE BODY...)." |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
56 (dolist (x clauses) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
57 (let ((feature (car x)) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
58 (body (cdr x))) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
59 (when (or (eq feature t) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
60 (featurep feature)) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
61 (return (cons 'progn body)))))) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
62 |
944
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 ;;; 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
|
65 |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
66 (hg-feature-cond |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
67 (xemacs (require 'view-less)) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
68 (t (require 'view))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
69 |
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 ;;; Variables accessible through the custom system. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
72 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
73 (defgroup mercurial nil |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
74 "Mercurial distributed SCM." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
75 :group 'tools) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
76 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
77 (defcustom hg-binary |
1011
d06420c90d8b
Emacs: search for hg in path before looking in funny places.
bos@serpentine.internal.keyresearch.com
parents:
1004
diff
changeset
|
78 (or (executable-find "hg") |
d06420c90d8b
Emacs: search for hg in path before looking in funny places.
bos@serpentine.internal.keyresearch.com
parents:
1004
diff
changeset
|
79 (dolist (path '("~/bin/hg" "/usr/bin/hg" "/usr/local/bin/hg")) |
d06420c90d8b
Emacs: search for hg in path before looking in funny places.
bos@serpentine.internal.keyresearch.com
parents:
1004
diff
changeset
|
80 (when (file-executable-p path) |
d06420c90d8b
Emacs: search for hg in path before looking in funny places.
bos@serpentine.internal.keyresearch.com
parents:
1004
diff
changeset
|
81 (return path)))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
82 "The path to Mercurial's hg executable." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
83 :type '(file :must-match t) |
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-mode-hook nil |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
87 "Hook run when a buffer enters hg-mode." |
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) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
90 |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
91 (defcustom hg-commit-mode-hook nil |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
92 "Hook run when a buffer is created to prepare a commit." |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
93 :type 'sexp |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
94 :group 'mercurial) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
95 |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
96 (defcustom hg-pre-commit-hook nil |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
97 "Hook run before a commit is performed. |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
98 If you want to prevent the commit from proceeding, raise an error." |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
99 :type 'sexp |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
100 :group 'mercurial) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
101 |
1029
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
102 (defcustom hg-log-mode-hook nil |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
103 "Hook run after a buffer is filled with log information." |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
104 :type 'sexp |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
105 :group 'mercurial) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
106 |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
107 (defcustom hg-global-prefix "\C-ch" |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
108 "The global prefix for Mercurial keymap bindings." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
109 :type 'sexp |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
110 :group 'mercurial) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
111 |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
112 (defcustom hg-commit-allow-empty-message nil |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
113 "Whether to allow changes to be committed with empty descriptions." |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
114 :type 'boolean |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
115 :group 'mercurial) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
116 |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
117 (defcustom hg-commit-allow-empty-file-list nil |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
118 "Whether to allow changes to be committed without any modified files." |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
119 :type 'boolean |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
120 :group 'mercurial) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
121 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
122 (defcustom hg-rev-completion-limit 100 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
123 "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
|
124 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
|
125 in a repository with a lot of history." |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
126 :type 'integer |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
127 :group 'mercurial) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
128 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
129 (defcustom hg-log-limit 50 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
130 "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
|
131 :type 'integer |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
132 :group 'mercurial) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
133 |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
134 (defcustom hg-update-modeline t |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
135 "Whether to update the modeline with the status of a file after every save. |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
136 Set this to nil on platforms with poor process management, such as Windows." |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
137 :type 'boolean |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
138 :group 'mercurial) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
139 |
1029
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
140 (defcustom hg-incoming-repository "default" |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
141 "The repository from which changes are pulled from by default. |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
142 This should be a symbolic repository name, since it is used for all |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
143 repository-related commands." |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
144 :type 'string |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
145 :group 'mercurial) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
146 |
12796
bc69ba99e34b
mercurial.el: fix hg-outgoing path when 'default-push' is not defined
Azhagu Selvan SP <tamizhgeek@gmail.com>
parents:
10268
diff
changeset
|
147 (defcustom hg-outgoing-repository "" |
1029
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
148 "The repository to which changes are pushed to by default. |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
149 This should be a symbolic repository name, since it is used for all |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
150 repository-related commands." |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
151 :type 'string |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
152 :group 'mercurial) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
153 |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
154 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
155 ;;; Other variables. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
156 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
157 (defvar hg-mode nil |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
158 "Is this file managed by Mercurial?") |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
159 (make-variable-buffer-local 'hg-mode) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
160 (put 'hg-mode 'permanent-local t) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
161 |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
162 (defvar hg-status nil) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
163 (make-variable-buffer-local 'hg-status) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
164 (put 'hg-status 'permanent-local t) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
165 |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
166 (defvar hg-prev-buffer nil) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
167 (make-variable-buffer-local 'hg-prev-buffer) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
168 (put 'hg-prev-buffer 'permanent-local t) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
169 |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
170 (defvar hg-root nil) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
171 (make-variable-buffer-local 'hg-root) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
172 (put 'hg-root 'permanent-local t) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
173 |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
174 (defvar hg-view-mode nil) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
175 (make-variable-buffer-local 'hg-view-mode) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
176 (put 'hg-view-mode 'permanent-local t) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
177 |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
178 (defvar hg-view-file-name nil) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
179 (make-variable-buffer-local 'hg-view-file-name) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
180 (put 'hg-view-file-name 'permanent-local t) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
181 |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
182 (defvar hg-output-buffer-name "*Hg*" |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
183 "The name to use for Mercurial output buffers.") |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
184 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
185 (defvar hg-file-history nil) |
1029
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
186 (defvar hg-repo-history nil) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
187 (defvar hg-rev-history nil) |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
188 (defvar hg-repo-completion-table nil) ; shut up warnings |
944
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 |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
191 ;;; Random constants. |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
192 |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
193 (defconst hg-commit-message-start |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
194 "--- Enter your commit message. Type `C-c C-c' to commit. ---\n") |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
195 |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
196 (defconst hg-commit-message-end |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
197 "--- Files in bold will be committed. Click to toggle selection. ---\n") |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
198 |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
199 (defconst hg-state-alist |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
200 '((?M . modified) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
201 (?A . added) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
202 (?R . removed) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
203 (?! . deleted) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
204 (?C . normal) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
205 (?I . ignored) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
206 (?? . nil))) |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
207 |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
208 ;;; hg-mode keymap. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
209 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
210 (defvar hg-prefix-map |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
211 (let ((map (make-sparse-keymap))) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
212 (hg-feature-cond (xemacs (set-keymap-name map 'hg-prefix-map))) ; XEmacs |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
213 (set-keymap-parent map vc-prefix-map) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
214 (define-key map "=" 'hg-diff) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
215 (define-key map "c" 'hg-undo) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
216 (define-key map "g" 'hg-annotate) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
217 (define-key map "i" 'hg-add) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
218 (define-key map "l" 'hg-log) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
219 (define-key map "n" 'hg-commit-start) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
220 ;; (define-key map "r" 'hg-update) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
221 (define-key map "u" 'hg-revert-buffer) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
222 (define-key map "~" 'hg-version-other-window) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
223 map) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
224 "This keymap overrides some default vc-mode bindings.") |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
225 |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
226 (defvar hg-mode-map |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
227 (let ((map (make-sparse-keymap))) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
228 (define-key map "\C-xv" hg-prefix-map) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
229 map)) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
230 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
231 (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
|
232 |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
233 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
234 ;;; Global keymap. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
235 |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
236 (defvar hg-global-map |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
237 (let ((map (make-sparse-keymap))) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
238 (define-key map "," 'hg-incoming) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
239 (define-key map "." 'hg-outgoing) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
240 (define-key map "<" 'hg-pull) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
241 (define-key map "=" 'hg-diff-repo) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
242 (define-key map ">" 'hg-push) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
243 (define-key map "?" 'hg-help-overview) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
244 (define-key map "A" 'hg-addremove) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
245 (define-key map "U" 'hg-revert) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
246 (define-key map "a" 'hg-add) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
247 (define-key map "c" 'hg-commit-start) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
248 (define-key map "f" 'hg-forget) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
249 (define-key map "h" 'hg-help-overview) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
250 (define-key map "i" 'hg-init) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
251 (define-key map "l" 'hg-log-repo) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
252 (define-key map "r" 'hg-root) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
253 (define-key map "s" 'hg-status) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
254 (define-key map "u" 'hg-update) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
255 map)) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
256 |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
257 (global-set-key hg-global-prefix hg-global-map) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
258 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
259 ;;; View mode keymap. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
260 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
261 (defvar hg-view-mode-map |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
262 (let ((map (make-sparse-keymap))) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
263 (hg-feature-cond (xemacs (set-keymap-name map 'hg-view-mode-map))) ; XEmacs |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
264 (define-key map (hg-feature-cond (xemacs [button2]) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
265 (t [mouse-2])) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
266 'hg-buffer-mouse-clicked) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
267 map)) |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
268 |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
269 (add-minor-mode 'hg-view-mode "" hg-view-mode-map) |
944
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 |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
272 ;;; Commit mode keymaps. |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
273 |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
274 (defvar hg-commit-mode-map |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
275 (let ((map (make-sparse-keymap))) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
276 (define-key map "\C-c\C-c" 'hg-commit-finish) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
277 (define-key map "\C-c\C-k" 'hg-commit-kill) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
278 (define-key map "\C-xv=" 'hg-diff-repo) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
279 map)) |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
280 |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
281 (defvar hg-commit-mode-file-map |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
282 (let ((map (make-sparse-keymap))) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
283 (define-key map (hg-feature-cond (xemacs [button2]) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
284 (t [mouse-2])) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
285 'hg-commit-mouse-clicked) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
286 (define-key map " " 'hg-commit-toggle-file) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
287 (define-key map "\r" 'hg-commit-toggle-file) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
288 map)) |
1308
2073e5a71008
Cleanup of tabs and trailing spaces.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1246
diff
changeset
|
289 |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
290 |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
291 ;;; Convenience functions. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
292 |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
293 (defsubst hg-binary () |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
294 (if hg-binary |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
295 hg-binary |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
296 (error "No `hg' executable found!"))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
297 |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
298 (defsubst hg-replace-in-string (str regexp newtext &optional literal) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
299 "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
|
300 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
|
301 replacement. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
302 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
303 This function bridges yet another pointless impedance gap between |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
304 XEmacs and GNU Emacs." |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
305 (hg-feature-cond |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
306 (xemacs (replace-in-string str regexp newtext literal)) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
307 (t (replace-regexp-in-string regexp newtext str nil literal)))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
308 |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
309 (defsubst hg-strip (str) |
1178 | 310 "Strip leading and trailing blank lines from a string." |
311 (hg-replace-in-string (hg-replace-in-string str "[\r\n][ \t\r\n]*\\'" "") | |
312 "\\`[ \t\r\n]*[\r\n]" "")) | |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
313 |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
314 (defsubst hg-chomp (str) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
315 "Strip trailing newlines from a string." |
2999
e75fdc37100c
mercurial.el: fix hg-chomp.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2998
diff
changeset
|
316 (hg-replace-in-string str "[\r\n]+\\'" "")) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
317 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
318 (defun hg-run-command (command &rest args) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
319 "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
|
320 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
|
321 (let* (exit-code |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
322 (output |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
323 (with-output-to-string |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
324 (with-current-buffer |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
325 standard-output |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
326 (setq exit-code |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
327 (apply 'call-process command nil t nil args)))))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
328 (cons exit-code output))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
329 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
330 (defun hg-run (command &rest args) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
331 "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
|
332 (apply 'hg-run-command (hg-binary) command args)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
333 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
334 (defun hg-run0 (command &rest args) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
335 "Run the Mercurial command COMMAND, returning its output. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
336 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
|
337 (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
|
338 (if (not (eq (car res) 0)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
339 (error "Mercurial command failed %s - exit code %s" |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
340 (cons command args) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
341 (car res)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
342 (cdr res)))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
343 |
4412
189a8ca52bfc
mercurial.el: move defmacro of hg-do-across-repo before use
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4411
diff
changeset
|
344 (defmacro hg-do-across-repo (path &rest body) |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
345 (let ((root-name (make-symbol "root-")) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
346 (buf-name (make-symbol "buf-"))) |
4412
189a8ca52bfc
mercurial.el: move defmacro of hg-do-across-repo before use
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4411
diff
changeset
|
347 `(let ((,root-name (hg-root ,path))) |
189a8ca52bfc
mercurial.el: move defmacro of hg-do-across-repo before use
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4411
diff
changeset
|
348 (save-excursion |
189a8ca52bfc
mercurial.el: move defmacro of hg-do-across-repo before use
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4411
diff
changeset
|
349 (dolist (,buf-name (buffer-list)) |
189a8ca52bfc
mercurial.el: move defmacro of hg-do-across-repo before use
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4411
diff
changeset
|
350 (set-buffer ,buf-name) |
189a8ca52bfc
mercurial.el: move defmacro of hg-do-across-repo before use
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4411
diff
changeset
|
351 (when (and hg-status (equal (hg-root buffer-file-name) ,root-name)) |
189a8ca52bfc
mercurial.el: move defmacro of hg-do-across-repo before use
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4411
diff
changeset
|
352 ,@body)))))) |
189a8ca52bfc
mercurial.el: move defmacro of hg-do-across-repo before use
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4411
diff
changeset
|
353 |
189a8ca52bfc
mercurial.el: move defmacro of hg-do-across-repo before use
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4411
diff
changeset
|
354 (put 'hg-do-across-repo 'lisp-indent-function 1) |
189a8ca52bfc
mercurial.el: move defmacro of hg-do-across-repo before use
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4411
diff
changeset
|
355 |
1024
5b257e419816
Sync buffers prior to doing a diff.
bos@serpentine.internal.keyresearch.com
parents:
1011
diff
changeset
|
356 (defun hg-sync-buffers (path) |
5b257e419816
Sync buffers prior to doing a diff.
bos@serpentine.internal.keyresearch.com
parents:
1011
diff
changeset
|
357 "Sync buffers visiting PATH with their on-disk copies. |
5b257e419816
Sync buffers prior to doing a diff.
bos@serpentine.internal.keyresearch.com
parents:
1011
diff
changeset
|
358 If PATH is not being visited, but is under the repository root, sync |
5b257e419816
Sync buffers prior to doing a diff.
bos@serpentine.internal.keyresearch.com
parents:
1011
diff
changeset
|
359 all buffers visiting files in the repository." |
5b257e419816
Sync buffers prior to doing a diff.
bos@serpentine.internal.keyresearch.com
parents:
1011
diff
changeset
|
360 (let ((buf (find-buffer-visiting path))) |
5b257e419816
Sync buffers prior to doing a diff.
bos@serpentine.internal.keyresearch.com
parents:
1011
diff
changeset
|
361 (if buf |
5b257e419816
Sync buffers prior to doing a diff.
bos@serpentine.internal.keyresearch.com
parents:
1011
diff
changeset
|
362 (with-current-buffer buf |
5b257e419816
Sync buffers prior to doing a diff.
bos@serpentine.internal.keyresearch.com
parents:
1011
diff
changeset
|
363 (vc-buffer-sync)) |
5b257e419816
Sync buffers prior to doing a diff.
bos@serpentine.internal.keyresearch.com
parents:
1011
diff
changeset
|
364 (hg-do-across-repo path |
5b257e419816
Sync buffers prior to doing a diff.
bos@serpentine.internal.keyresearch.com
parents:
1011
diff
changeset
|
365 (vc-buffer-sync))))) |
1308
2073e5a71008
Cleanup of tabs and trailing spaces.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1246
diff
changeset
|
366 |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
367 (defun hg-buffer-commands (pnt) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
368 "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
|
369 (interactive "d") |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
370 (let ((rev (get-char-property pnt 'rev)) |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
371 (file (get-char-property pnt 'file))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
372 (cond |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
373 (file |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
374 (find-file-other-window file)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
375 (rev |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
376 (hg-diff hg-view-file-name rev rev)) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
377 ((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
|
378 |
1004
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
379 (defsubst hg-event-point (event) |
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
380 "Return the character position of the mouse event EVENT." |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
381 (hg-feature-cond (xemacs (event-point event)) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
382 (t (posn-point (event-start event))))) |
1004
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
383 |
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
384 (defsubst hg-event-window (event) |
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
385 "Return the window over which mouse event EVENT occurred." |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
386 (hg-feature-cond (xemacs (event-window event)) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
387 (t (posn-window (event-start event))))) |
1004
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
388 |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
389 (defun hg-buffer-mouse-clicked (event) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
390 "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
|
391 These are then handed off to `hg-buffer-commands'. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
392 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
393 Handle frickin' frackin' gratuitous event-related incompatibilities." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
394 (interactive "e") |
1004
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
395 (select-window (hg-event-window event)) |
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
396 (hg-buffer-commands (hg-event-point event))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
397 |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
398 (defsubst hg-abbrev-file-name (file) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
399 "Portable wrapper around abbreviate-file-name." |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
400 (hg-feature-cond (xemacs (abbreviate-file-name file t)) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
401 (t (abbreviate-file-name file)))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
402 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
403 (defun hg-read-file-name (&optional prompt default) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
404 "Read a file or directory name, or a pattern, to use with a command." |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
405 (save-excursion |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
406 (while hg-prev-buffer |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
407 (set-buffer hg-prev-buffer)) |
2668
7a32b7e6c563
Emacs: apply "expand-filename" on "default-directory".
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2667
diff
changeset
|
408 (let ((path (or default |
7a32b7e6c563
Emacs: apply "expand-filename" on "default-directory".
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2667
diff
changeset
|
409 (buffer-file-name) |
7a32b7e6c563
Emacs: apply "expand-filename" on "default-directory".
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2667
diff
changeset
|
410 (expand-file-name default-directory)))) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
411 (if (or (not path) current-prefix-arg) |
2315
c4a2d8502cc0
Emacs: adapt read-file-name invocation for (non-X)Emacs 21.4.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
412 (expand-file-name |
c4a2d8502cc0
Emacs: adapt read-file-name invocation for (non-X)Emacs 21.4.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
413 (eval (list* 'read-file-name |
c4a2d8502cc0
Emacs: adapt read-file-name invocation for (non-X)Emacs 21.4.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
414 (format "File, directory or pattern%s: " |
c4a2d8502cc0
Emacs: adapt read-file-name invocation for (non-X)Emacs 21.4.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
415 (or prompt "")) |
c4a2d8502cc0
Emacs: adapt read-file-name invocation for (non-X)Emacs 21.4.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
416 (and path (file-name-directory path)) |
c4a2d8502cc0
Emacs: adapt read-file-name invocation for (non-X)Emacs 21.4.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
417 nil nil |
c4a2d8502cc0
Emacs: adapt read-file-name invocation for (non-X)Emacs 21.4.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
418 (and path (file-name-nondirectory path)) |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
419 (hg-feature-cond |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
420 (xemacs (cons (quote 'hg-file-history) nil)) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
421 (t nil))))) |
2315
c4a2d8502cc0
Emacs: adapt read-file-name invocation for (non-X)Emacs 21.4.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
422 path)))) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
423 |
2316
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
424 (defun hg-read-number (&optional prompt default) |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
425 "Read a integer value." |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
426 (save-excursion |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
427 (if (or (not default) current-prefix-arg) |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
428 (string-to-number |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
429 (eval (list* 'read-string |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4694
diff
changeset
|
430 (or prompt "") |
2316
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
431 (if default (cons (format "%d" default) nil) nil)))) |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
432 default))) |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
433 |
1029
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
434 (defun hg-read-config () |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
435 "Return an alist of (key . value) pairs of Mercurial config data. |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
436 Each key is of the form (section . name)." |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
437 (let (items) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
438 (dolist (line (split-string (hg-chomp (hg-run0 "debugconfig")) "\n") items) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
439 (string-match "^\\([^=]*\\)=\\(.*\\)" line) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
440 (let* ((left (substring line (match-beginning 1) (match-end 1))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
441 (right (substring line (match-beginning 2) (match-end 2))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
442 (key (split-string left "\\.")) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
443 (value (hg-replace-in-string right "\\\\n" "\n" t))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
444 (setq items (cons (cons (cons (car key) (cadr key)) value) items)))))) |
1308
2073e5a71008
Cleanup of tabs and trailing spaces.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1246
diff
changeset
|
445 |
1029
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
446 (defun hg-config-section (section config) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
447 "Return an alist of (name . value) pairs for SECTION of CONFIG." |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
448 (let (items) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
449 (dolist (item config items) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
450 (when (equal (caar item) section) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
451 (setq items (cons (cons (cdar item) (cdr item)) items)))))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
452 |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
453 (defun hg-string-starts-with (sub str) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
454 "Indicate whether string STR starts with the substring or character SUB." |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
455 (if (not (stringp sub)) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
456 (and (> (length str) 0) (equal (elt str 0) sub)) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
457 (let ((sub-len (length sub))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
458 (and (<= sub-len (length str)) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
459 (string= sub (substring str 0 sub-len)))))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
460 |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
461 (defun hg-complete-repo (string predicate all) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
462 "Attempt to complete a repository name. |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
463 We complete on either symbolic names from Mercurial's config or real |
17533 | 464 directory names from the file system. We do not penalize URLs." |
1029
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
465 (or (if all |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
466 (all-completions string hg-repo-completion-table predicate) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
467 (try-completion string hg-repo-completion-table predicate)) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
468 (let* ((str (expand-file-name string)) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
469 (dir (file-name-directory str)) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
470 (file (file-name-nondirectory str))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
471 (if all |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
472 (let (completions) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
473 (dolist (name (delete "./" (file-name-all-completions file dir)) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
474 completions) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
475 (let ((path (concat dir name))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
476 (when (file-directory-p path) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
477 (setq completions (cons name completions)))))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
478 (let ((comp (file-name-completion file dir))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
479 (if comp |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
480 (hg-abbrev-file-name (concat dir comp)))))))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
481 |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
482 (defun hg-read-repo-name (&optional prompt initial-contents default) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
483 "Read the location of a repository." |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
484 (save-excursion |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
485 (while hg-prev-buffer |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
486 (set-buffer hg-prev-buffer)) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
487 (let (hg-repo-completion-table) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
488 (if current-prefix-arg |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
489 (progn |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
490 (dolist (path (hg-config-section "paths" (hg-read-config))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
491 (setq hg-repo-completion-table |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
492 (cons (cons (car path) t) hg-repo-completion-table)) |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
493 (unless (hg-string-starts-with (hg-feature-cond |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
494 (xemacs directory-sep-char) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
495 (t ?/)) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
496 (cdr path)) |
1029
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
497 (setq hg-repo-completion-table |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
498 (cons (cons (cdr path) t) hg-repo-completion-table)))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
499 (completing-read (format "Repository%s: " (or prompt "")) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
500 'hg-complete-repo |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
501 nil |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
502 nil |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
503 initial-contents |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
504 'hg-repo-history |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
505 default)) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
506 default)))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
507 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
508 (defun hg-read-rev (&optional prompt default) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
509 "Read a revision or tag, offering completions." |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
510 (save-excursion |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
511 (while hg-prev-buffer |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
512 (set-buffer hg-prev-buffer)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
513 (let ((rev (or default "tip"))) |
1029
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
514 (if current-prefix-arg |
1175
7e909ceeb36a
Emacs: fix invocations of "hg log" to match current behaviour of log.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1029
diff
changeset
|
515 (let ((revs (split-string |
7e909ceeb36a
Emacs: fix invocations of "hg log" to match current behaviour of log.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1029
diff
changeset
|
516 (hg-chomp |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
517 (hg-run0 "-q" "log" "-l" |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
518 (format "%d" hg-rev-completion-limit))) |
1175
7e909ceeb36a
Emacs: fix invocations of "hg log" to match current behaviour of log.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1029
diff
changeset
|
519 "[\n:]"))) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
520 (dolist (line (split-string (hg-chomp (hg-run0 "tags")) "\n")) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
521 (setq revs (cons (car (split-string line "\\s-")) revs))) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
522 (completing-read (format "Revision%s (%s): " |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
523 (or prompt "") |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
524 (or default "tip")) |
5465
9873cbb134b2
mercurial.el, mq.el: remove runtime dependencies on CL package
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5142
diff
changeset
|
525 (mapcar (lambda (x) (cons x x)) revs) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
526 nil |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
527 nil |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
528 nil |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
529 'hg-rev-history |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
530 (or default "tip"))) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
531 rev)))) |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
532 |
3002
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
533 (defun hg-parents-for-mode-line (root) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
534 "Format the parents of the working directory for the mode line." |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
535 (let ((parents (split-string (hg-chomp |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
536 (hg-run0 "--cwd" root "parents" "--template" |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
537 "{rev}\n")) "\n"))) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
538 (mapconcat 'identity parents "+"))) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
539 |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
540 (defun hg-buffers-visiting-repo (&optional path) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
541 "Return a list of buffers visiting the repository containing PATH." |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
542 (let ((root-name (hg-root (or path (buffer-file-name)))) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
543 bufs) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
544 (save-excursion |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
545 (dolist (buf (buffer-list) bufs) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
546 (set-buffer buf) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
547 (let ((name (buffer-file-name))) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
548 (when (and hg-status name (equal (hg-root name) root-name)) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
549 (setq bufs (cons buf bufs)))))))) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
550 |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
551 (defun hg-update-mode-lines (path) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
552 "Update the mode lines of all buffers visiting the same repository as PATH." |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
553 (let* ((root (hg-root path)) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
554 (parents (hg-parents-for-mode-line root))) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
555 (save-excursion |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
556 (dolist (info (hg-path-status |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
557 root |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
558 (mapcar |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
559 (function |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
560 (lambda (buf) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
561 (substring (buffer-file-name buf) (length root)))) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
562 (hg-buffers-visiting-repo root)))) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
563 (let* ((name (car info)) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
564 (status (cdr info)) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
565 (buf (find-buffer-visiting (concat root name)))) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
566 (when buf |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
567 (set-buffer buf) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
568 (hg-mode-line-internal status parents))))))) |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4694
diff
changeset
|
569 |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
570 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
571 ;;; View mode bits. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
572 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
573 (defun hg-exit-view-mode (buf) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
574 "Exit from hg-view-mode. |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
575 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
|
576 current frame." |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
577 (when (and (eq buf (current-buffer)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
578 (> (length (window-list)) 1)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
579 (delete-window)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
580 (when (buffer-live-p buf) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
581 (kill-buffer buf))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
582 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
583 (defun hg-view-mode (prev-buffer &optional file-name) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
584 (goto-char (point-min)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
585 (set-buffer-modified-p nil) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
586 (toggle-read-only t) |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
587 (hg-feature-cond (xemacs (view-minor-mode prev-buffer 'hg-exit-view-mode)) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
588 (t (view-mode-enter nil 'hg-exit-view-mode))) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
589 (setq hg-view-mode t) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
590 (setq truncate-lines t) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
591 (when file-name |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4694
diff
changeset
|
592 (setq hg-view-file-name |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
593 (hg-abbrev-file-name file-name)))) |
1308
2073e5a71008
Cleanup of tabs and trailing spaces.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1246
diff
changeset
|
594 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
595 (defun hg-file-status (file) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
596 "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
|
597 (let* ((s (hg-run "status" file)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
598 (exit (car s)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
599 (output (cdr s))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
600 (if (= exit 0) |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
601 (let ((state (and (>= (length output) 2) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
602 (= (aref output 1) ? ) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
603 (assq (aref output 0) hg-state-alist)))) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
604 (if state |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
605 (cdr state) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
606 'normal))))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
607 |
3002
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
608 (defun hg-path-status (root paths) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
609 "Return status of PATHS in repo ROOT as an alist. |
3001
a7c4c7537999
mercurial.el: add hg-status.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3000
diff
changeset
|
610 Each entry is a pair (FILE-NAME . STATUS)." |
3002
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
611 (let ((s (apply 'hg-run "--cwd" root "status" "-marduc" paths)) |
3005
18c661e9abd9
mercurial.el: deal with more vagaries of "hg status".
Bryan O'Sullivan <bos@serpentine.com>
parents:
3003
diff
changeset
|
612 result) |
18c661e9abd9
mercurial.el: deal with more vagaries of "hg status".
Bryan O'Sullivan <bos@serpentine.com>
parents:
3003
diff
changeset
|
613 (dolist (entry (split-string (hg-chomp (cdr s)) "\n") (nreverse result)) |
18c661e9abd9
mercurial.el: deal with more vagaries of "hg status".
Bryan O'Sullivan <bos@serpentine.com>
parents:
3003
diff
changeset
|
614 (let (state name) |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
615 (cond ((= (aref entry 1) ? ) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
616 (setq state (assq (aref entry 0) hg-state-alist) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
617 name (substring entry 2))) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
618 ((string-match "\\(.*\\): " entry) |
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
619 (setq name (match-string 1 entry)))) |
3005
18c661e9abd9
mercurial.el: deal with more vagaries of "hg status".
Bryan O'Sullivan <bos@serpentine.com>
parents:
3003
diff
changeset
|
620 (setq result (cons (cons name state) result)))))) |
3001
a7c4c7537999
mercurial.el: add hg-status.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3000
diff
changeset
|
621 |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
622 (defmacro hg-view-output (args &rest body) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
623 "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
|
624 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
|
625 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
|
626 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
|
627 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
|
628 being viewed." |
4433
ba22e867cb23
mercurial.el: fix error on hg-read-rev() with small tip, and cleanups
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4413
diff
changeset
|
629 (let ((prev-buf (make-symbol "prev-buf-")) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
630 (v-b-name (car args)) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
631 (v-m-rest (cdr args))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
632 `(let ((view-buf-name ,v-b-name) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
633 (,prev-buf (current-buffer))) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
634 (get-buffer-create view-buf-name) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
635 (kill-buffer view-buf-name) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
636 (get-buffer-create view-buf-name) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
637 (set-buffer view-buf-name) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
638 (save-excursion |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
639 ,@body) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
640 (case (count-lines (point-min) (point-max)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
641 ((0) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
642 (kill-buffer view-buf-name) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
643 (message "(No output)")) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
644 ((1) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
645 (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
|
646 (kill-buffer view-buf-name) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
647 (message "%s" msg))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
648 (t |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
649 (pop-to-buffer view-buf-name) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
650 (setq hg-prev-buffer ,prev-buf) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
651 (hg-view-mode ,prev-buf ,@v-m-rest)))))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
652 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
653 (put 'hg-view-output 'lisp-indent-function 1) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
654 |
3005
18c661e9abd9
mercurial.el: deal with more vagaries of "hg status".
Bryan O'Sullivan <bos@serpentine.com>
parents:
3003
diff
changeset
|
655 ;;; Context save and restore across revert and other operations. |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
656 |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
657 (defun hg-position-context (pos) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
658 "Return information to help find the given position again." |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
659 (let* ((end (min (point-max) (+ pos 98)))) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
660 (list pos |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
661 (buffer-substring (max (point-min) (- pos 2)) end) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
662 (- end pos)))) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
663 |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
664 (defun hg-buffer-context () |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
665 "Return information to help restore a user's editing context. |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
666 This is useful across reverts and merges, where a context is likely |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
667 to have moved a little, but not really changed." |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
668 (let ((point-context (hg-position-context (point))) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
669 (mark-context (let ((mark (mark-marker))) |
5467
521284cdbcb4
mercurial.el: mark-marker() returns non-nil with no active mark on GNU Emacs
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5465
diff
changeset
|
670 (and mark |
521284cdbcb4
mercurial.el: mark-marker() returns non-nil with no active mark on GNU Emacs
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5465
diff
changeset
|
671 ;; make sure active mark |
521284cdbcb4
mercurial.el: mark-marker() returns non-nil with no active mark on GNU Emacs
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5465
diff
changeset
|
672 (marker-buffer mark) |
521284cdbcb4
mercurial.el: mark-marker() returns non-nil with no active mark on GNU Emacs
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5465
diff
changeset
|
673 (marker-position mark) |
521284cdbcb4
mercurial.el: mark-marker() returns non-nil with no active mark on GNU Emacs
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5465
diff
changeset
|
674 (hg-position-context mark))))) |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
675 (list point-context mark-context))) |
1308
2073e5a71008
Cleanup of tabs and trailing spaces.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1246
diff
changeset
|
676 |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
677 (defun hg-find-context (ctx) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
678 "Attempt to find a context in the given buffer. |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
679 Always returns a valid, hopefully sane, position." |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
680 (let ((pos (nth 0 ctx)) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
681 (str (nth 1 ctx)) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
682 (fixup (nth 2 ctx))) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
683 (save-excursion |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
684 (goto-char (max (point-min) (- pos 15000))) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
685 (if (and (not (equal str "")) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
686 (search-forward str nil t)) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
687 (- (point) fixup) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
688 (max pos (point-min)))))) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
689 |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
690 (defun hg-restore-context (ctx) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
691 "Attempt to restore the user's editing context." |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
692 (let ((point-context (nth 0 ctx)) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
693 (mark-context (nth 1 ctx))) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
694 (goto-char (hg-find-context point-context)) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
695 (when mark-context |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
696 (set-mark (hg-find-context mark-context))))) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
697 |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
698 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
699 ;;; Hooks. |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
700 |
3002
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
701 (defun hg-mode-line-internal (status parents) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
702 (setq hg-status status |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
703 hg-mode (and status (concat " Hg:" |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
704 parents |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
705 (cdr (assq status |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
706 '((normal . "") |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
707 (removed . "r") |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
708 (added . "a") |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
709 (deleted . "!") |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
710 (modified . "m")))))))) |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4694
diff
changeset
|
711 |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
712 (defun hg-mode-line (&optional force) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
713 "Update the modeline with the current status of a file. |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
714 An update occurs if optional argument FORCE is non-nil, |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
715 hg-update-modeline is non-nil, or we have not yet checked the state of |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
716 the file." |
3002
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
717 (let ((root (hg-root))) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
718 (when (and root (or force hg-update-modeline (not hg-mode))) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
719 (let ((status (hg-file-status buffer-file-name)) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
720 (parents (hg-parents-for-mode-line root))) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
721 (hg-mode-line-internal status parents) |
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
722 status)))) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
723 |
1371
68e84563c540
emacs minor mode optional argument
Robin Farine <robin.farine@terminus.org>
parents:
1308
diff
changeset
|
724 (defun hg-mode (&optional toggle) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
725 "Minor mode for Mercurial distributed SCM integration. |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
726 |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
727 The Mercurial mode user interface is based on that of VC mode, so if |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
728 you're already familiar with VC, the same keybindings and functions |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
729 will generally work. |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
730 |
2517
0086056322da
mercurial.el: inhibit backups for files managed by mercurial
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2457
diff
changeset
|
731 Below is a list of many common SCM tasks. In the list, `G/L\' |
4411 | 732 indicates whether a key binding is global (G) to a repository or |
733 local (L) to a file. Many commands take a prefix argument. | |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
734 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
735 SCM Task G/L Key Binding Command Name |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
736 -------- --- ----------- ------------ |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
737 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
|
738 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
739 Tell Mercurial to manage a file G C-c h a hg-add |
1179 | 740 Commit changes to current file only L C-x v n hg-commit-start |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
741 Undo changes to file since commit L C-x v u hg-revert-buffer |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
742 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
743 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
|
744 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
745 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
|
746 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
|
747 |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
748 Diff repo vs last checkin G C-c h = hg-diff-repo |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
749 View status of files in repo G C-c h s hg-status |
1179 | 750 Commit all changes G C-c h c hg-commit-start |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
751 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
752 Undo all changes since last commit G C-c h U hg-revert |
1179 | 753 View repo change history G C-c h l hg-log-repo |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
754 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
755 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
|
756 Pull changes G C-c h < hg-pull |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
757 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
|
758 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
|
759 Push changes G C-c h > hg-push" |
2517
0086056322da
mercurial.el: inhibit backups for files managed by mercurial
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2457
diff
changeset
|
760 (unless vc-make-backup-files |
0086056322da
mercurial.el: inhibit backups for files managed by mercurial
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2457
diff
changeset
|
761 (set (make-local-variable 'backup-inhibited) t)) |
2518
d78ae783499d
mercurial.el: fix misleading indent of code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2517
diff
changeset
|
762 (run-hooks 'hg-mode-hook)) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
763 |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
764 (defun hg-find-file-hook () |
4413
b008deae9910
mercurial.el: don't raise an error from find-file-hook
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4412
diff
changeset
|
765 (ignore-errors |
b008deae9910
mercurial.el: don't raise an error from find-file-hook
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4412
diff
changeset
|
766 (when (hg-mode-line) |
b008deae9910
mercurial.el: don't raise an error from find-file-hook
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4412
diff
changeset
|
767 (hg-mode)))) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
768 |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
769 (add-hook 'find-file-hooks 'hg-find-file-hook) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
770 |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
771 (defun hg-after-save-hook () |
4694
6bf58c9400e2
mercurial.el: ignore errors on hg-after-save-hook()
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4693
diff
changeset
|
772 (ignore-errors |
6bf58c9400e2
mercurial.el: ignore errors on hg-after-save-hook()
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4693
diff
changeset
|
773 (let ((old-status hg-status)) |
6bf58c9400e2
mercurial.el: ignore errors on hg-after-save-hook()
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4693
diff
changeset
|
774 (hg-mode-line) |
6bf58c9400e2
mercurial.el: ignore errors on hg-after-save-hook()
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4693
diff
changeset
|
775 (if (and (not old-status) hg-status) |
6bf58c9400e2
mercurial.el: ignore errors on hg-after-save-hook()
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4693
diff
changeset
|
776 (hg-mode))))) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
777 |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
778 (add-hook 'after-save-hook 'hg-after-save-hook) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
779 |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
780 |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
781 ;;; User interface functions. |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
782 |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
783 (defun hg-help-overview () |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
784 "This is an overview of the Mercurial SCM mode for Emacs. |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
785 |
10263 | 786 You can find the source code, license (GPLv2+), and credits for this |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
787 code by typing `M-x find-library mercurial RET'." |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
788 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
789 (hg-view-output ("Mercurial Help Overview") |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
790 (insert (documentation 'hg-help-overview)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
791 (let ((pos (point))) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
792 (insert (documentation 'hg-mode)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
793 (goto-char pos) |
2452
d1a7c8a5b835
Emacs: use delete-region instead of kill-* functions.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
794 (end-of-line 1) |
2457 | 795 (delete-region pos (point))) |
2737
a5c43944e1ee
avoid calling (cd ...) with `nil' as a directory name
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
2668
diff
changeset
|
796 (let ((hg-root-dir (hg-root))) |
a5c43944e1ee
avoid calling (cd ...) with `nil' as a directory name
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
2668
diff
changeset
|
797 (if (not hg-root-dir) |
a5c43944e1ee
avoid calling (cd ...) with `nil' as a directory name
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
2668
diff
changeset
|
798 (error "error: %s: directory is not part of a Mercurial repository." |
a5c43944e1ee
avoid calling (cd ...) with `nil' as a directory name
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
2668
diff
changeset
|
799 default-directory) |
2877
0ffca0cb9f4b
Use cached hg-root-dir instead of rediscovering
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
2737
diff
changeset
|
800 (cd hg-root-dir))))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
801 |
2997
48baf9fb1921
mercurial.el: get rid of unportable, unperformant use of replace-regexp.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2877
diff
changeset
|
802 (defun hg-fix-paths () |
48baf9fb1921
mercurial.el: get rid of unportable, unperformant use of replace-regexp.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2877
diff
changeset
|
803 "Fix paths reported by some Mercurial commands." |
48baf9fb1921
mercurial.el: get rid of unportable, unperformant use of replace-regexp.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2877
diff
changeset
|
804 (save-excursion |
48baf9fb1921
mercurial.el: get rid of unportable, unperformant use of replace-regexp.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2877
diff
changeset
|
805 (goto-char (point-min)) |
48baf9fb1921
mercurial.el: get rid of unportable, unperformant use of replace-regexp.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2877
diff
changeset
|
806 (while (re-search-forward " \\.\\.." nil t) |
48baf9fb1921
mercurial.el: get rid of unportable, unperformant use of replace-regexp.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2877
diff
changeset
|
807 (replace-match " " nil nil)))) |
48baf9fb1921
mercurial.el: get rid of unportable, unperformant use of replace-regexp.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2877
diff
changeset
|
808 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
809 (defun hg-add (path) |
996
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
810 "Add PATH to the Mercurial repository on the next commit. |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
811 With a prefix argument, prompt for the path to add." |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
812 (interactive (list (hg-read-file-name " to add"))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
813 (let ((buf (current-buffer)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
814 (update (equal buffer-file-name path))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
815 (hg-view-output (hg-output-buffer-name) |
2454
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
816 (apply 'call-process (hg-binary) nil t nil (list "add" path)) |
2997
48baf9fb1921
mercurial.el: get rid of unportable, unperformant use of replace-regexp.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2877
diff
changeset
|
817 (hg-fix-paths) |
2998
e1762867a734
mercurial.el: fix calls to goto-char.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2997
diff
changeset
|
818 (goto-char (point-min)) |
2454
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
819 (cd (hg-root path))) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
820 (when update |
2517
0086056322da
mercurial.el: inhibit backups for files managed by mercurial
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2457
diff
changeset
|
821 (unless vc-make-backup-files |
0086056322da
mercurial.el: inhibit backups for files managed by mercurial
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2457
diff
changeset
|
822 (set (make-local-variable 'backup-inhibited) t)) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
823 (with-current-buffer buf |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
824 (hg-mode-line))))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
825 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
826 (defun hg-addremove () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
827 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
828 (error "not implemented")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
829 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
830 (defun hg-annotate () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
831 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
832 (error "not implemented")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
833 |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
834 (defun hg-commit-toggle-file (pos) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
835 "Toggle whether or not the file at POS will be committed." |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
836 (interactive "d") |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
837 (save-excursion |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
838 (goto-char pos) |
8370
45ed015b524e
allow toggling when the cursor is on the correct line instead of just the filename text in hg-commit-toggle-file
Jonathan Kotta <jpkotta@packetdigital.com>
parents:
6390
diff
changeset
|
839 (let (face |
1004
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
840 (inhibit-read-only t) |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
841 bol) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
842 (beginning-of-line) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
843 (setq bol (+ (point) 4)) |
8370
45ed015b524e
allow toggling when the cursor is on the correct line instead of just the filename text in hg-commit-toggle-file
Jonathan Kotta <jpkotta@packetdigital.com>
parents:
6390
diff
changeset
|
844 (setq face (get-text-property bol 'face)) |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
845 (end-of-line) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
846 (if (eq face 'bold) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
847 (progn |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
848 (remove-text-properties bol (point) '(face nil)) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
849 (message "%s will not be committed" |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
850 (buffer-substring bol (point)))) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
851 (add-text-properties bol (point) '(face bold)) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
852 (message "%s will be committed" |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
853 (buffer-substring bol (point))))))) |
1308
2073e5a71008
Cleanup of tabs and trailing spaces.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1246
diff
changeset
|
854 |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
855 (defun hg-commit-mouse-clicked (event) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
856 "Toggle whether or not the file at POS will be committed." |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
857 (interactive "@e") |
1004
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
858 (hg-commit-toggle-file (hg-event-point event))) |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
859 |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
860 (defun hg-commit-kill () |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
861 "Kill the commit currently being prepared." |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
862 (interactive) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
863 (when (or (not (buffer-modified-p)) (y-or-n-p "Really kill this commit? ")) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
864 (let ((buf hg-prev-buffer)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
865 (kill-buffer nil) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
866 (switch-to-buffer buf)))) |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
867 |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
868 (defun hg-commit-finish () |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
869 "Finish preparing a commit, and perform the actual commit. |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
870 The hook hg-pre-commit-hook is run before anything else is done. If |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
871 the commit message is empty and hg-commit-allow-empty-message is nil, |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
872 an error is raised. If the list of files to commit is empty and |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
873 hg-commit-allow-empty-file-list is nil, an error is raised." |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
874 (interactive) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
875 (let ((root hg-root)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
876 (save-excursion |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
877 (run-hooks 'hg-pre-commit-hook) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
878 (goto-char (point-min)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
879 (search-forward hg-commit-message-start) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
880 (let (message files) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
881 (let ((start (point))) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
882 (goto-char (point-max)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
883 (search-backward hg-commit-message-end) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
884 (setq message (hg-strip (buffer-substring start (point))))) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
885 (when (and (= (length message) 0) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
886 (not hg-commit-allow-empty-message)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
887 (error "Cannot proceed - commit message is empty")) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
888 (forward-line 1) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
889 (beginning-of-line) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
890 (while (< (point) (point-max)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
891 (let ((pos (+ (point) 4))) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
892 (end-of-line) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
893 (when (eq (get-text-property pos 'face) 'bold) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
894 (end-of-line) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
895 (setq files (cons (buffer-substring pos (point)) files)))) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
896 (forward-line 1)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
897 (when (and (= (length files) 0) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
898 (not hg-commit-allow-empty-file-list)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
899 (error "Cannot proceed - no files to commit")) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
900 (setq message (concat message "\n")) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
901 (apply 'hg-run0 "--cwd" hg-root "commit" "-m" message files)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
902 (let ((buf hg-prev-buffer)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
903 (kill-buffer nil) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
904 (switch-to-buffer buf)) |
3002
65efeb7b2c56
mercurial.el: speed up mode line updates.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3001
diff
changeset
|
905 (hg-update-mode-lines root)))) |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
906 |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
907 (defun hg-commit-mode () |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
908 "Mode for describing a commit of changes to a Mercurial repository. |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
909 This involves two actions: describing the changes with a commit |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
910 message, and choosing the files to commit. |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
911 |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
912 To describe the commit, simply type some text in the designated area. |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
913 |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
914 By default, all modified, added and removed files are selected for |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
915 committing. Files that will be committed are displayed in bold face\; |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
916 those that will not are displayed in normal face. |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
917 |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
918 To toggle whether a file will be committed, move the cursor over a |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
919 particular file and hit space or return. Alternatively, middle click |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
920 on the file. |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
921 |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
922 Key bindings |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
923 ------------ |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
924 \\[hg-commit-finish] proceed with commit |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
925 \\[hg-commit-kill] kill commit |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
926 |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
927 \\[hg-diff-repo] view diff of pending changes" |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
928 (interactive) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
929 (use-local-map hg-commit-mode-map) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
930 (set-syntax-table text-mode-syntax-table) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
931 (setq local-abbrev-table text-mode-abbrev-table |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
932 major-mode 'hg-commit-mode |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
933 mode-name "Hg-Commit") |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
934 (set-buffer-modified-p nil) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
935 (setq buffer-undo-list nil) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
936 (run-hooks 'text-mode-hook 'hg-commit-mode-hook)) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
937 |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
938 (defun hg-commit-start () |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
939 "Prepare a commit of changes to the repository containing the current file." |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
940 (interactive) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
941 (while hg-prev-buffer |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
942 (set-buffer hg-prev-buffer)) |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
943 (let ((root (hg-root)) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
944 (prev-buffer (current-buffer)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
945 modified-files) |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
946 (unless root |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
947 (error "Cannot commit outside a repository!")) |
1024
5b257e419816
Sync buffers prior to doing a diff.
bos@serpentine.internal.keyresearch.com
parents:
1011
diff
changeset
|
948 (hg-sync-buffers root) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
949 (setq modified-files (hg-chomp (hg-run0 "--cwd" root "status" "-arm"))) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
950 (when (and (= (length modified-files) 0) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
951 (not hg-commit-allow-empty-file-list)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
952 (error "No pending changes to commit")) |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
953 (let* ((buf-name (format "*Mercurial: Commit %s*" root))) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
954 (pop-to-buffer (get-buffer-create buf-name)) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
955 (when (= (point-min) (point-max)) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
956 (set (make-local-variable 'hg-root) root) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
957 (setq hg-prev-buffer prev-buffer) |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
958 (insert "\n") |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
959 (let ((bol (point))) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
960 (insert hg-commit-message-end) |
1004
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
961 (add-text-properties bol (point) '(face bold-italic))) |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
962 (let ((file-area (point))) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
963 (insert modified-files) |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
964 (goto-char file-area) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
965 (while (< (point) (point-max)) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
966 (let ((bol (point))) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
967 (forward-char 1) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
968 (insert " ") |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
969 (end-of-line) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
970 (add-text-properties (+ bol 4) (point) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
971 '(face bold mouse-face highlight))) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
972 (forward-line 1)) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
973 (goto-char file-area) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
974 (add-text-properties (point) (point-max) |
1004
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
975 `(keymap ,hg-commit-mode-file-map)) |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
976 (goto-char (point-min)) |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
977 (insert hg-commit-message-start) |
1004
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
978 (add-text-properties (point-min) (point) '(face bold-italic)) |
999
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
979 (insert "\n\n") |
bb391518bc28
Emacs: first cut at commit support.
Bryan O'Sullivan <bos@serpentine.com>
parents:
996
diff
changeset
|
980 (forward-line -1) |
1004
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
981 (save-excursion |
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
982 (goto-char (point-max)) |
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
983 (search-backward hg-commit-message-end) |
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
984 (add-text-properties (match-beginning 0) (point-max) |
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
985 '(read-only t)) |
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
986 (goto-char (point-min)) |
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
987 (search-forward hg-commit-message-start) |
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
988 (add-text-properties (match-beginning 0) (match-end 0) |
ad6fcceaf59b
Emacs: improved GNU Emacs support.
bos@serpentine.internal.keyresearch.com
parents:
1003
diff
changeset
|
989 '(read-only t))) |
2454
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
990 (hg-commit-mode) |
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
991 (cd root)))))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
992 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
993 (defun hg-diff (path &optional rev1 rev2) |
996
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
994 "Show the differences between REV1 and REV2 of PATH. |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
995 When called interactively, the default behaviour is to treat REV1 as |
2455
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
996 the \"parent\" revision, REV2 as the current edited version of the file, and |
996
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
997 PATH as the file edited in the current buffer. |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
998 With a prefix argument, prompt for all of these." |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
999 (interactive (list (hg-read-file-name " to diff") |
2455
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1000 (let ((rev1 (hg-read-rev " to start with" 'parent))) |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1001 (and (not (eq rev1 'parent)) rev1)) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
1002 (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
|
1003 (and (not (eq rev2 'working-dir)) rev2)))) |
1024
5b257e419816
Sync buffers prior to doing a diff.
bos@serpentine.internal.keyresearch.com
parents:
1011
diff
changeset
|
1004 (hg-sync-buffers path) |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1005 (let ((a-path (hg-abbrev-file-name path)) |
2455
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1006 ;; none revision is specified explicitly |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1007 (none (and (not rev1) (not rev2))) |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1008 ;; only one revision is specified explicitly |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4694
diff
changeset
|
1009 (one (or (and (or (equal rev1 rev2) (not rev2)) rev1) |
2455
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1010 (and (not rev1) rev2))) |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1011 diff) |
1027
cb31576ed3e4
Emacs: fix up hg-log and hg-diff to operate more uniformly.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1026
diff
changeset
|
1012 (hg-view-output ((cond |
2455
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1013 (none |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1014 (format "Mercurial: Diff against parent of %s" a-path)) |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1015 (one |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1016 (format "Mercurial: Diff of rev %s of %s" one a-path)) |
1027
cb31576ed3e4
Emacs: fix up hg-log and hg-diff to operate more uniformly.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1026
diff
changeset
|
1017 (t |
cb31576ed3e4
Emacs: fix up hg-log and hg-diff to operate more uniformly.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1026
diff
changeset
|
1018 (format "Mercurial: Diff from rev %s to %s of %s" |
2455
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1019 rev1 rev2 a-path)))) |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1020 (cond |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4694
diff
changeset
|
1021 (none |
2455
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1022 (call-process (hg-binary) nil t nil "diff" path)) |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1023 (one |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1024 (call-process (hg-binary) nil t nil "diff" "-r" one path)) |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1025 (t |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1026 (call-process (hg-binary) nil t nil "diff" "-r" rev1 "-r" rev2 path))) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
1027 (diff-mode) |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1028 (setq diff (not (= (point-min) (point-max)))) |
2454
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1029 (font-lock-fontify-buffer) |
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1030 (cd (hg-root path))) |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1031 diff)) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1032 |
2455
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1033 (defun hg-diff-repo (path &optional rev1 rev2) |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1034 "Show the differences between REV1 and REV2 of repository containing PATH. |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1035 When called interactively, the default behaviour is to treat REV1 as |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1036 the \"parent\" revision, REV2 as the current edited version of the file, and |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1037 PATH as the `hg-root' of the current buffer. |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1038 With a prefix argument, prompt for all of these." |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1039 (interactive (list (hg-read-file-name " to diff") |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1040 (let ((rev1 (hg-read-rev " to start with" 'parent))) |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1041 (and (not (eq rev1 'parent)) rev1)) |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1042 (let ((rev2 (hg-read-rev " to end with" 'working-dir))) |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1043 (and (not (eq rev2 'working-dir)) rev2)))) |
ff83112332f9
Emacs: follow the revision usage policy of "hg diff" command.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1044 (hg-diff (hg-root path) rev1 rev2)) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
1045 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
1046 (defun hg-forget (path) |
996
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1047 "Lose track of PATH, which has been added, but not yet committed. |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1048 This will prevent the file from being incorporated into the Mercurial |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1049 repository on the next commit. |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1050 With a prefix argument, prompt for the path to forget." |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
1051 (interactive (list (hg-read-file-name " to forget"))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
1052 (let ((buf (current-buffer)) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
1053 (update (equal buffer-file-name path))) |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
1054 (hg-view-output (hg-output-buffer-name) |
2454
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1055 (apply 'call-process (hg-binary) nil t nil (list "forget" path)) |
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1056 ;; "hg forget" shows pathes relative NOT TO ROOT BUT TO REPOSITORY |
2997
48baf9fb1921
mercurial.el: get rid of unportable, unperformant use of replace-regexp.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2877
diff
changeset
|
1057 (hg-fix-paths) |
2998
e1762867a734
mercurial.el: fix calls to goto-char.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2997
diff
changeset
|
1058 (goto-char (point-min)) |
2454
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1059 (cd (hg-root path))) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
1060 (when update |
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
1061 (with-current-buffer buf |
2667
92ba858ed640
Emacs: apply kill-local-variable instead of make-local-variable to FORGET
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2518
diff
changeset
|
1062 (when (local-variable-p 'backup-inhibited) |
92ba858ed640
Emacs: apply kill-local-variable instead of make-local-variable to FORGET
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2518
diff
changeset
|
1063 (kill-local-variable 'backup-inhibited)) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
1064 (hg-mode-line))))) |
1308
2073e5a71008
Cleanup of tabs and trailing spaces.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1246
diff
changeset
|
1065 |
1029
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1066 (defun hg-incoming (&optional repo) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1067 "Display changesets present in REPO that are not present locally." |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1068 (interactive (list (hg-read-repo-name " where changes would come from"))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1069 (hg-view-output ((format "Mercurial: Incoming from %s to %s" |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1070 (hg-abbrev-file-name (hg-root)) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1071 (hg-abbrev-file-name |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1072 (or repo hg-incoming-repository)))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1073 (call-process (hg-binary) nil t nil "incoming" |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1074 (or repo hg-incoming-repository)) |
2454
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1075 (hg-log-mode) |
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1076 (cd (hg-root)))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1077 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1078 (defun hg-init () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1079 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1080 (error "not implemented")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1081 |
1029
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1082 (defun hg-log-mode () |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1083 "Mode for viewing a Mercurial change log." |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1084 (goto-char (point-min)) |
2452
d1a7c8a5b835
Emacs: use delete-region instead of kill-* functions.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1085 (when (looking-at "^searching for changes.*$") |
d1a7c8a5b835
Emacs: use delete-region instead of kill-* functions.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1086 (delete-region (match-beginning 0) (match-end 0))) |
1029
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1087 (run-hooks 'hg-log-mode-hook)) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1088 |
2316
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1089 (defun hg-log (path &optional rev1 rev2 log-limit) |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1090 "Display the revision history of PATH. |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1091 History is displayed between REV1 and REV2. |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1092 Number of displayed changesets is limited to LOG-LIMIT. |
4693
3f484688c702
mercurial.el: change default log range to tip:0
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4433
diff
changeset
|
1093 REV1 defaults to the tip, while REV2 defaults to 0. |
2316
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1094 LOG-LIMIT defaults to `hg-log-limit'. |
1027
cb31576ed3e4
Emacs: fix up hg-log and hg-diff to operate more uniformly.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1026
diff
changeset
|
1095 With a prefix argument, prompt for each parameter." |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
1096 (interactive (list (hg-read-file-name " to log") |
2316
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1097 (hg-read-rev " to start with" |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1098 "tip") |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1099 (hg-read-rev " to end with" |
4693
3f484688c702
mercurial.el: change default log range to tip:0
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4433
diff
changeset
|
1100 "0") |
2316
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1101 (hg-read-number "Output limited to: " |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1102 hg-log-limit))) |
1027
cb31576ed3e4
Emacs: fix up hg-log and hg-diff to operate more uniformly.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1026
diff
changeset
|
1103 (let ((a-path (hg-abbrev-file-name path)) |
4693
3f484688c702
mercurial.el: change default log range to tip:0
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4433
diff
changeset
|
1104 (r1 (or rev1 "tip")) |
3f484688c702
mercurial.el: change default log range to tip:0
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4433
diff
changeset
|
1105 (r2 (or rev2 "0")) |
2316
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1106 (limit (format "%d" (or log-limit hg-log-limit)))) |
1027
cb31576ed3e4
Emacs: fix up hg-log and hg-diff to operate more uniformly.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1026
diff
changeset
|
1107 (hg-view-output ((if (equal r1 r2) |
2316
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1108 (format "Mercurial: Log of rev %s of %s" rev1 a-path) |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4694
diff
changeset
|
1109 (format |
2316
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1110 "Mercurial: at most %s log(s) from rev %s to %s of %s" |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1111 limit r1 r2 a-path))) |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1112 (eval (list* 'call-process (hg-binary) nil t nil |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1113 "log" |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1114 "-r" (format "%s:%s" r1 r2) |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1115 "-l" limit |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1116 (if (> (length path) (length (hg-root path))) |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1117 (cons path nil) |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1118 nil))) |
2454
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1119 (hg-log-mode) |
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1120 (cd (hg-root path))))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1121 |
2316
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1122 (defun hg-log-repo (path &optional rev1 rev2 log-limit) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
1123 "Display the revision history of the repository containing PATH. |
2316
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1124 History is displayed between REV1 and REV2. |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1125 Number of displayed changesets is limited to LOG-LIMIT, |
4693
3f484688c702
mercurial.el: change default log range to tip:0
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4433
diff
changeset
|
1126 REV1 defaults to the tip, while REV2 defaults to 0. |
2316
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1127 LOG-LIMIT defaults to `hg-log-limit'. |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1128 With a prefix argument, prompt for each parameter." |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
1129 (interactive (list (hg-read-file-name " to log") |
2316
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1130 (hg-read-rev " to start with" |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1131 "tip") |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4694
diff
changeset
|
1132 (hg-read-rev " to end with" |
4693
3f484688c702
mercurial.el: change default log range to tip:0
NIIMI Satoshi <sa2c@sa2c.net>
parents:
4433
diff
changeset
|
1133 "0") |
2316
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1134 (hg-read-number "Output limited to: " |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1135 hg-log-limit))) |
3d58376a7103
Emacs: separate limitations of revision range and shown changesets.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
1371
diff
changeset
|
1136 (hg-log (hg-root path) rev1 rev2 log-limit)) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
1137 |
1029
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1138 (defun hg-outgoing (&optional repo) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1139 "Display changesets present locally that are not present in REPO." |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1140 (interactive (list (hg-read-repo-name " where changes would go to" nil |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1141 hg-outgoing-repository))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1142 (hg-view-output ((format "Mercurial: Outgoing from %s to %s" |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1143 (hg-abbrev-file-name (hg-root)) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1144 (hg-abbrev-file-name |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1145 (or repo hg-outgoing-repository)))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1146 (call-process (hg-binary) nil t nil "outgoing" |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1147 (or repo hg-outgoing-repository)) |
2454
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1148 (hg-log-mode) |
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1149 (cd (hg-root)))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1150 |
1246
ae96c85fb0af
mercurial.el: implement hg-pull, and stub in hg-update.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1179
diff
changeset
|
1151 (defun hg-pull (&optional repo) |
ae96c85fb0af
mercurial.el: implement hg-pull, and stub in hg-update.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1179
diff
changeset
|
1152 "Pull changes from repository REPO. |
ae96c85fb0af
mercurial.el: implement hg-pull, and stub in hg-update.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1179
diff
changeset
|
1153 This does not update the working directory." |
ae96c85fb0af
mercurial.el: implement hg-pull, and stub in hg-update.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1179
diff
changeset
|
1154 (interactive (list (hg-read-repo-name " to pull from"))) |
ae96c85fb0af
mercurial.el: implement hg-pull, and stub in hg-update.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1179
diff
changeset
|
1155 (hg-view-output ((format "Mercurial: Pull to %s from %s" |
ae96c85fb0af
mercurial.el: implement hg-pull, and stub in hg-update.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1179
diff
changeset
|
1156 (hg-abbrev-file-name (hg-root)) |
ae96c85fb0af
mercurial.el: implement hg-pull, and stub in hg-update.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1179
diff
changeset
|
1157 (hg-abbrev-file-name |
ae96c85fb0af
mercurial.el: implement hg-pull, and stub in hg-update.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1179
diff
changeset
|
1158 (or repo hg-incoming-repository)))) |
ae96c85fb0af
mercurial.el: implement hg-pull, and stub in hg-update.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1179
diff
changeset
|
1159 (call-process (hg-binary) nil t nil "pull" |
2454
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1160 (or repo hg-incoming-repository)) |
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1161 (cd (hg-root)))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1162 |
1029
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1163 (defun hg-push (&optional repo) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1164 "Push changes to repository REPO." |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1165 (interactive (list (hg-read-repo-name " to push to"))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1166 (hg-view-output ((format "Mercurial: Push from %s to %s" |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1167 (hg-abbrev-file-name (hg-root)) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1168 (hg-abbrev-file-name |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1169 (or repo hg-outgoing-repository)))) |
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1170 (call-process (hg-binary) nil t nil "push" |
2454
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1171 (or repo hg-outgoing-repository)) |
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1172 (cd (hg-root)))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1173 |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1174 (defun hg-revert-buffer-internal () |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1175 (let ((ctx (hg-buffer-context))) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1176 (message "Reverting %s..." buffer-file-name) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1177 (hg-run0 "revert" buffer-file-name) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1178 (revert-buffer t t t) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1179 (hg-restore-context ctx) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1180 (hg-mode-line) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1181 (message "Reverting %s...done" buffer-file-name))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1182 |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1183 (defun hg-revert-buffer () |
996
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1184 "Revert current buffer's file back to the latest committed version. |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1185 If the file has not changed, nothing happens. Otherwise, this |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1186 displays a diff and asks for confirmation before reverting." |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1187 (interactive) |
995
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1188 (let ((vc-suppress-confirm nil) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1189 (obuf (current-buffer)) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1190 diff) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1191 (vc-buffer-sync) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1192 (unwind-protect |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1193 (setq diff (hg-diff buffer-file-name)) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1194 (when diff |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1195 (unless (yes-or-no-p "Discard changes? ") |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1196 (error "Revert cancelled"))) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1197 (when diff |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1198 (let ((buf (current-buffer))) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1199 (delete-window (selected-window)) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1200 (kill-buffer buf)))) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1201 (set-buffer obuf) |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1202 (when diff |
1e4b009b379e
Emacs support: add hg-revert-buffer.
Bryan O'Sullivan <bos@serpentine.com>
parents:
958
diff
changeset
|
1203 (hg-revert-buffer-internal)))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1204 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1205 (defun hg-root (&optional path) |
996
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1206 "Return the root of the repository that contains the given path. |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1207 If the path is outside a repository, return nil. |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1208 When called interactively, the root is printed. A prefix argument |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1209 prompts for a path to check." |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
1210 (interactive (list (hg-read-file-name))) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
1211 (if (or path (not hg-root)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
1212 (let ((root (do ((prev nil dir) |
2453
b5902db74ba3
Emacs: use `default-directory' if `buffer-file-name' is null.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2452
diff
changeset
|
1213 (dir (file-name-directory |
b5902db74ba3
Emacs: use `default-directory' if `buffer-file-name' is null.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2452
diff
changeset
|
1214 (or |
b5902db74ba3
Emacs: use `default-directory' if `buffer-file-name' is null.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2452
diff
changeset
|
1215 path |
b5902db74ba3
Emacs: use `default-directory' if `buffer-file-name' is null.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2452
diff
changeset
|
1216 buffer-file-name |
b5902db74ba3
Emacs: use `default-directory' if `buffer-file-name' is null.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2452
diff
changeset
|
1217 (expand-file-name default-directory))) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
1218 (file-name-directory (directory-file-name dir)))) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
1219 ((equal prev dir)) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
1220 (when (file-directory-p (concat dir ".hg")) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
1221 (return dir))))) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
1222 (when (interactive-p) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
1223 (if root |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
1224 (message "The root of this repository is `%s'." root) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
1225 (message "The path `%s' is not in a Mercurial repository." |
1029
b5f0ccad8917
Emacs: implement hg-incoming, hg-outgoing and hg-push.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1027
diff
changeset
|
1226 (hg-abbrev-file-name path)))) |
1003
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
1227 root) |
6dfc9cc71f42
Emacs support: numerous changes.
bos@serpentine.internal.keyresearch.com
parents:
1001
diff
changeset
|
1228 hg-root)) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1229 |
3003
78fe7e2c2e1e
mercurial.el: add hg-cwd
Bryan O'Sullivan <bos@serpentine.com>
parents:
3002
diff
changeset
|
1230 (defun hg-cwd (&optional path) |
78fe7e2c2e1e
mercurial.el: add hg-cwd
Bryan O'Sullivan <bos@serpentine.com>
parents:
3002
diff
changeset
|
1231 "Return the current directory of PATH within the repository." |
78fe7e2c2e1e
mercurial.el: add hg-cwd
Bryan O'Sullivan <bos@serpentine.com>
parents:
3002
diff
changeset
|
1232 (do ((stack nil (cons (file-name-nondirectory |
78fe7e2c2e1e
mercurial.el: add hg-cwd
Bryan O'Sullivan <bos@serpentine.com>
parents:
3002
diff
changeset
|
1233 (directory-file-name dir)) |
78fe7e2c2e1e
mercurial.el: add hg-cwd
Bryan O'Sullivan <bos@serpentine.com>
parents:
3002
diff
changeset
|
1234 stack)) |
78fe7e2c2e1e
mercurial.el: add hg-cwd
Bryan O'Sullivan <bos@serpentine.com>
parents:
3002
diff
changeset
|
1235 (prev nil dir) |
78fe7e2c2e1e
mercurial.el: add hg-cwd
Bryan O'Sullivan <bos@serpentine.com>
parents:
3002
diff
changeset
|
1236 (dir (file-name-directory (or path buffer-file-name |
78fe7e2c2e1e
mercurial.el: add hg-cwd
Bryan O'Sullivan <bos@serpentine.com>
parents:
3002
diff
changeset
|
1237 (expand-file-name default-directory))) |
78fe7e2c2e1e
mercurial.el: add hg-cwd
Bryan O'Sullivan <bos@serpentine.com>
parents:
3002
diff
changeset
|
1238 (file-name-directory (directory-file-name dir)))) |
78fe7e2c2e1e
mercurial.el: add hg-cwd
Bryan O'Sullivan <bos@serpentine.com>
parents:
3002
diff
changeset
|
1239 ((equal prev dir)) |
78fe7e2c2e1e
mercurial.el: add hg-cwd
Bryan O'Sullivan <bos@serpentine.com>
parents:
3002
diff
changeset
|
1240 (when (file-directory-p (concat dir ".hg")) |
78fe7e2c2e1e
mercurial.el: add hg-cwd
Bryan O'Sullivan <bos@serpentine.com>
parents:
3002
diff
changeset
|
1241 (let ((cwd (mapconcat 'identity stack "/"))) |
78fe7e2c2e1e
mercurial.el: add hg-cwd
Bryan O'Sullivan <bos@serpentine.com>
parents:
3002
diff
changeset
|
1242 (unless (equal cwd "") |
78fe7e2c2e1e
mercurial.el: add hg-cwd
Bryan O'Sullivan <bos@serpentine.com>
parents:
3002
diff
changeset
|
1243 (return (file-name-as-directory cwd))))))) |
78fe7e2c2e1e
mercurial.el: add hg-cwd
Bryan O'Sullivan <bos@serpentine.com>
parents:
3002
diff
changeset
|
1244 |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
1245 (defun hg-status (path) |
996
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1246 "Print revision control status of a file or directory. |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1247 With prefix argument, prompt for the path to give status for. |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1248 Names are displayed relative to the repository root." |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
1249 (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
|
1250 (let ((root (hg-root))) |
996
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1251 (hg-view-output ((format "Mercurial: Status of %s in %s" |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1252 (let ((name (substring (expand-file-name path) |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1253 (length root)))) |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1254 (if (> (length name) 0) |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1255 name |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1256 "*")) |
5ed566574486
Emacs: document existing functions.
Bryan O'Sullivan <bos@serpentine.com>
parents:
995
diff
changeset
|
1257 (hg-abbrev-file-name root))) |
947
4cabedfab66e
In-progress Emacs snapshot.
Bryan O'Sullivan <bos@serpentine.com>
parents:
945
diff
changeset
|
1258 (apply 'call-process (hg-binary) nil t nil |
2454
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1259 (list "--cwd" root "status" path)) |
74518478d2bf
Emacs: change directory of output buffer to the root of the repository.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
2317
diff
changeset
|
1260 (cd (hg-root path))))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1261 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1262 (defun hg-undo () |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1263 (interactive) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1264 (error "not implemented")) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1265 |
1246
ae96c85fb0af
mercurial.el: implement hg-pull, and stub in hg-update.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1179
diff
changeset
|
1266 (defun hg-update () |
ae96c85fb0af
mercurial.el: implement hg-pull, and stub in hg-update.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1179
diff
changeset
|
1267 (interactive) |
ae96c85fb0af
mercurial.el: implement hg-pull, and stub in hg-update.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1179
diff
changeset
|
1268 (error "not implemented")) |
ae96c85fb0af
mercurial.el: implement hg-pull, and stub in hg-update.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1179
diff
changeset
|
1269 |
4875
97dbf330069a
Re: mercurial.el and hg-version-other-window
jon.christopher@Rigaku.com
parents:
4694
diff
changeset
|
1270 (defun hg-version-other-window (rev) |
97dbf330069a
Re: mercurial.el and hg-version-other-window
jon.christopher@Rigaku.com
parents:
4694
diff
changeset
|
1271 "Visit version REV of the current file in another window. |
97dbf330069a
Re: mercurial.el and hg-version-other-window
jon.christopher@Rigaku.com
parents:
4694
diff
changeset
|
1272 If the current file is named `F', the version is named `F.~REV~'. |
97dbf330069a
Re: mercurial.el and hg-version-other-window
jon.christopher@Rigaku.com
parents:
4694
diff
changeset
|
1273 If `F.~REV~' already exists, use it instead of checking it out again." |
97dbf330069a
Re: mercurial.el and hg-version-other-window
jon.christopher@Rigaku.com
parents:
4694
diff
changeset
|
1274 (interactive "sVersion to visit (default is workfile version): ") |
97dbf330069a
Re: mercurial.el and hg-version-other-window
jon.christopher@Rigaku.com
parents:
4694
diff
changeset
|
1275 (let* ((file buffer-file-name) |
97dbf330069a
Re: mercurial.el and hg-version-other-window
jon.christopher@Rigaku.com
parents:
4694
diff
changeset
|
1276 (version (if (string-equal rev "") |
97dbf330069a
Re: mercurial.el and hg-version-other-window
jon.christopher@Rigaku.com
parents:
4694
diff
changeset
|
1277 "tip" |
97dbf330069a
Re: mercurial.el and hg-version-other-window
jon.christopher@Rigaku.com
parents:
4694
diff
changeset
|
1278 rev)) |
97dbf330069a
Re: mercurial.el and hg-version-other-window
jon.christopher@Rigaku.com
parents:
4694
diff
changeset
|
1279 (automatic-backup (vc-version-backup-file-name file version)) |
97dbf330069a
Re: mercurial.el and hg-version-other-window
jon.christopher@Rigaku.com
parents:
4694
diff
changeset
|
1280 (manual-backup (vc-version-backup-file-name file version 'manual))) |
97dbf330069a
Re: mercurial.el and hg-version-other-window
jon.christopher@Rigaku.com
parents:
4694
diff
changeset
|
1281 (unless (file-exists-p manual-backup) |
97dbf330069a
Re: mercurial.el and hg-version-other-window
jon.christopher@Rigaku.com
parents:
4694
diff
changeset
|
1282 (if (file-exists-p automatic-backup) |
97dbf330069a
Re: mercurial.el and hg-version-other-window
jon.christopher@Rigaku.com
parents:
4694
diff
changeset
|
1283 (rename-file automatic-backup manual-backup nil) |
97dbf330069a
Re: mercurial.el and hg-version-other-window
jon.christopher@Rigaku.com
parents:
4694
diff
changeset
|
1284 (hg-run0 "-q" "cat" "-r" version "-o" manual-backup file))) |
97dbf330069a
Re: mercurial.el and hg-version-other-window
jon.christopher@Rigaku.com
parents:
4694
diff
changeset
|
1285 (find-file-other-window manual-backup))) |
944
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1286 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1287 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1288 (provide 'mercurial) |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1289 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1290 |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1291 ;;; Local Variables: |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1292 ;;; prompt-to-byte-compile: nil |
41ca6bf19735
Initial skeleton for mercurial.el.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1293 ;;; end: |