diff options
| author | Dan Nicolaescu | 2007-06-20 05:59:41 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2007-06-20 05:59:41 +0000 |
| commit | 612234482fca3112c63432612ea023822b45fbea (patch) | |
| tree | 4122b1313761c62703f897104e2c5a9f858d2f48 | |
| parent | b20c4725bdc15471ef8632de84489afb9ac2f810 (diff) | |
| download | emacs-612234482fca3112c63432612ea023822b45fbea.tar.gz emacs-612234482fca3112c63432612ea023822b45fbea.zip | |
* vc-hg.el: New file.
| -rw-r--r-- | etc/NEWS | 2 | ||||
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/vc-hg.el | 126 |
3 files changed, 132 insertions, 0 deletions
| @@ -71,6 +71,8 @@ considered for update. | |||
| 71 | 71 | ||
| 72 | ** VC has some support for Bazaar (bzr). | 72 | ** VC has some support for Bazaar (bzr). |
| 73 | 73 | ||
| 74 | ** VC has some support for Mercurial (hg). | ||
| 75 | |||
| 74 | ** sgml-electric-tag-pair-mode lets you simultaneously edit matched tag pairs. | 76 | ** sgml-electric-tag-pair-mode lets you simultaneously edit matched tag pairs. |
| 75 | 77 | ||
| 76 | 78 | ||
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ea0f3774b16..757e07170cd 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2007-06-19 Ivan Kanis <apple@kanis.eu> | ||
| 2 | |||
| 3 | * vc-hg.el: New file. | ||
| 4 | |||
| 1 | 2007-06-17 Glenn Morris <rgm@gnu.org> | 5 | 2007-06-17 Glenn Morris <rgm@gnu.org> |
| 2 | 6 | ||
| 3 | * lpr.el (lpr-page-header-switches): Move %s to separate element | 7 | * lpr.el (lpr-page-header-switches): Move %s to separate element |
diff --git a/lisp/vc-hg.el b/lisp/vc-hg.el new file mode 100644 index 00000000000..79296f8bbb9 --- /dev/null +++ b/lisp/vc-hg.el | |||
| @@ -0,0 +1,126 @@ | |||
| 1 | ;;; vc-hg.el --- VC backend for the mercurial version control system | ||
| 2 | |||
| 3 | ;; Copyright (C) 2006 Ivan Kanis | ||
| 4 | ;; Author: Ivan Kanis | ||
| 5 | ;; $Id: vc-hg.el 1889 2007-06-17 12:39:26Z ivan $ | ||
| 6 | ;; | ||
| 7 | ;; This program is free software ; you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation ; either version 2 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | ;; | ||
| 12 | ;; This program is distributed in the hope that it will be useful, but | ||
| 13 | ;; WITHOUT ANY WARRANTY ; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | ;; General Public License for more details. | ||
| 16 | ;; | ||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with this program ; if not, write to the Free Software | ||
| 19 | ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 20 | |||
| 21 | ;;; Commentary: | ||
| 22 | |||
| 23 | ;; This is a mercurial version control backend | ||
| 24 | |||
| 25 | ;;; THANKS: | ||
| 26 | |||
| 27 | ;;; BUGS: | ||
| 28 | |||
| 29 | ;;; INSTALLATION: | ||
| 30 | |||
| 31 | ;;; Code: | ||
| 32 | |||
| 33 | (eval-when-compile | ||
| 34 | (require 'vc)) | ||
| 35 | |||
| 36 | ;; (setq vc-handled-backends '(CVS SVN hg)) | ||
| 37 | |||
| 38 | ;;; Customization options | ||
| 39 | |||
| 40 | (defcustom vc-hg-global-switches nil | ||
| 41 | "*Global switches to pass to any Hg command." | ||
| 42 | :type '(choice (const :tag "None" nil) | ||
| 43 | (string :tag "Argument String") | ||
| 44 | (repeat :tag "Argument List" | ||
| 45 | :value ("") | ||
| 46 | string)) | ||
| 47 | :version "22.1" | ||
| 48 | :group 'vc) | ||
| 49 | |||
| 50 | ;;; State querying functions | ||
| 51 | |||
| 52 | (defun vc-hg-registered (file) | ||
| 53 | "Return t if FILE is registered in Hg" | ||
| 54 | (if (eq 0 (call-process "hg" nil nil nil | ||
| 55 | "--cwd" (file-name-directory file) | ||
| 56 | "status" (file-name-nondirectory file))) | ||
| 57 | (vc-file-setprop file 'vc-name file) nil)) | ||
| 58 | |||
| 59 | (defun vc-hg-state (file) | ||
| 60 | "Return state of files in Hg" | ||
| 61 | (let ((out (vc-hg-internal-status file))) | ||
| 62 | (if (eq 0 (length out)) 'up-to-date | ||
| 63 | (let ((state (aref out 0))) | ||
| 64 | (cond | ||
| 65 | ((eq state ?M) 'edited) | ||
| 66 | ((eq state ?P) 'needs-patch) | ||
| 67 | (t 'up-to-date)))))) | ||
| 68 | |||
| 69 | (defun vc-hg-workfile-version (file) | ||
| 70 | "Return version number of file" | ||
| 71 | (let ((out (vc-hg-internal-log file))) | ||
| 72 | (if (string-match "changeset: *\\([0-9]*\\)" out) | ||
| 73 | (match-string 1 out) | ||
| 74 | "0"))) | ||
| 75 | |||
| 76 | (defun vc-hg-internal-log(file) | ||
| 77 | "Return log of FILE" | ||
| 78 | (with-output-to-string | ||
| 79 | (with-current-buffer | ||
| 80 | standard-output | ||
| 81 | (call-process | ||
| 82 | "hg" nil t nil "--cwd" (file-name-directory file) | ||
| 83 | "log" "-l1" (file-name-nondirectory file))))) | ||
| 84 | |||
| 85 | ;;; History functions | ||
| 86 | |||
| 87 | (defun vc-hg-print-log(file &optional buffer) | ||
| 88 | "Get change log associated with FILE." | ||
| 89 | (vc-hg-command | ||
| 90 | buffer | ||
| 91 | (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0) | ||
| 92 | file "log")) | ||
| 93 | |||
| 94 | (defun vc-hg-internal-status(file) | ||
| 95 | "Return status of FILE" | ||
| 96 | (with-output-to-string | ||
| 97 | (with-current-buffer | ||
| 98 | standard-output | ||
| 99 | (call-process | ||
| 100 | "hg" nil t nil "--cwd" (file-name-directory file) | ||
| 101 | "status" (file-name-nondirectory file))))) | ||
| 102 | |||
| 103 | (defun vc-hg-diff (file &optional oldvers newvers buffers) | ||
| 104 | "Get a difference report using hg between two versions of FILE." | ||
| 105 | (when buffers (message buffers)) | ||
| 106 | (unless buffers (setq buffers "*vc-diff*")) | ||
| 107 | (when oldvers (message oldvers)) | ||
| 108 | (when newvers (message newvers)) | ||
| 109 | (call-process "hg" nil buffers nil | ||
| 110 | "--cwd" (file-name-directory file) | ||
| 111 | "diff" (file-name-nondirectory file))) | ||
| 112 | |||
| 113 | ;;; Internal functions | ||
| 114 | |||
| 115 | (defun vc-hg-command (buffer okstatus file &rest flags) | ||
| 116 | "A wrapper around `vc-do-command' for use in vc-hg.el. | ||
| 117 | The difference to vc-do-command is that this function always invokes `hg', | ||
| 118 | and that it passes `vc-hg-global-switches' to it before FLAGS." | ||
| 119 | (apply 'vc-do-command buffer okstatus "hg" file | ||
| 120 | (if (stringp vc-hg-global-switches) | ||
| 121 | (cons vc-hg-global-switches flags) | ||
| 122 | (append vc-hg-global-switches | ||
| 123 | flags)))) | ||
| 124 | |||
| 125 | (provide 'vc-hg) | ||
| 126 | |||