Mercurial > hg > mercurial-crew-with-dirclash
annotate contrib/mq.el @ 4536:720ae5085ee3
commit: fix bug where dirstate for removed file is confused
This fixes issue586
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 10 Jun 2007 21:16:58 -0500 |
parents | 3b0f73edee57 |
children | ea7b982b6c08 |
rev | line source |
---|---|
2993
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 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
8 ;; under the terms of version 2 of the GNU General Public License as |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
9 ;; published by the Free Software Foundation. |
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 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
21 (require 'mercurial) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
22 |
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 (defcustom mq-mode-hook nil |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
25 "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
|
26 :type 'sexp |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
27 :group 'mercurial) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
28 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
29 (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
|
30 "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
|
31 :type 'sexp |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
32 :group 'mercurial) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
33 |
2995
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
34 (defcustom mq-edit-mode-hook nil |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
35 "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:
2993
diff
changeset
|
36 :type 'sexp |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
37 :group 'mercurial) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
38 |
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
|
39 (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
|
40 "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
|
41 :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
|
42 :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
|
43 |
4429
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
44 (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
|
45 "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
|
46 :type 'string |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
47 :group 'mercurial) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
48 |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
49 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
50 ;;; Internal variables. |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
51 |
3370
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
52 (defvar mq-mode nil |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
53 "Is this file managed by MQ?") |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
54 (make-variable-buffer-local 'mq-mode) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
55 (put 'mq-mode 'permanent-local t) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
56 |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
57 (defvar mq-patch-history nil) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
58 |
3370
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
59 (defvar mq-top-patch '(nil)) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
60 |
2995
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
61 (defvar mq-prev-buffer nil) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
62 (make-variable-buffer-local 'mq-prev-buffer) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
63 (put 'mq-prev-buffer 'permanent-local t) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
64 |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
65 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
66 ;;; Global keymap. |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
67 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
68 (defvar mq-global-map (make-sparse-keymap)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
69 (fset 'mq-global-map mq-global-map) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
70 (global-set-key mq-global-prefix 'mq-global-map) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
71 (define-key mq-global-map "." 'mq-push) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
72 (define-key mq-global-map ">" 'mq-push-all) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
73 (define-key mq-global-map "," 'mq-pop) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
74 (define-key mq-global-map "<" 'mq-pop-all) |
4424
1d31302c4522
mq.el: add mq-diff function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4423
diff
changeset
|
75 (define-key mq-global-map "=" 'mq-diff) |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
76 (define-key mq-global-map "r" 'mq-refresh) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
77 (define-key mq-global-map "e" 'mq-refresh-edit) |
4422
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
78 (define-key mq-global-map "i" 'mq-new) |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
79 (define-key mq-global-map "n" 'mq-next) |
4429
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
80 (define-key mq-global-map "o" 'mq-signoff) |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
81 (define-key mq-global-map "p" 'mq-previous) |
4423
2647f1fbc24c
mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4422
diff
changeset
|
82 (define-key mq-global-map "s" 'mq-edit-series) |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
83 (define-key mq-global-map "t" 'mq-top) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
84 |
3370
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
85 (add-minor-mode 'mq-mode 'mq-mode) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
86 |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
87 |
2995
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
88 ;;; Refresh edit mode keymap. |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
89 |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
90 (defvar mq-edit-mode-map (make-sparse-keymap)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
91 (define-key mq-edit-mode-map "\C-c\C-c" 'mq-edit-finish) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
92 (define-key mq-edit-mode-map "\C-c\C-k" 'mq-edit-kill) |
4429
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
93 (define-key mq-edit-mode-map "\C-c\C-s" 'mq-signoff) |
2995
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
94 |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
95 |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
96 ;;; Helper functions. |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
97 |
4422
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
98 (defun mq-read-patch-name (&optional source prompt force) |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
99 "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
|
100 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
|
101 (let ((patches (split-string |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
102 (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
|
103 (when force |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
104 (completing-read (format "Patch%s: " (or prompt "")) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
105 (map 'list 'cons patches patches) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
106 nil |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
107 nil |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
108 nil |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
109 'mq-patch-history)))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
110 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
111 (defun mq-refresh-buffers (root) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
112 (save-excursion |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
113 (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
|
114 (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
|
115 (set-buffer buf) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
116 (let ((ctx (hg-buffer-context))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
117 (message "Refreshing %s..." (buffer-name)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
118 (revert-buffer t t t) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
119 (hg-restore-context ctx) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
120 (message "Refreshing %s...done" (buffer-name)))))) |
3370
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
121 (hg-update-mode-lines root) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
122 (mq-update-mode-lines root)) |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
123 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
124 (defun mq-last-line () |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
125 (goto-char (point-max)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
126 (beginning-of-line) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
127 (when (looking-at "^$") |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
128 (forward-line -1)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
129 (let ((bol (point))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
130 (end-of-line) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
131 (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
|
132 (when (> (length line) 0) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
133 line)))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
134 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
135 (defun mq-push (&optional patch) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
136 "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
|
137 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
|
138 (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
|
139 current-prefix-arg))) |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
140 (let ((root (hg-root)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
141 (prev-buf (current-buffer)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
142 last-line ok) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
143 (unless root |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
144 (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
|
145 (hg-sync-buffers root) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
146 (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
|
147 (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
|
148 (split-window-vertically) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
149 (other-window 1) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
150 (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
|
151 (cd root) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
152 (message "Pushing...") |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
153 (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
|
154 (if patch (list patch)))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
155 last-line (mq-last-line)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
156 (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
|
157 (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
|
158 (and (equal lines 2) (string-match "Now at:" last-line))) |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
159 (progn |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
160 (kill-buffer (current-buffer)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
161 (delete-window)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
162 (hg-view-mode prev-buf)))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
163 (mq-refresh-buffers root) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
164 (sit-for 0) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
165 (when last-line |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
166 (if ok |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
167 (message "Pushing... %s" last-line) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
168 (error "Pushing... %s" last-line))))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
169 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
170 (defun mq-push-all () |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
171 "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
|
172 (interactive) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
173 (mq-push "-a")) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
174 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
175 (defun mq-pop (&optional patch) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
176 "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
|
177 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
|
178 (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
|
179 current-prefix-arg))) |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
180 (let ((root (hg-root)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
181 last-line ok) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
182 (unless root |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
183 (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
|
184 (hg-sync-buffers root) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
185 (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
|
186 (cd root) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
187 (message "Popping...") |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
188 (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
|
189 (if patch (list patch)))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
190 last-line (mq-last-line)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
191 (kill-buffer (current-buffer)) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
192 (mq-refresh-buffers root) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
193 (sit-for 0) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
194 (when last-line |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
195 (if ok |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
196 (message "Popping... %s" last-line) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
197 (error "Popping... %s" last-line))))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
198 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
199 (defun mq-pop-all () |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
200 "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
|
201 (interactive) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
202 (mq-pop "-a")) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
203 |
2995
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
204 (defun mq-refresh-internal (root &rest args) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
205 (hg-sync-buffers root) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
206 (let ((patch (mq-patch-info "qtop"))) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
207 (message "Refreshing %s..." patch) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
208 (let ((ret (apply 'hg-run "qrefresh" args))) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
209 (if (equal (car ret) 0) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
210 (message "Refreshing %s... done." patch) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
211 (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:
2993
diff
changeset
|
212 |
4426
807c7b99ff13
imported patch mq-refresh-git.patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4425
diff
changeset
|
213 (defun mq-refresh (&optional git) |
807c7b99ff13
imported patch mq-refresh-git.patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4425
diff
changeset
|
214 "Refresh the topmost applied patch. |
807c7b99ff13
imported patch mq-refresh-git.patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4425
diff
changeset
|
215 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
|
216 (interactive "P") |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
217 (let ((root (hg-root))) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
218 (unless root |
2995
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
219 (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
|
220 (apply 'mq-refresh-internal root (if git '("--git"))))) |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
221 |
2995
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
222 (defun mq-patch-info (cmd &optional msg) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
223 (let* ((ret (hg-run cmd)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
224 (info (hg-chomp (cdr ret)))) |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
225 (if (equal (car ret) 0) |
2995
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
226 (if msg |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
227 (message "%s patch: %s" msg info) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
228 info) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
229 (error "%s" info)))) |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
230 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
231 (defun mq-top () |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
232 "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
|
233 (interactive) |
2995
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
234 (mq-patch-info "qtop" "Top")) |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
235 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
236 (defun mq-next () |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
237 "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
|
238 (interactive) |
2995
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
239 (mq-patch-info "qnext" "Next")) |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
240 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
241 (defun mq-previous () |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
242 "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
|
243 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
|
244 (interactive) |
2995
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
245 (mq-patch-info "qprev" "Previous")) |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
246 |
2995
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
247 (defun mq-edit-finish () |
2996
06696f9c30c0
mq.el: Add comment to mq-edit-finish.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2995
diff
changeset
|
248 "Finish editing the description of this patch, and refresh the patch." |
2995
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
249 (interactive) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
250 (unless (equal (mq-patch-info "qtop") mq-top) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
251 (error "Topmost patch has changed!")) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
252 (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
|
253 (run-hooks 'mq-edit-finish-hook) |
2995
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
254 (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:
2993
diff
changeset
|
255 (let ((buf mq-prev-buffer)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
256 (kill-buffer nil) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
257 (switch-to-buffer buf))) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
258 |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
259 (defun mq-edit-kill () |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
260 "Kill the edit currently being prepared." |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
261 (interactive) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
262 (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:
2993
diff
changeset
|
263 (let ((buf mq-prev-buffer)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
264 (kill-buffer nil) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
265 (switch-to-buffer buf)))) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
266 |
3370
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
267 (defun mq-get-top (root) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
268 (let ((entry (assoc root mq-top-patch))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
269 (if entry |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
270 (cdr entry)))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
271 |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
272 (defun mq-set-top (root patch) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
273 (let ((entry (assoc root mq-top-patch))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
274 (if entry |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
275 (if patch |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
276 (setcdr entry patch) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
277 (setq mq-top-patch (delq entry mq-top-patch))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
278 (setq mq-top-patch (cons (cons root patch) mq-top-patch))))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
279 |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
280 (defun mq-update-mode-lines (root) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
281 (let ((cwd default-directory)) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
282 (cd root) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
283 (condition-case nil |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
284 (mq-set-top root (mq-patch-info "qtop")) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
285 (error (mq-set-top root nil))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
286 (cd cwd)) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
287 (let ((patch (mq-get-top root))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
288 (save-excursion |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
289 (dolist (buf (hg-buffers-visiting-repo root)) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
290 (set-buffer buf) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
291 (if mq-mode |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
292 (setq mq-mode (or (and patch (concat " MQ:" patch)) " MQ"))))))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
293 |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
294 (defun mq-mode (&optional arg) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
295 "Minor mode for Mercurial repositories with an MQ patch queue" |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
296 (interactive "i") |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
297 (cond ((hg-root) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
298 (setq mq-mode (if (null arg) (not mq-mode) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
299 arg)) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
300 (mq-update-mode-lines (hg-root)))) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
301 (run-hooks 'mq-mode-hook)) |
b7fe334ff4fb
mq.el: add mode-line hook
Brendan Cully <brendan@kublai.com>
parents:
2996
diff
changeset
|
302 |
2995
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
303 (defun mq-edit-mode () |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
304 "Mode for editing the description of a patch. |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
305 |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
306 Key bindings |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
307 ------------ |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
308 \\[mq-edit-finish] use this description |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
309 \\[mq-edit-kill] abandon this description" |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
310 (interactive) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
311 (use-local-map mq-edit-mode-map) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
312 (set-syntax-table text-mode-syntax-table) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
313 (setq local-abbrev-table text-mode-abbrev-table |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
314 major-mode 'mq-edit-mode |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
315 mode-name "MQ-Edit") |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
316 (set-buffer-modified-p nil) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
317 (setq buffer-undo-list nil) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
318 (run-hooks 'text-mode-hook 'mq-edit-mode-hook)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
319 |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
320 (defun mq-refresh-edit () |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
321 "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
|
322 (interactive) |
2995
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
323 (while mq-prev-buffer |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
324 (set-buffer mq-prev-buffer)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
325 (let ((root (hg-root)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
326 (prev-buffer (current-buffer)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
327 (patch (mq-patch-info "qtop"))) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
328 (hg-sync-buffers root) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
329 (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:
2993
diff
changeset
|
330 (switch-to-buffer (get-buffer-create buf-name)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
331 (when (= (point-min) (point-max)) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
332 (set (make-local-variable 'hg-root) root) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
333 (set (make-local-variable 'mq-top) patch) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
334 (setq mq-prev-buffer prev-buffer) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
335 (insert (hg-run0 "qheader")) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
336 (goto-char (point-min))) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
337 (mq-edit-mode) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
338 (cd root))) |
e2bad806ccc3
mq.el: add ability to edit a patch.
Bryan O'Sullivan <bos@serpentine.com>
parents:
2993
diff
changeset
|
339 (message "Type `C-c C-c' to finish editing and refresh the patch.")) |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
340 |
4422
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
341 (defun mq-new (name) |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
342 "Create a new empty patch named NAME. |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
343 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
|
344 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
|
345 directory is modified." |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
346 (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
|
347 (message "Creating patch...") |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
348 (let ((ret (if current-prefix-arg |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
349 (hg-run "qnew" "-f" name) |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
350 (hg-run "qnew" name)))) |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
351 (if (equal (car ret) 0) |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
352 (progn |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
353 (hg-update-mode-lines (buffer-file-name)) |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
354 (message "Creating patch... done.")) |
7b0d0acea6d6
mq.el: add mq-new function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
3370
diff
changeset
|
355 (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
|
356 |
4423
2647f1fbc24c
mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4422
diff
changeset
|
357 (defun mq-edit-series () |
2647f1fbc24c
mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4422
diff
changeset
|
358 "Edit the MQ series file directly." |
2647f1fbc24c
mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4422
diff
changeset
|
359 (interactive) |
2647f1fbc24c
mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4422
diff
changeset
|
360 (let ((root (hg-root))) |
2647f1fbc24c
mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4422
diff
changeset
|
361 (unless root |
2647f1fbc24c
mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4422
diff
changeset
|
362 (error "Not in an MQ repository!")) |
2647f1fbc24c
mq.el: add mq-edit-series function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4422
diff
changeset
|
363 (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
|
364 |
4425
a57ac6049e22
mq.el: allow mq-diff to take a git option.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4424
diff
changeset
|
365 (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
|
366 "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
|
367 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
|
368 (interactive "P") |
4424
1d31302c4522
mq.el: add mq-diff function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4423
diff
changeset
|
369 (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
|
370 (if git |
a57ac6049e22
mq.el: allow mq-diff to take a git option.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4424
diff
changeset
|
371 (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
|
372 (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
|
373 (diff-mode) |
1d31302c4522
mq.el: add mq-diff function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4423
diff
changeset
|
374 (font-lock-fontify-buffer))) |
1d31302c4522
mq.el: add mq-diff function.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4423
diff
changeset
|
375 |
4429
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
376 (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
|
377 "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
|
378 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
|
379 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
|
380 (interactive) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
381 (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
|
382 signed) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
383 (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
|
384 (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
|
385 (save-excursion |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
386 (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
|
387 (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
|
388 (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
|
389 (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
|
390 (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
|
391 (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
|
392 (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
|
393 (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
|
394 (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
|
395 (insert "\n"))) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
396 (insert signoff) |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
397 (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
|
398 (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
|
399 (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
|
400 (if signed |
3b0f73edee57
mq.el: add mq-signoff, to sign off on a patch
Bryan O'Sullivan <bos@serpentine.com>
parents:
4428
diff
changeset
|
401 (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
|
402 (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
|
403 |
2993
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
404 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
405 (provide 'mq) |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
406 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
407 |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
408 ;;; Local Variables: |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
409 ;;; prompt-to-byte-compile: nil |
425413d9ef59
Emacs: add mq.el, early support for Mercurial Queues.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
410 ;;; end: |