diff options
| author | Stefan Monnier | 2007-09-14 16:33:47 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2007-09-14 16:33:47 +0000 |
| commit | b1dc6d44c91080a303754a78ea36ba4e5ce05dcf (patch) | |
| tree | 8327a344fb70e610fafae46eddfab63c0599276d | |
| parent | 6f00fa338385a12d7065046f91e8ac857bfa755d (diff) | |
| download | emacs-b1dc6d44c91080a303754a78ea36ba4e5ce05dcf.tar.gz emacs-b1dc6d44c91080a303754a78ea36ba4e5ce05dcf.zip | |
Add vc-mtn.el.
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/vc-hooks.el | 7 | ||||
| -rw-r--r-- | lisp/vc-mtn.el | 285 |
4 files changed, 300 insertions, 6 deletions
| @@ -80,7 +80,9 @@ this variable. | |||
| 80 | 80 | ||
| 81 | *** VC backends can provide completion of revision names. | 81 | *** VC backends can provide completion of revision names. |
| 82 | 82 | ||
| 83 | *** VC has some support for Mercurial (hg). | 83 | *** VC has some support for Mercurial (Hg). |
| 84 | |||
| 85 | *** VC has some support for Monotone (Mtn). | ||
| 84 | 86 | ||
| 85 | *** VC has some support for Bazaar (Bzr). | 87 | *** VC has some support for Bazaar (Bzr). |
| 86 | 88 | ||
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0fa66e193da..0c177765581 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2007-09-14 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * vc-mtn.el: New file. | ||
| 4 | |||
| 5 | * vc-hooks.el (vc-handled-backends): Add Mtn. | ||
| 6 | |||
| 1 | 2007-09-13 Eli Zaretskii <eliz@gnu.org> | 7 | 2007-09-13 Eli Zaretskii <eliz@gnu.org> |
| 2 | 8 | ||
| 3 | * files.el (find-file, find-file-other-window) | 9 | * files.el (find-file, find-file-other-window) |
| @@ -9,12 +15,12 @@ | |||
| 9 | 2007-09-13 Jari Aalto <jari.aalto@cante.net> | 15 | 2007-09-13 Jari Aalto <jari.aalto@cante.net> |
| 10 | 16 | ||
| 11 | * man.el (Man-default-man-entry): At end of line, continue looking | 17 | * man.el (Man-default-man-entry): At end of line, continue looking |
| 12 | to the next line for possible end of hyphenated command. | 18 | to the next line for possible end of hyphenated command. |
| 13 | 19 | ||
| 14 | 2007-09-13 Chris Moore <dooglus@gmail.com> | 20 | 2007-09-13 Chris Moore <dooglus@gmail.com> |
| 15 | 21 | ||
| 16 | * shell.el (shell-resync-dirs): Don't move the cursor relative to | 22 | * shell.el (shell-resync-dirs): Don't move the cursor relative to |
| 17 | the command being edited. | 23 | the command being edited. |
| 18 | 24 | ||
| 19 | 2007-09-13 Nick Roberts <nickrob@snap.net.nz> | 25 | 2007-09-13 Nick Roberts <nickrob@snap.net.nz> |
| 20 | 26 | ||
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el index 0356e10fe5c..1d28c055770 100644 --- a/lisp/vc-hooks.el +++ b/lisp/vc-hooks.el | |||
| @@ -63,9 +63,10 @@ interpreted as hostnames." | |||
| 63 | :group 'vc) | 63 | :group 'vc) |
| 64 | 64 | ||
| 65 | (defcustom vc-handled-backends '(RCS CVS SVN SCCS Bzr Git Hg Arch MCVS) | 65 | (defcustom vc-handled-backends '(RCS CVS SVN SCCS Bzr Git Hg Arch MCVS) |
| 66 | ;; Bzr, Git, Hg, Arch and MCVS come last because they are per-tree | 66 | ;; RCS, CVS, SVN and SCCS come first because they are per-dir |
| 67 | ;; rather than per-dir. | 67 | ;; rather than per-tree. RCS comes first because of the multibackend |
| 68 | "*List of version control backends for which VC will be used. | 68 | ;; support intended to use RCS for local commits (with a remote CVS server). |
| 69 | "List of version control backends for which VC will be used. | ||
| 69 | Entries in this list will be tried in order to determine whether a | 70 | Entries in this list will be tried in order to determine whether a |
| 70 | file is under that sort of version control. | 71 | file is under that sort of version control. |
| 71 | Removing an entry from the list prevents VC from being activated | 72 | Removing an entry from the list prevents VC from being activated |
diff --git a/lisp/vc-mtn.el b/lisp/vc-mtn.el new file mode 100644 index 00000000000..e24bf399ba1 --- /dev/null +++ b/lisp/vc-mtn.el | |||
| @@ -0,0 +1,285 @@ | |||
| 1 | ;;; vc-mtn.el --- VC backend for Monotone | ||
| 2 | |||
| 3 | ;; Copyright (C) 2007 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 6 | ;; Keywords: | ||
| 7 | |||
| 8 | ;; This file is free software; you can redistribute it and/or modify | ||
| 9 | ;; it under the terms of the GNU General Public License as published by | ||
| 10 | ;; the Free Software Foundation; either version 3, or (at your option) | ||
| 11 | ;; any later version. | ||
| 12 | |||
| 13 | ;; This file is distributed in the hope that it will be useful, | ||
| 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | ;; GNU General Public License for more details. | ||
| 17 | |||
| 18 | ;; You should have received a copy of the GNU General Public License | ||
| 19 | ;; along with GNU Emacs; see the file COPYING. If not, write to | ||
| 20 | ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
| 21 | ;; Boston, MA 02110-1301, USA. | ||
| 22 | |||
| 23 | ;;; Commentary: | ||
| 24 | |||
| 25 | ;; | ||
| 26 | |||
| 27 | ;;; Code: | ||
| 28 | |||
| 29 | (eval-when-compile (require 'cl) (require 'vc)) | ||
| 30 | |||
| 31 | ;; Clear up the cache to force vc-call to check again and discover | ||
| 32 | ;; new functions when we reload this file. | ||
| 33 | (put 'Mtn 'vc-functions nil) | ||
| 34 | |||
| 35 | (defvar vc-mtn-command "mtn") | ||
| 36 | (unless (executable-find vc-mtn-command) | ||
| 37 | ;; vc-mtn.el is 100% non-functional without the `mtn' executable. | ||
| 38 | (setq vc-handled-backends (delq 'Mtn vc-handled-backends))) | ||
| 39 | |||
| 40 | ;;;###autoload | ||
| 41 | (defconst vc-mtn-admin-dir "_MTN") | ||
| 42 | ;;;###autoload | ||
| 43 | (defconst vc-mtn-admin-format (concat vc-mtn-admin-dir "/format")) | ||
| 44 | |||
| 45 | ;;;###autoload (defun vc-mtn-registered (file) | ||
| 46 | ;;;###autoload (if (vc-find-root file vc-mtn-admin-format) | ||
| 47 | ;;;###autoload (progn | ||
| 48 | ;;;###autoload (load "vc-mtn") | ||
| 49 | ;;;###autoload (vc-mtn-registered file)))) | ||
| 50 | |||
| 51 | (defun vc-mtn-revision-granularity () 'repository) | ||
| 52 | (defun vc-mtn-checkout-model (file) 'implicit) | ||
| 53 | |||
| 54 | (defun vc-mtn-root (file) | ||
| 55 | (setq file (if (file-directory-p file) | ||
| 56 | (file-name-as-directory file) | ||
| 57 | (file-name-directory file))) | ||
| 58 | (or (vc-file-getprop file 'vc-mtn-root) | ||
| 59 | (vc-file-setprop file 'vc-mtn-root | ||
| 60 | (vc-find-root file vc-mtn-admin-format)))) | ||
| 61 | |||
| 62 | |||
| 63 | (defun vc-mtn-registered (file) | ||
| 64 | (let ((root (vc-mtn-root file))) | ||
| 65 | (when root | ||
| 66 | (vc-mtn-state file)))) | ||
| 67 | |||
| 68 | (defun vc-mtn-command (buffer okstatus files &rest flags) | ||
| 69 | "A wrapper around `vc-do-command' for use in vc-mtn.el." | ||
| 70 | (apply 'vc-do-command buffer okstatus vc-mtn-command files flags)) | ||
| 71 | |||
| 72 | (defun vc-mtn-state (file) | ||
| 73 | ;; If `mtn' fails or returns status>0, or if the search files, just | ||
| 74 | ;; return nil. | ||
| 75 | (ignore-errors | ||
| 76 | (with-temp-buffer | ||
| 77 | (vc-mtn-command t 0 file "status") | ||
| 78 | (goto-char (point-min)) | ||
| 79 | (re-search-forward "^ \\(?:patched \\(.*\\)\\|no changes$\\)") | ||
| 80 | (if (match-end 1) | ||
| 81 | 'edited | ||
| 82 | 'up-to-date)))) | ||
| 83 | |||
| 84 | (defun vc-mtn-workfile-version (file) | ||
| 85 | ;; If `mtn' fails or returns status>0, or if the search fails, just | ||
| 86 | ;; return nil. | ||
| 87 | (ignore-errors | ||
| 88 | (with-temp-buffer | ||
| 89 | (vc-mtn-command t 0 file "status") | ||
| 90 | (goto-char (point-min)) | ||
| 91 | (re-search-forward "Current branch: \\(.*\\)\nChanges against parent \\(.*\\)") | ||
| 92 | (match-string 2)))) | ||
| 93 | |||
| 94 | (defun vc-mtn-workfile-branch (file) | ||
| 95 | ;; If `mtn' fails or returns status>0, or if the search files, just | ||
| 96 | ;; return nil. | ||
| 97 | (ignore-errors | ||
| 98 | (with-temp-buffer | ||
| 99 | (vc-mtn-command t 0 file "status") | ||
| 100 | (goto-char (point-min)) | ||
| 101 | (re-search-forward "Current branch: \\(.*\\)\nChanges against parent \\(.*\\)") | ||
| 102 | (match-string 1)))) | ||
| 103 | |||
| 104 | (defun vc-mtn-workfile-unchanged-p (file) | ||
| 105 | (not (eq (vc-mtn-state file) 'edited))) | ||
| 106 | |||
| 107 | ;; Mode-line rewrite code copied from vc-arch.el. | ||
| 108 | |||
| 109 | (defcustom vc-mtn-mode-line-rewrite | ||
| 110 | '(("\\`[^:/#]*[:/#]" . "")) ;Drop the host part. | ||
| 111 | "Rewrite rules to shorten Mtn's revision names on the mode-line." | ||
| 112 | :type '(repeat (cons regexp string)) | ||
| 113 | :group 'vc) | ||
| 114 | |||
| 115 | (defun vc-mtn-mode-line-string (file) | ||
| 116 | "Return string for placement in modeline by `vc-mode-line' for FILE." | ||
| 117 | (let ((branch (vc-mtn-workfile-branch file))) | ||
| 118 | (dolist (rule vc-mtn-mode-line-rewrite) | ||
| 119 | (if (string-match (car rule) branch) | ||
| 120 | (setq branch (replace-match (cdr rule) t nil branch)))) | ||
| 121 | (format "Mtn%c%s" | ||
| 122 | (case (vc-state file) | ||
| 123 | ((up-to-date needs-patch) ?-) | ||
| 124 | (added ?@) | ||
| 125 | (t ?:)) | ||
| 126 | branch))) | ||
| 127 | |||
| 128 | (defun vc-mtn-register (files &optional rest) | ||
| 129 | (vc-mtn-command nil 0 files "add")) | ||
| 130 | |||
| 131 | (defun vc-mtn-responsible-p (file) (vc-mtn-root file)) | ||
| 132 | (defun vc-mtn-could-register (file) (vc-mtn-root file)) | ||
| 133 | |||
| 134 | (defun vc-mtn-checkin (files rev comment) | ||
| 135 | (vc-mtn-command nil 0 files "commit" "-m" comment)) | ||
| 136 | |||
| 137 | (defun vc-mtn-find-version (file rev buffer) | ||
| 138 | (vc-mtn-command buffer 0 file "cat" "-r" rev)) | ||
| 139 | |||
| 140 | ;; (defun vc-mtn-checkout (file &optional editable rev) | ||
| 141 | ;; ) | ||
| 142 | |||
| 143 | (defun vc-mtn-revert (file &optional contents-done) | ||
| 144 | (unless contents-done | ||
| 145 | (vc-mtn-command nil 0 file "revert"))) | ||
| 146 | |||
| 147 | ;; (defun vc-mtn-roolback (files) | ||
| 148 | ;; ) | ||
| 149 | |||
| 150 | (defun vc-mtn-print-log (files &optional buffer) | ||
| 151 | (vc-mtn-command buffer 0 files "log")) | ||
| 152 | |||
| 153 | (define-derived-mode vc-mtn-log-view-mode log-view-mode "Mtn-Log-View" | ||
| 154 | ;; TODO: Not sure what to do about file markers for now. | ||
| 155 | (set (make-local-variable 'log-view-file-re) "\\'\\`") | ||
| 156 | ;; TODO: Use a more precise regexp than "[ |/]+" to avoid false positives | ||
| 157 | ;; in the ChangeLog text. | ||
| 158 | (set (make-local-variable 'log-view-message-re) | ||
| 159 | "^[ |/]+Revision: \\([0-9a-f]+\\)") | ||
| 160 | (require 'add-log) ;For change-log faces. | ||
| 161 | (set (make-local-variable 'log-view-font-lock-keywords) | ||
| 162 | (append log-view-font-lock-keywords | ||
| 163 | '(("^[ |]+Author: \\(.*\\)" (1 'change-log-email)) | ||
| 164 | ("^[ |]+Date: \\(.*\\)" (1 'change-log-date-face)))))) | ||
| 165 | |||
| 166 | ;; (defun vc-mtn-show-log-entry (version) | ||
| 167 | ;; ) | ||
| 168 | |||
| 169 | (defun vc-mtn-wash-log (file)) | ||
| 170 | |||
| 171 | (defalias 'vc-mtn-diff-tree 'vc-mtn-diff) | ||
| 172 | (defun vc-mtn-diff (files &optional rev1 rev2 buffer) | ||
| 173 | (apply 'vc-mtn-command (or buffer "*vc-diff*") 1 files "diff" | ||
| 174 | (append (if rev1 (list "-r" rev1)) (if rev2 (list "-r" rev2))))) | ||
| 175 | |||
| 176 | (defun vc-mtn-annotate-command (file buf &optional rev) | ||
| 177 | (apply 'vc-mtn-command buf 0 file "annotate" | ||
| 178 | (if rev (list "-r" rev)))) | ||
| 179 | |||
| 180 | (defconst vc-mtn-annotate-full-re | ||
| 181 | "^ *\\([0-9a-f]+\\)\\.* by [^ ]+ \\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\): ") | ||
| 182 | (defconst vc-mtn-annotate-any-re | ||
| 183 | (concat "^\\(?: +: \\|" vc-mtn-annotate-full-re "\\)")) | ||
| 184 | |||
| 185 | (defun vc-mtn-annotate-time () | ||
| 186 | (when (looking-at vc-mtn-annotate-any-re) | ||
| 187 | (goto-char (match-end 0)) | ||
| 188 | (let ((year (match-string 2))) | ||
| 189 | (if (not year) | ||
| 190 | ;; Look for the date on a previous line. | ||
| 191 | (save-excursion | ||
| 192 | (get-text-property (1- (previous-single-property-change | ||
| 193 | (point) 'vc-mtn-time nil (point-min))) | ||
| 194 | 'vc-mtn-time)) | ||
| 195 | (let ((time (vc-annotate-convert-time | ||
| 196 | (encode-time 0 0 0 | ||
| 197 | (string-to-number (match-string 4)) | ||
| 198 | (string-to-number (match-string 3)) | ||
| 199 | (string-to-number year) | ||
| 200 | t)))) | ||
| 201 | (let ((inhibit-read-only t) | ||
| 202 | (inhibit-modification-hooks t)) | ||
| 203 | (put-text-property (match-beginning 0) (match-end 0) | ||
| 204 | 'vc-mtn-time time)) | ||
| 205 | time))))) | ||
| 206 | |||
| 207 | (defun vc-mtn-annotate-extract-revision-at-line () | ||
| 208 | (save-excursion | ||
| 209 | (when (or (looking-at vc-mtn-annotate-full-re) | ||
| 210 | (re-search-backward vc-mtn-annotate-full-re nil t)) | ||
| 211 | (match-string 1)))) | ||
| 212 | |||
| 213 | ;;; Revision completion. | ||
| 214 | |||
| 215 | (defun vc-mtn-list-tags () | ||
| 216 | (with-temp-buffer | ||
| 217 | (vc-mtn-command t 0 nil "list" "tags") | ||
| 218 | (goto-char (point-min)) | ||
| 219 | (let ((tags ())) | ||
| 220 | (while (re-search-forward "^[^ ]+" nil t) | ||
| 221 | (push (match-string 0) tags)) | ||
| 222 | tags))) | ||
| 223 | |||
| 224 | (defun vc-mtn-list-branches () | ||
| 225 | (with-temp-buffer | ||
| 226 | (vc-mtn-command t 0 nil "list" "branches") | ||
| 227 | (goto-char (point-min)) | ||
| 228 | (let ((branches ())) | ||
| 229 | (while (re-search-forward "^.+" nil t) | ||
| 230 | (push (match-string 0) branches)) | ||
| 231 | branches))) | ||
| 232 | |||
| 233 | (defun vc-mtn-list-revision-ids (prefix) | ||
| 234 | (with-temp-buffer | ||
| 235 | (vc-mtn-command t 0 nil "complete" "revision" prefix) | ||
| 236 | (goto-char (point-min)) | ||
| 237 | (let ((ids ())) | ||
| 238 | (while (re-search-forward "^.+" nil t) | ||
| 239 | (push (match-string 0) ids)) | ||
| 240 | ids))) | ||
| 241 | |||
| 242 | (defun vc-mtn-revision-completion-table (file) | ||
| 243 | ;; TODO: Implement completion for for selectors | ||
| 244 | ;; TODO: Implement completion for composite selectors. | ||
| 245 | (lexical-let ((file file)) | ||
| 246 | (lambda (string pred action) | ||
| 247 | (cond | ||
| 248 | ;; "Tag" selectors. | ||
| 249 | ((string-match "\\`t:" string) | ||
| 250 | (complete-with-action action | ||
| 251 | (mapcar (lambda (tag) (concat "t:" tag)) | ||
| 252 | (vc-mtn-list-tags)) | ||
| 253 | string pred)) | ||
| 254 | ;; "Branch" selectors. | ||
| 255 | ((string-match "\\`b:" string) | ||
| 256 | (complete-with-action action | ||
| 257 | (mapcar (lambda (tag) (concat "b:" tag)) | ||
| 258 | (vc-mtn-list-branches)) | ||
| 259 | string pred)) | ||
| 260 | ;; "Head" selectors. Not sure how they differ from "branch" selectors. | ||
| 261 | ((string-match "\\`h:" string) | ||
| 262 | (complete-with-action action | ||
| 263 | (mapcar (lambda (tag) (concat "h:" tag)) | ||
| 264 | (vc-mtn-list-branches)) | ||
| 265 | string pred)) | ||
| 266 | ;; "ID" selectors. | ||
| 267 | ((string-match "\\`i:" string) | ||
| 268 | (complete-with-action action | ||
| 269 | (mapcar (lambda (tag) (concat "i:" tag)) | ||
| 270 | (vc-mtn-list-revision-ids | ||
| 271 | (substring string (match-end 0)))) | ||
| 272 | string pred)) | ||
| 273 | (t | ||
| 274 | (complete-with-action action | ||
| 275 | '("t:" "b:" "h:" "i:" | ||
| 276 | ;; Completion not implemented for these. | ||
| 277 | "a:" "c:" "d:" "e:" "l:") | ||
| 278 | string pred)))))) | ||
| 279 | |||
| 280 | |||
| 281 | |||
| 282 | (provide 'vc-mtn) | ||
| 283 | |||
| 284 | ;; arch-tag: 2b89ffbc-cbb8-405a-9080-2eafd4becb70 | ||
| 285 | ;;; vc-mtn.el ends here | ||