author | Christian Ebert <blacktrash@gmx.net> |
Thu, 28 Jan 2010 10:38:29 +0000 | |
branch | stable |
changeset 10283 | 2ae7f001b61d |
parent 10263 | 25e572394f5c |
child 15782 | 7de7630053cb |
permissions | -rw-r--r-- |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
1 |
;;; mq.el --- Emacs support for Mercurial Queues |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
2 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
3 |
;; Copyright (C) 2006 Bryan O'Sullivan |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
4 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
5 |
;; Author: Bryan O'Sullivan <bos@serpentine.com> |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
6 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
7 |
;; mq.el is free software; you can redistribute it and/or modify it |
10263 | 8 |
;; under the terms of the GNU General Public License version 2 or any |
9 |
;; later version. |
|
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
10 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
11 |
;; mq.el is distributed in the hope that it will be useful, but |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
12 |
;; WITHOUT ANY WARRANTY; without even the implied warranty of |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
13 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
14 |
;; General Public License for more details. |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
15 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
16 |
;; You should have received a copy of the GNU General Public License |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
17 |
;; along with mq.el, GNU Emacs, or XEmacs; see the file COPYING (`C-h |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
18 |
;; C-l'). If not, write to the Free Software Foundation, Inc., 59 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
19 |
;; Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
20 |
|
5465
9873cbb134b2
mercurial.el, mq.el: remove runtime dependencies on CL package
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5081
diff
changeset
|
21 |
(eval-when-compile (require 'cl)) |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
22 |
(require 'mercurial) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
23 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
24 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
25 |
(defcustom mq-mode-hook nil |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
26 |
"Hook run when a buffer enters mq-mode." |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
27 |
:type 'sexp |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
28 |
:group 'mercurial) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
29 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
30 |
(defcustom mq-global-prefix "\C-cq" |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
31 |
"The global prefix for Mercurial Queues keymap bindings." |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
32 |
:type 'sexp |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
33 |
:group 'mercurial) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
34 |
|
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
35 |
(defcustom mq-edit-mode-hook nil |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
36 |
"Hook run after a buffer is populated to edit a patch description." |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
37 |
:type 'sexp |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
38 |
:group 'mercurial) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
39 |
|
4427
b59611e9dd64
mq.el: add hook to run when finishing the edit of a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4426
diff
changeset
|
40 |
(defcustom mq-edit-finish-hook nil |
b59611e9dd64
mq.el: add hook to run when finishing the edit of a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4426
diff
changeset
|
41 |
"Hook run before a patch description is finished up with." |
b59611e9dd64
mq.el: add hook to run when finishing the edit of a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4426
diff
changeset
|
42 |
:type 'sexp |
b59611e9dd64
mq.el: add hook to run when finishing the edit of a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4426
diff
changeset
|
43 |
:group 'mercurial) |
b59611e9dd64
mq.el: add hook to run when finishing the edit of a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4426
diff
changeset
|
44 |
|
4429
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
45 |
(defcustom mq-signoff-address nil |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
46 |
"Address with which to sign off on a patch." |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
47 |
:type 'string |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
48 |
:group 'mercurial) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
49 |
|
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
50 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
51 |
;;; Internal variables. |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
52 |
|
3370
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
53 |
(defvar mq-mode nil |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
54 |
"Is this file managed by MQ?") |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
55 |
(make-variable-buffer-local 'mq-mode) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
56 |
(put 'mq-mode 'permanent-local t) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
57 |
|
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
58 |
(defvar mq-patch-history nil) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
59 |
|
3370
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
60 |
(defvar mq-top-patch '(nil)) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
61 |
|
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
62 |
(defvar mq-prev-buffer nil) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
63 |
(make-variable-buffer-local 'mq-prev-buffer) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
64 |
(put 'mq-prev-buffer 'permanent-local t) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
65 |
|
5466
87860c62e003
mq.el: declare variable mq-top
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5465
diff
changeset
|
66 |
(defvar mq-top nil) |
87860c62e003
mq.el: declare variable mq-top
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5465
diff
changeset
|
67 |
(make-variable-buffer-local 'mq-top) |
87860c62e003
mq.el: declare variable mq-top
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5465
diff
changeset
|
68 |
(put 'mq-top 'permanent-local t) |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
69 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
70 |
;;; Global keymap. |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
71 |
|
5468
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
72 |
(defvar mq-global-map |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
73 |
(let ((map (make-sparse-keymap))) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
74 |
(define-key map "." 'mq-push) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
75 |
(define-key map ">" 'mq-push-all) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
76 |
(define-key map "," 'mq-pop) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
77 |
(define-key map "<" 'mq-pop-all) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
78 |
(define-key map "=" 'mq-diff) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
79 |
(define-key map "r" 'mq-refresh) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
80 |
(define-key map "e" 'mq-refresh-edit) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
81 |
(define-key map "i" 'mq-new) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
82 |
(define-key map "n" 'mq-next) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
83 |
(define-key map "o" 'mq-signoff) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
84 |
(define-key map "p" 'mq-previous) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
85 |
(define-key map "s" 'mq-edit-series) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
86 |
(define-key map "t" 'mq-top) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
87 |
map)) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
88 |
|
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
89 |
(global-set-key mq-global-prefix mq-global-map) |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
90 |
|
3370
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
91 |
(add-minor-mode 'mq-mode 'mq-mode) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
92 |
|
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
93 |
|
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
94 |
;;; Refresh edit mode keymap. |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
95 |
|
5468
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
96 |
(defvar mq-edit-mode-map |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
97 |
(let ((map (make-sparse-keymap))) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
98 |
(define-key map "\C-c\C-c" 'mq-edit-finish) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
99 |
(define-key map "\C-c\C-k" 'mq-edit-kill) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
100 |
(define-key map "\C-c\C-s" 'mq-signoff) |
24eb1bf8dd83
mq.el: define keymaps as convensions
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5466
diff
changeset
|
101 |
map)) |
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
102 |
|
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
103 |
|
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
104 |
;;; Helper functions. |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
105 |
|
4422
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
106 |
(defun mq-read-patch-name (&optional source prompt force) |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
107 |
"Read a patch name to use with a command. |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
108 |
May return nil, meaning \"use the default\"." |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
109 |
(let ((patches (split-string |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
110 |
(hg-chomp (hg-run0 (or source "qseries"))) "\n"))) |
4422
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
111 |
(when force |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
112 |
(completing-read (format "Patch%s: " (or prompt "")) |
5465
9873cbb134b2
mercurial.el, mq.el: remove runtime dependencies on CL package
NIIMI Satoshi <sa2c@sa2c.net>
parents:
5081
diff
changeset
|
113 |
(mapcar (lambda (x) (cons x x)) patches) |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
114 |
nil |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
115 |
nil |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
116 |
nil |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
117 |
'mq-patch-history)))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
118 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
119 |
(defun mq-refresh-buffers (root) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
120 |
(save-excursion |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
121 |
(dolist (buf (hg-buffers-visiting-repo root)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
122 |
(when (not (verify-visited-file-modtime buf)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
123 |
(set-buffer buf) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
124 |
(let ((ctx (hg-buffer-context))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
125 |
(message "Refreshing %s..." (buffer-name)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
126 |
(revert-buffer t t t) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
127 |
(hg-restore-context ctx) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
128 |
(message "Refreshing %s...done" (buffer-name)))))) |
3370
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
129 |
(hg-update-mode-lines root) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
130 |
(mq-update-mode-lines root)) |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
131 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
132 |
(defun mq-last-line () |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
133 |
(goto-char (point-max)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
134 |
(beginning-of-line) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
135 |
(when (looking-at "^$") |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
136 |
(forward-line -1)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
137 |
(let ((bol (point))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
138 |
(end-of-line) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
139 |
(let ((line (buffer-substring bol (point)))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
140 |
(when (> (length line) 0) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
141 |
line)))) |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4429
diff
changeset
|
142 |
|
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
143 |
(defun mq-push (&optional patch) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
144 |
"Push patches until PATCH is reached. |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
145 |
If PATCH is nil, push at most one patch." |
4422
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
146 |
(interactive (list (mq-read-patch-name "qunapplied" " to push" |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
147 |
current-prefix-arg))) |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
148 |
(let ((root (hg-root)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
149 |
(prev-buf (current-buffer)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
150 |
last-line ok) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
151 |
(unless root |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
152 |
(error "Cannot push outside a repository!")) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
153 |
(hg-sync-buffers root) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
154 |
(let ((buf-name (format "MQ: Push %s" (or patch "next patch")))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
155 |
(kill-buffer (get-buffer-create buf-name)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
156 |
(split-window-vertically) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
157 |
(other-window 1) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
158 |
(switch-to-buffer (get-buffer-create buf-name)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
159 |
(cd root) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
160 |
(message "Pushing...") |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
161 |
(setq ok (= 0 (apply 'call-process (hg-binary) nil t t "qpush" |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
162 |
(if patch (list patch)))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
163 |
last-line (mq-last-line)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
164 |
(let ((lines (count-lines (point-min) (point-max)))) |
4428
fa51e66117b4
mq.el: don't fill half the screen with a single line of output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4427
diff
changeset
|
165 |
(if (or (<= lines 1) |
fa51e66117b4
mq.el: don't fill half the screen with a single line of output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4427
diff
changeset
|
166 |
(and (equal lines 2) (string-match "Now at:" last-line))) |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
167 |
(progn |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
168 |
(kill-buffer (current-buffer)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
169 |
(delete-window)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
170 |
(hg-view-mode prev-buf)))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
171 |
(mq-refresh-buffers root) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
172 |
(sit-for 0) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
173 |
(when last-line |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
174 |
(if ok |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
175 |
(message "Pushing... %s" last-line) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
176 |
(error "Pushing... %s" last-line))))) |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4429
diff
changeset
|
177 |
|
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
178 |
(defun mq-push-all () |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
179 |
"Push patches until all are applied." |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
180 |
(interactive) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
181 |
(mq-push "-a")) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
182 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
183 |
(defun mq-pop (&optional patch) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
184 |
"Pop patches until PATCH is reached. |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
185 |
If PATCH is nil, pop at most one patch." |
4422
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
186 |
(interactive (list (mq-read-patch-name "qapplied" " to pop to" |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
187 |
current-prefix-arg))) |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
188 |
(let ((root (hg-root)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
189 |
last-line ok) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
190 |
(unless root |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
191 |
(error "Cannot pop outside a repository!")) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
192 |
(hg-sync-buffers root) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
193 |
(set-buffer (generate-new-buffer "qpop")) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
194 |
(cd root) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
195 |
(message "Popping...") |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
196 |
(setq ok (= 0 (apply 'call-process (hg-binary) nil t t "qpop" |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
197 |
(if patch (list patch)))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
198 |
last-line (mq-last-line)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
199 |
(kill-buffer (current-buffer)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
200 |
(mq-refresh-buffers root) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
201 |
(sit-for 0) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
202 |
(when last-line |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
203 |
(if ok |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
204 |
(message "Popping... %s" last-line) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
205 |
(error "Popping... %s" last-line))))) |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4429
diff
changeset
|
206 |
|
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
207 |
(defun mq-pop-all () |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
208 |
"Push patches until none are applied." |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
209 |
(interactive) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
210 |
(mq-pop "-a")) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
211 |
|
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
212 |
(defun mq-refresh-internal (root &rest args) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
213 |
(hg-sync-buffers root) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
214 |
(let ((patch (mq-patch-info "qtop"))) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
215 |
(message "Refreshing %s..." patch) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
216 |
(let ((ret (apply 'hg-run "qrefresh" args))) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
217 |
(if (equal (car ret) 0) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
218 |
(message "Refreshing %s... done." patch) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
219 |
(error "Refreshing %s... %s" patch (hg-chomp (cdr ret))))))) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
220 |
|
4426
807c7b99ff13
imported patch mq-refresh-git.patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4425
diff
changeset
|
221 |
(defun mq-refresh (&optional git) |
807c7b99ff13
imported patch mq-refresh-git.patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4425
diff
changeset
|
222 |
"Refresh the topmost applied patch. |
807c7b99ff13
imported patch mq-refresh-git.patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4425
diff
changeset
|
223 |
With a prefix argument, generate a git-compatible patch." |
807c7b99ff13
imported patch mq-refresh-git.patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4425
diff
changeset
|
224 |
(interactive "P") |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
225 |
(let ((root (hg-root))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
226 |
(unless root |
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
227 |
(error "Cannot refresh outside of a repository!")) |
4426
807c7b99ff13
imported patch mq-refresh-git.patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4425
diff
changeset
|
228 |
(apply 'mq-refresh-internal root (if git '("--git"))))) |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
229 |
|
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
230 |
(defun mq-patch-info (cmd &optional msg) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
231 |
(let* ((ret (hg-run cmd)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
232 |
(info (hg-chomp (cdr ret)))) |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
233 |
(if (equal (car ret) 0) |
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
234 |
(if msg |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
235 |
(message "%s patch: %s" msg info) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
236 |
info) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
237 |
(error "%s" info)))) |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
238 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
239 |
(defun mq-top () |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
240 |
"Print the name of the topmost applied patch." |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
241 |
(interactive) |
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
242 |
(mq-patch-info "qtop" "Top")) |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
243 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
244 |
(defun mq-next () |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
245 |
"Print the name of the next patch to be pushed." |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
246 |
(interactive) |
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
247 |
(mq-patch-info "qnext" "Next")) |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
248 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
249 |
(defun mq-previous () |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
250 |
"Print the name of the first patch below the topmost applied patch. |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
251 |
This would become the active patch if popped to." |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
252 |
(interactive) |
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
253 |
(mq-patch-info "qprev" "Previous")) |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
254 |
|
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
255 |
(defun mq-edit-finish () |
3010
06696f9c30c0
mq.el: Add comment to mq-edit-finish.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3009
diff
changeset
|
256 |
"Finish editing the description of this patch, and refresh the patch." |
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
257 |
(interactive) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
258 |
(unless (equal (mq-patch-info "qtop") mq-top) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
259 |
(error "Topmost patch has changed!")) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
260 |
(hg-sync-buffers hg-root) |
4427
b59611e9dd64
mq.el: add hook to run when finishing the edit of a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4426
diff
changeset
|
261 |
(run-hooks 'mq-edit-finish-hook) |
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
262 |
(mq-refresh-internal hg-root "-m" (buffer-substring (point-min) (point-max))) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
263 |
(let ((buf mq-prev-buffer)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
264 |
(kill-buffer nil) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
265 |
(switch-to-buffer buf))) |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4429
diff
changeset
|
266 |
|
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
267 |
(defun mq-edit-kill () |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
268 |
"Kill the edit currently being prepared." |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
269 |
(interactive) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
270 |
(when (or (not (buffer-modified-p)) (y-or-n-p "Really kill this edit? ")) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
271 |
(let ((buf mq-prev-buffer)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
272 |
(kill-buffer nil) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
273 |
(switch-to-buffer buf)))) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
274 |
|
3370
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
275 |
(defun mq-get-top (root) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
276 |
(let ((entry (assoc root mq-top-patch))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
277 |
(if entry |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
278 |
(cdr entry)))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
279 |
|
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
280 |
(defun mq-set-top (root patch) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
281 |
(let ((entry (assoc root mq-top-patch))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
282 |
(if entry |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
283 |
(if patch |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
284 |
(setcdr entry patch) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
285 |
(setq mq-top-patch (delq entry mq-top-patch))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
286 |
(setq mq-top-patch (cons (cons root patch) mq-top-patch))))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
287 |
|
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
288 |
(defun mq-update-mode-lines (root) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
289 |
(let ((cwd default-directory)) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
290 |
(cd root) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
291 |
(condition-case nil |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
292 |
(mq-set-top root (mq-patch-info "qtop")) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
293 |
(error (mq-set-top root nil))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
294 |
(cd cwd)) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
295 |
(let ((patch (mq-get-top root))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
296 |
(save-excursion |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
297 |
(dolist (buf (hg-buffers-visiting-repo root)) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
298 |
(set-buffer buf) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
299 |
(if mq-mode |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
300 |
(setq mq-mode (or (and patch (concat " MQ:" patch)) " MQ"))))))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
301 |
|
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
302 |
(defun mq-mode (&optional arg) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
303 |
"Minor mode for Mercurial repositories with an MQ patch queue" |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
304 |
(interactive "i") |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
305 |
(cond ((hg-root) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
306 |
(setq mq-mode (if (null arg) (not mq-mode) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
307 |
arg)) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
308 |
(mq-update-mode-lines (hg-root)))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
309 |
(run-hooks 'mq-mode-hook)) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
3010
diff
changeset
|
310 |
|
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
311 |
(defun mq-edit-mode () |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
312 |
"Mode for editing the description of a patch. |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
313 |
|
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
314 |
Key bindings |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
315 |
------------ |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
316 |
\\[mq-edit-finish] use this description |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
317 |
\\[mq-edit-kill] abandon this description" |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
318 |
(interactive) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
319 |
(use-local-map mq-edit-mode-map) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
320 |
(set-syntax-table text-mode-syntax-table) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
321 |
(setq local-abbrev-table text-mode-abbrev-table |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
322 |
major-mode 'mq-edit-mode |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
323 |
mode-name "MQ-Edit") |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
324 |
(set-buffer-modified-p nil) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
325 |
(setq buffer-undo-list nil) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
326 |
(run-hooks 'text-mode-hook 'mq-edit-mode-hook)) |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4429
diff
changeset
|
327 |
|
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
328 |
(defun mq-refresh-edit () |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
329 |
"Refresh the topmost applied patch, editing the patch description." |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
330 |
(interactive) |
3009
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
331 |
(while mq-prev-buffer |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
332 |
(set-buffer mq-prev-buffer)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
333 |
(let ((root (hg-root)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
334 |
(prev-buffer (current-buffer)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
335 |
(patch (mq-patch-info "qtop"))) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
336 |
(hg-sync-buffers root) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
337 |
(let ((buf-name (format "*MQ: Edit description of %s*" patch))) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
338 |
(switch-to-buffer (get-buffer-create buf-name)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
339 |
(when (= (point-min) (point-max)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
340 |
(set (make-local-variable 'hg-root) root) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
341 |
(set (make-local-variable 'mq-top) patch) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
342 |
(setq mq-prev-buffer prev-buffer) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
343 |
(insert (hg-run0 "qheader")) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
344 |
(goto-char (point-min))) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
345 |
(mq-edit-mode) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
346 |
(cd root))) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3007
diff
changeset
|
347 |
(message "Type `C-c C-c' to finish editing and refresh the patch.")) |
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
348 |
|
4422
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
349 |
(defun mq-new (name) |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
350 |
"Create a new empty patch named NAME. |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
351 |
The patch is applied on top of the current topmost patch. |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
352 |
With a prefix argument, forcibly create the patch even if the working |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
353 |
directory is modified." |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
354 |
(interactive (list (mq-read-patch-name "qseries" " to create" t))) |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
355 |
(message "Creating patch...") |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
356 |
(let ((ret (if current-prefix-arg |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
357 |
(hg-run "qnew" "-f" name) |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
358 |
(hg-run "qnew" name)))) |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
359 |
(if (equal (car ret) 0) |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
360 |
(progn |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
361 |
(hg-update-mode-lines (buffer-file-name)) |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
362 |
(message "Creating patch... done.")) |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
363 |
(error "Creating patch... %s" (hg-chomp (cdr ret)))))) |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
364 |
|
4423
2647f1fbc24c
mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4422
diff
changeset
|
365 |
(defun mq-edit-series () |
2647f1fbc24c
mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4422
diff
changeset
|
366 |
"Edit the MQ series file directly." |
2647f1fbc24c
mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4422
diff
changeset
|
367 |
(interactive) |
2647f1fbc24c
mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4422
diff
changeset
|
368 |
(let ((root (hg-root))) |
2647f1fbc24c
mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4422
diff
changeset
|
369 |
(unless root |
2647f1fbc24c
mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4422
diff
changeset
|
370 |
(error "Not in an MQ repository!")) |
2647f1fbc24c
mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4422
diff
changeset
|
371 |
(find-file (concat root ".hg/patches/series")))) |
2647f1fbc24c
mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4422
diff
changeset
|
372 |
|
4425
a57ac6049e22
mq.el: allow mq-diff to take a git option.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4424
diff
changeset
|
373 |
(defun mq-diff (&optional git) |
a57ac6049e22
mq.el: allow mq-diff to take a git option.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4424
diff
changeset
|
374 |
"Display a diff of the topmost applied patch. |
a57ac6049e22
mq.el: allow mq-diff to take a git option.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4424
diff
changeset
|
375 |
With a prefix argument, display a git-compatible diff." |
a57ac6049e22
mq.el: allow mq-diff to take a git option.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4424
diff
changeset
|
376 |
(interactive "P") |
4424
1d31302c4522
mq.el: add mq-diff function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4423
diff
changeset
|
377 |
(hg-view-output ((format "MQ: Diff of %s" (mq-patch-info "qtop"))) |
4425
a57ac6049e22
mq.el: allow mq-diff to take a git option.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4424
diff
changeset
|
378 |
(if git |
a57ac6049e22
mq.el: allow mq-diff to take a git option.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4424
diff
changeset
|
379 |
(call-process (hg-binary) nil t nil "qdiff" "--git") |
a57ac6049e22
mq.el: allow mq-diff to take a git option.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4424
diff
changeset
|
380 |
(call-process (hg-binary) nil t nil "qdiff")) |
4424
1d31302c4522
mq.el: add mq-diff function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4423
diff
changeset
|
381 |
(diff-mode) |
1d31302c4522
mq.el: add mq-diff function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4423
diff
changeset
|
382 |
(font-lock-fontify-buffer))) |
1d31302c4522
mq.el: add mq-diff function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4423
diff
changeset
|
383 |
|
4429
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
384 |
(defun mq-signoff () |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
385 |
"Sign off on the current patch, in the style used by the Linux kernel. |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
386 |
If the variable mq-signoff-address is non-nil, it will be used, otherwise |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
387 |
the value of the ui.username item from your hgrc will be used." |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
388 |
(interactive) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
389 |
(let ((was-editing (eq major-mode 'mq-edit-mode)) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
390 |
signed) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
391 |
(unless was-editing |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
392 |
(mq-refresh-edit)) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
393 |
(save-excursion |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
394 |
(let* ((user (or mq-signoff-address |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
395 |
(hg-run0 "debugconfig" "ui.username"))) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
396 |
(signoff (concat "Signed-off-by: " user))) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
397 |
(if (search-forward signoff nil t) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
398 |
(message "You have already signed off on this patch.") |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
399 |
(goto-char (point-max)) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
400 |
(let ((case-fold-search t)) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
401 |
(if (re-search-backward "^Signed-off-by: " nil t) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
402 |
(forward-line 1) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
403 |
(insert "\n"))) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
404 |
(insert signoff) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
405 |
(message "%s" signoff) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
406 |
(setq signed t)))) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
407 |
(unless was-editing |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
408 |
(if signed |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
409 |
(mq-edit-finish) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
410 |
(mq-edit-kill))))) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
411 |
|
3007
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
412 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
413 |
(provide 'mq) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
414 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
415 |
|
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
416 |
;;; Local Variables: |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
417 |
;;; prompt-to-byte-compile: nil |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
418 |
;;; end: |