aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2007-07-21 17:51:13 +0000
committerDan Nicolaescu2007-07-21 17:51:13 +0000
commit0c3b8cc477722c8eb6bc1b5e8de463ba1e0980aa (patch)
tree930450ca61073ecc7b5a483e2e8689710ab8fd4a
parent26716cc246dafe884123457cc1cd6bb17c39cf88 (diff)
downloademacs-0c3b8cc477722c8eb6bc1b5e8de463ba1e0980aa.tar.gz
emacs-0c3b8cc477722c8eb6bc1b5e8de463ba1e0980aa.zip
(vc-hg-diff): Use vc-hg-command.
(vc-hg-dir-state): Fix loop. (vc-hg-print-log): Fix expected return value for vc-hg-command. (vc-hg-next-version, vc-hg-delete-file, vc-hg-rename-file) (vc-hg-register, vc-hg-create-repo, vc-hg-checkin) (vc-hg-revert): Likewise. (vc-hg-revision-table, vc-hg-revision-completion-table): New functions.
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/vc-hg.el57
2 files changed, 48 insertions, 20 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a37a2b0a658..36bfbcafa89 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
12007-07-21 Dan Nicolaescu <dann@ics.uci.edu>
2
3 * vc-hg.el (vc-hg-diff): Use vc-hg-command.
4 (vc-hg-dir-state): Fix loop.
5 (vc-hg-print-log): Fix expected return value for vc-hg-command.
6 (vc-hg-next-version, vc-hg-delete-file, vc-hg-rename-file)
7 (vc-hg-register, vc-hg-create-repo, vc-hg-checkin)
8 (vc-hg-revert): Likewise.
9 (vc-hg-revision-table, vc-hg-revision-completion-table): New
10 functions.
11
12007-07-21 Thien-Thi Nguyen <ttn@gnuvola.org> 122007-07-21 Thien-Thi Nguyen <ttn@gnuvola.org>
2 13
3 * emacs-lisp/lisp-mode.el (calculate-lisp-indent): In the 14 * emacs-lisp/lisp-mode.el (calculate-lisp-indent): In the
diff --git a/lisp/vc-hg.el b/lisp/vc-hg.el
index 946a47e8f72..7fd8d5f532b 100644
--- a/lisp/vc-hg.el
+++ b/lisp/vc-hg.el
@@ -72,7 +72,7 @@
72;; - comment-history (file) NOT NEEDED 72;; - comment-history (file) NOT NEEDED
73;; - update-changelog (files) NOT NEEDED 73;; - update-changelog (files) NOT NEEDED
74;; * diff (file &optional rev1 rev2 buffer) OK 74;; * diff (file &optional rev1 rev2 buffer) OK
75;; - revision-completion-table (file) ?? 75;; - revision-completion-table (file) OK
76;; - diff-tree (dir &optional rev1 rev2) TEST IT 76;; - diff-tree (dir &optional rev1 rev2) TEST IT
77;; - annotate-command (file buf &optional rev) OK 77;; - annotate-command (file buf &optional rev) OK
78;; - annotate-time () OK 78;; - annotate-time () OK
@@ -110,6 +110,7 @@
110;;; Code: 110;;; Code:
111 111
112(eval-when-compile 112(eval-when-compile
113 (require 'cl)
113 (require 'vc)) 114 (require 'vc))
114 115
115;;; Customization options 116;;; Customization options
@@ -173,11 +174,12 @@
173 (goto-char (point-min)) 174 (goto-char (point-min))
174 (let ((status-char nil) 175 (let ((status-char nil)
175 (file nil)) 176 (file nil))
176 (while (eq 0 (forward-line)) 177 (while (not (eobp))
177 (setq status-char (char-after)) 178 (setq status-char (char-after))
178 (setq file 179 (setq file
179 (expand-file-name 180 (expand-file-name
180 (buffer-substring-no-properties (+ (point) 2) (line-end-position)))) 181 (buffer-substring-no-properties (+ (point) 2)
182 (line-end-position))))
181 (cond 183 (cond
182 ;; The rest of the possible states in "hg status" output: 184 ;; The rest of the possible states in "hg status" output:
183 ;; R = removed 185 ;; R = removed
@@ -192,7 +194,8 @@
192 (vc-file-setprop file 'vc-state 'edited)) 194 (vc-file-setprop file 'vc-state 'edited))
193 ((eq status-char ??) 195 ((eq status-char ??)
194 (vc-file-setprop file 'vc-backend 'none) 196 (vc-file-setprop file 'vc-backend 'none)
195 (vc-file-setprop file 'vc-state 'nil))))))) 197 (vc-file-setprop file 'vc-state 'nil)))
198 (forward-line)))))
196 199
197(defun vc-hg-workfile-version (file) 200(defun vc-hg-workfile-version (file)
198 "Hg-specific version of `vc-workfile-version'." 201 "Hg-specific version of `vc-workfile-version'."
@@ -270,15 +273,31 @@
270 (setq oldvers nil)) 273 (setq oldvers nil))
271 (if (and (not oldvers) newvers) 274 (if (and (not oldvers) newvers)
272 (setq oldvers working)) 275 (setq oldvers working))
273 (apply 'call-process "hg" nil (or buffer "*vc-diff*") nil 276 (apply #'vc-hg-command (or buffer "*vc-diff*") nil
274 "--cwd" (file-name-directory file) "diff" 277 (file-name-nondirectory file)
278 "--cwd" (file-name-directory file)
279 "diff"
275 (append 280 (append
276 (if oldvers 281 (if oldvers
277 (if newvers 282 (if newvers
278 (list "-r" oldvers "-r" newvers) 283 (list "-r" oldvers "-r" newvers)
279 (list "-r" oldvers)) 284 (list "-r" oldvers))
280 (list "")) 285 (list ""))))))
281 (list (file-name-nondirectory file)))))) 286
287(defun vc-hg-revision-table (file)
288 (let ((default-directory (file-name-directory file)))
289 (with-temp-buffer
290 (vc-hg-command t nil file "log" "--template" "{rev} ")
291 (split-string
292 (buffer-substring-no-properties (point-min) (point-max))))))
293
294;; Modelled after the similar function in vc-cvs.el
295(defun vc-hg-revision-completion-table (file)
296 (lexical-let ((file file)
297 table)
298 (setq table (lazy-completion-table
299 table (lambda () (vc-hg-revision-table file))))
300 table))
282 301
283(defalias 'vc-hg-diff-tree 'vc-hg-diff) 302(defalias 'vc-hg-diff-tree 'vc-hg-diff)
284 303
@@ -317,7 +336,7 @@ Optional arg VERSION is a version to annotate from."
317 (let ((newrev (1+ (string-to-number rev))) 336 (let ((newrev (1+ (string-to-number rev)))
318 (tip-version 337 (tip-version
319 (with-temp-buffer 338 (with-temp-buffer
320 (vc-hg-command t nil nil "tip") 339 (vc-hg-command t 0 nil "tip")
321 (goto-char (point-min)) 340 (goto-char (point-min))
322 (re-search-forward "^changeset:[ \t]*\\([0-9]+\\):") 341 (re-search-forward "^changeset:[ \t]*\\([0-9]+\\):")
323 (string-to-number (match-string-no-properties 1))))) 342 (string-to-number (match-string-no-properties 1)))))
@@ -332,18 +351,18 @@ Optional arg VERSION is a version to annotate from."
332 (condition-case () 351 (condition-case ()
333 (delete-file file) 352 (delete-file file)
334 (file-error nil)) 353 (file-error nil))
335 (vc-hg-command nil nil file "remove" "--after" "--force")) 354 (vc-hg-command nil 0 file "remove" "--after" "--force"))
336 355
337;; Modelled after the similar function in vc-bzr.el 356;; Modelled after the similar function in vc-bzr.el
338(defun vc-hg-rename-file (old new) 357(defun vc-hg-rename-file (old new)
339 "Rename file from OLD to NEW using `hg mv'." 358 "Rename file from OLD to NEW using `hg mv'."
340 (vc-hg-command nil nil new old "mv")) 359 (vc-hg-command nil 0 new old "mv"))
341 360
342(defun vc-hg-register (file &optional rev comment) 361(defun vc-hg-register (file &optional rev comment)
343 "Register FILE under hg. 362 "Register FILE under hg.
344REV is ignored. 363REV is ignored.
345COMMENT is ignored." 364COMMENT is ignored."
346 (vc-hg-command nil nil file "add")) 365 (vc-hg-command nil 0 file "add"))
347 366
348(defalias 'vc-hg-responsible-p 'vc-hg-root) 367(defalias 'vc-hg-responsible-p 'vc-hg-root)
349 368
@@ -366,18 +385,16 @@ COMMENT is ignored."
366(defun vc-hg-checkin (file rev comment) 385(defun vc-hg-checkin (file rev comment)
367 "HG-specific version of `vc-backend-checkin'. 386 "HG-specific version of `vc-backend-checkin'.
368REV is ignored." 387REV is ignored."
369 (vc-hg-command nil nil file "commit" "-m" comment)) 388 (vc-hg-command nil 0 files "commit" "-m" comment))
370 389
371(defun vc-hg-find-version (file rev buffer) 390(defun vc-hg-find-version (file rev buffer)
372 (let ((coding-system-for-read 'binary) 391 (let ((coding-system-for-read 'binary)
373 (coding-system-for-write 'binary)) 392 (coding-system-for-write 'binary))
374 (if rev 393 (if rev
375 (vc-hg-command buffer nil file "cat" "-r" rev) 394 (vc-hg-command buffer 0 file "cat" "-r" rev)
376 (vc-hg-command buffer nil file "cat")))) 395 (vc-hg-command buffer 0 file "cat"))))
377 396
378;; Modelled after the similar function in vc-bzr.el 397;; Modelled after the similar function in vc-bzr.el
379;; This should not be needed, `vc-hg-find-version' provides the same
380;; functionality.
381(defun vc-hg-checkout (file &optional editable rev) 398(defun vc-hg-checkout (file &optional editable rev)
382 "Retrieve a revision of FILE. 399 "Retrieve a revision of FILE.
383EDITABLE is ignored. 400EDITABLE is ignored.
@@ -386,8 +403,8 @@ REV is the revision to check out into WORKFILE."
386 (coding-system-for-write 'binary)) 403 (coding-system-for-write 'binary))
387 (with-current-buffer (or (get-file-buffer file) (current-buffer)) 404 (with-current-buffer (or (get-file-buffer file) (current-buffer))
388 (if rev 405 (if rev
389 (vc-hg-command t nil file "cat" "-r" rev) 406 (vc-hg-command t 0 file "cat" "-r" rev)
390 (vc-hg-command t nil file "cat"))))) 407 (vc-hg-command t 0 file "cat")))))
391 408
392(defun vc-hg-checkout-model (file) 409(defun vc-hg-checkout-model (file)
393 'implicit) 410 'implicit)
@@ -408,7 +425,7 @@ REV is the revision to check out into WORKFILE."
408;; Modelled after the similar function in vc-bzr.el 425;; Modelled after the similar function in vc-bzr.el
409(defun vc-hg-revert (file &optional contents-done) 426(defun vc-hg-revert (file &optional contents-done)
410 (unless contents-done 427 (unless contents-done
411 (with-temp-buffer (vc-hg-command t nil file "revert")))) 428 (with-temp-buffer (vc-hg-command t 0 file "revert"))))
412 429
413;;; Internal functions 430;;; Internal functions
414 431