Mercurial > emacs
annotate lisp/vc-hg.el @ 81564:99961edaa9c1
(vc-hg-print-log): Insert the file name.
(vc-hg-log-view-mode): Fontify the file name.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Fri, 22 Jun 2007 17:22:17 +0000 |
parents | ac8e3d72984f |
children | 0e2a83705e5f |
rev | line source |
---|---|
81474 | 1 ;;; vc-hg.el --- VC backend for the mercurial version control system |
2 | |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
3 ;; Copyright (C) 2006, 2007 Free Software Foundation, Inc. |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
4 |
81474 | 5 ;; Author: Ivan Kanis |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
6 ;; Keywords: tools |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
7 ;; Version: 1889 |
81479
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
8 |
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
10 |
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
81474 | 12 ;; it under the terms of the GNU General Public License as published by |
81479
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
14 ;; any later version. |
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
15 |
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
19 ;; GNU General Public License for more details. |
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
20 |
81474 | 21 ;; You should have received a copy of the GNU General Public License |
81479
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
24 ;; Boston, MA 02110-1301, USA. |
81474 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; This is a mercurial version control backend | |
29 | |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
30 ;;; Thanks: |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
31 |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
32 ;;; Bugs: |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
33 |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
34 ;;; Installation: |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
35 |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
36 ;;; Todo: |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
37 |
81526 | 38 ;; Implement the rest of the vc interface: |
39 ;; - dired | |
40 ;; - snapshot? | |
81474 | 41 |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
42 ;; Implement Stefan Monnier's advice: |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
43 ;; vc-hg-registered and vc-hg-state |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
44 ;; Both of those functions should be super extra careful to fail gracefully in |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
45 ;; unexpected circumstances. The most important such case is when the `hg' |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
46 ;; executable is not available. The reason this is important is that any error |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
47 ;; there will prevent the user from even looking at the file :-( |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
48 ;; Ideally, just like in vc-arch and vc-cvs, checking that the file is under |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
49 ;; mercurial's control and extracting the current revision should be done |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
50 ;; without even using `hg' (this way even if you don't have `hg' installed, |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
51 ;; Emacs is able to tell you this file is under mercurial's control). |
81474 | 52 |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
53 ;;; History: |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
54 ;; |
81474 | 55 |
56 ;;; Code: | |
57 | |
58 (eval-when-compile | |
59 (require 'vc)) | |
60 | |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
61 ;; XXX This should be moved to vc-hooks when the full vc interface is |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
62 ;; implemented. |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
63 (add-to-list 'vc-handled-backends 'HG) |
81474 | 64 |
65 ;;; Customization options | |
66 | |
67 (defcustom vc-hg-global-switches nil | |
68 "*Global switches to pass to any Hg command." | |
69 :type '(choice (const :tag "None" nil) | |
70 (string :tag "Argument String") | |
71 (repeat :tag "Argument List" | |
72 :value ("") | |
73 string)) | |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
74 ;; :version "22.2" |
81474 | 75 :group 'vc) |
76 | |
77 ;;; State querying functions | |
78 | |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
79 ;;; Modelled after the similar function in vc-bzr.el |
81474 | 80 (defun vc-hg-registered (file) |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
81 "Return non-nil if FILE is registered with hg." |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
82 (if (vc-find-root file ".hg") ; short cut |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
83 (vc-hg-state file))) ; expensive |
81474 | 84 |
85 (defun vc-hg-state (file) | |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
86 "Hg-specific version of `vc-state'." |
81474 | 87 (let ((out (vc-hg-internal-status file))) |
88 (if (eq 0 (length out)) 'up-to-date | |
89 (let ((state (aref out 0))) | |
90 (cond | |
91 ((eq state ?M) 'edited) | |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
92 ((eq state ?A) 'edited) |
81474 | 93 ((eq state ?P) 'needs-patch) |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
94 ((eq state ??) nil) |
81474 | 95 (t 'up-to-date)))))) |
96 | |
97 (defun vc-hg-workfile-version (file) | |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
98 "Hg-specific version of `vc-workfile-version'." |
81474 | 99 (let ((out (vc-hg-internal-log file))) |
100 (if (string-match "changeset: *\\([0-9]*\\)" out) | |
101 (match-string 1 out) | |
102 "0"))) | |
103 | |
104 ;;; History functions | |
105 | |
106 (defun vc-hg-print-log(file &optional buffer) | |
107 "Get change log associated with FILE." | |
81564
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
108 ;; `log-view-mode' needs to have the file name in order to function |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
109 ;; correctly. "hg log" does not print it, so we insert it here by |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
110 ;; hand. |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
111 |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
112 ;; `vc-do-command' creates the buffer, but we need it before running |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
113 ;; the command. |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
114 (vc-setup-buffer buffer) |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
115 ;; If the buffer exists from a previous invocation it might be |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
116 ;; read-only. |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
117 (let ((inhibit-read-only t)) |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
118 (with-current-buffer |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
119 buffer |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
120 (insert "File: " (file-name-nondirectory file) "\n"))) |
81474 | 121 (vc-hg-command |
122 buffer | |
123 (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0) | |
124 file "log")) | |
125 | |
81538
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
126 (defvar log-view-message-re) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
127 (defvar log-view-file-re) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
128 (defvar log-view-font-lock-keywords) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
129 (defvar log-view-current-tag-function) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
130 |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
131 (define-derived-mode vc-hg-log-view-mode log-view-mode "HG-Log-View" |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
132 (require 'add-log) ;; we need the faces add-log |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
133 ;; Don't have file markers, so use impossible regexp. |
81564
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
134 (set (make-local-variable 'log-view-file-re) "^File:[ \t]+\\(.+\\)") |
81538
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
135 (set (make-local-variable 'log-view-message-re) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
136 "^changeset:[ \t]*\\([0-9]+\\):\\(.+\\)") |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
137 (set (make-local-variable 'log-view-font-lock-keywords) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
138 (append |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
139 ;; XXX maybe use a different face for the version number |
81564
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
140 `((,log-view-message-re (1 'change-log-acknowledgement)) |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
141 (,log-view-file-re (1 'change-log-file-face))) |
81538
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
142 ;; Handle the case: |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
143 ;; user: foo@bar |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
144 '(("^user:[ \t]+\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)" |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
145 (1 'change-log-email)) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
146 ;; Handle the case: |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
147 ;; user: FirstName LastName <foo@bar> |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
148 ("^user:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]" |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
149 (1 'change-log-name) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
150 (2 'change-log-email)) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
151 ("^date: \\(.+\\)" (1 'change-log-date)) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
152 ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
153 |
81526 | 154 (defun vc-hg-diff (file &optional oldvers newvers buffer) |
81474 | 155 "Get a difference report using hg between two versions of FILE." |
81526 | 156 (let ((working (vc-workfile-version file))) |
157 (if (and (equal oldvers working) (not newvers)) | |
158 (setq oldvers nil)) | |
159 (if (and (not oldvers) newvers) | |
160 (setq oldvers working)) | |
161 (apply 'call-process "hg" nil (or buffer "*vc-diff*") nil | |
162 "--cwd" (file-name-directory file) "diff" | |
163 (append | |
164 (if oldvers | |
165 (if newvers | |
166 (list "-r" oldvers "-r" newvers) | |
167 (list "-r" oldvers)) | |
168 (list "")) | |
169 (list (file-name-nondirectory file)))))) | |
170 | |
171 (defun vc-hg-annotate-command (file buffer &optional version) | |
172 "Execute \"hg annotate\" on FILE, inserting the contents in BUFFER. | |
173 Optional arg VERSION is a version to annotate from." | |
174 (vc-hg-command buffer 0 file "annotate" "-d" "-n" (if version (concat "-r" version))) | |
175 (with-current-buffer buffer | |
176 (goto-char (point-min)) | |
177 (re-search-forward "^[0-9]") | |
178 (delete-region (point-min) (1- (point))))) | |
179 | |
180 | |
181 ;;; The format for one line output by "hg annotate -d -n" looks like this: | |
182 ;;;215 Wed Jun 20 21:22:58 2007 -0700: CONTENTS | |
183 ;;; i.e: VERSION_NUMBER DATE: CONTENTS | |
184 (defconst vc-hg-annotate-re "^[ \t]*\\([0-9]+\\) \\(.\\{30\\}\\): ") | |
185 | |
186 (defun vc-hg-annotate-time () | |
187 (when (looking-at vc-hg-annotate-re) | |
188 (goto-char (match-end 0)) | |
189 (vc-annotate-convert-time | |
190 (date-to-time (match-string-no-properties 2))))) | |
191 | |
192 (defun vc-hg-annotate-extract-revision-at-line () | |
193 (save-excursion | |
194 (beginning-of-line) | |
195 (if (looking-at vc-hg-annotate-re) (match-string-no-properties 1)))) | |
196 | |
197 (defun vc-hg-previous-version (file rev) | |
198 (let ((newrev (1- (string-to-number rev)))) | |
199 (when (>= newrev 0) | |
200 (number-to-string newrev)))) | |
81474 | 201 |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
202 (defun vc-hg-register (file &optional rev comment) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
203 "Register FILE under hg. |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
204 REV is ignored. |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
205 COMMENT is ignored." |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
206 (vc-hg-command nil nil file "add")) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
207 |
81526 | 208 (defun vc-hg-checkin (file rev comment) |
209 "HG-specific version of `vc-backend-checkin'. | |
210 REV is ignored." | |
211 (vc-hg-command nil nil file "commit" "-m" comment)) | |
212 | |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
213 ;;; Modelled after the similar function in vc-bzr.el |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
214 (defun vc-hg-checkout (file &optional editable rev workfile) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
215 "Retrieve a revision of FILE into a WORKFILE. |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
216 EDITABLE is ignored. |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
217 REV is the revision to check out into WORKFILE." |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
218 (unless workfile |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
219 (setq workfile (vc-version-backup-file-name file rev))) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
220 (let ((coding-system-for-read 'binary) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
221 (coding-system-for-write 'binary)) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
222 (with-temp-file workfile |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
223 (if rev |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
224 (vc-hg-command t nil file "cat" "-r" rev) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
225 (vc-hg-command t nil file "cat"))))) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
226 |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
227 (defun vc-hg-checkout-model (file) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
228 'implicit) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
229 |
81474 | 230 ;;; Internal functions |
231 | |
232 (defun vc-hg-command (buffer okstatus file &rest flags) | |
233 "A wrapper around `vc-do-command' for use in vc-hg.el. | |
234 The difference to vc-do-command is that this function always invokes `hg', | |
235 and that it passes `vc-hg-global-switches' to it before FLAGS." | |
236 (apply 'vc-do-command buffer okstatus "hg" file | |
237 (if (stringp vc-hg-global-switches) | |
238 (cons vc-hg-global-switches flags) | |
239 (append vc-hg-global-switches | |
240 flags)))) | |
241 | |
81564
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
242 (defun vc-hg-internal-log (file &optional buffer) |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
243 "Return log of FILE." |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
244 (with-output-to-string |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
245 (with-current-buffer |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
246 standard-output |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
247 (call-process |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
248 "hg" nil t nil "--cwd" (file-name-directory file) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
249 "log" "-l1" (file-name-nondirectory file))))) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
250 |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
251 (defun vc-hg-internal-status(file) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
252 "Return status of FILE." |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
253 (with-output-to-string |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
254 (with-current-buffer |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
255 standard-output |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
256 (call-process |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
257 "hg" nil t nil "--cwd" (file-name-directory file) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
258 "status" (file-name-nondirectory file))))) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
259 |
81474 | 260 (provide 'vc-hg) |
261 | |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
262 ;;; vc-hg.el ends here |