summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Nicolaescu <dann@ics.uci.edu>2007-07-21 17:51:13 +0000
committerDan Nicolaescu <dann@ics.uci.edu>2007-07-21 17:51:13 +0000
commit0c3b8cc477722c8eb6bc1b5e8de463ba1e0980aa (patch)
tree930450ca61073ecc7b5a483e2e8689710ab8fd4a
parent26716cc246dafe884123457cc1cd6bb17c39cf88 (diff)
downloademacs-0c3b8cc477722c8eb6bc1b5e8de463ba1e0980aa.tar.gz
(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 @@
+2007-07-21 Dan Nicolaescu <dann@ics.uci.edu>
+
+ * vc-hg.el (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.
+
2007-07-21 Thien-Thi Nguyen <ttn@gnuvola.org>
* 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 @@
;; - comment-history (file) NOT NEEDED
;; - update-changelog (files) NOT NEEDED
;; * diff (file &optional rev1 rev2 buffer) OK
-;; - revision-completion-table (file) ??
+;; - revision-completion-table (file) OK
;; - diff-tree (dir &optional rev1 rev2) TEST IT
;; - annotate-command (file buf &optional rev) OK
;; - annotate-time () OK
@@ -110,6 +110,7 @@
;;; Code:
(eval-when-compile
+ (require 'cl)
(require 'vc))
;;; Customization options
@@ -173,11 +174,12 @@
(goto-char (point-min))
(let ((status-char nil)
(file nil))
- (while (eq 0 (forward-line))
+ (while (not (eobp))
(setq status-char (char-after))
(setq file
(expand-file-name
- (buffer-substring-no-properties (+ (point) 2) (line-end-position))))
+ (buffer-substring-no-properties (+ (point) 2)
+ (line-end-position))))
(cond
;; The rest of the possible states in "hg status" output:
;; R = removed
@@ -192,7 +194,8 @@
(vc-file-setprop file 'vc-state 'edited))
((eq status-char ??)
(vc-file-setprop file 'vc-backend 'none)
- (vc-file-setprop file 'vc-state 'nil)))))))
+ (vc-file-setprop file 'vc-state 'nil)))
+ (forward-line)))))
(defun vc-hg-workfile-version (file)
"Hg-specific version of `vc-workfile-version'."
@@ -270,15 +273,31 @@
(setq oldvers nil))
(if (and (not oldvers) newvers)
(setq oldvers working))
- (apply 'call-process "hg" nil (or buffer "*vc-diff*") nil
- "--cwd" (file-name-directory file) "diff"
+ (apply #'vc-hg-command (or buffer "*vc-diff*") nil
+ (file-name-nondirectory file)
+ "--cwd" (file-name-directory file)
+ "diff"
(append
(if oldvers
(if newvers
(list "-r" oldvers "-r" newvers)
(list "-r" oldvers))
- (list ""))
- (list (file-name-nondirectory file))))))
+ (list ""))))))
+
+(defun vc-hg-revision-table (file)
+ (let ((default-directory (file-name-directory file)))
+ (with-temp-buffer
+ (vc-hg-command t nil file "log" "--template" "{rev} ")
+ (split-string
+ (buffer-substring-no-properties (point-min) (point-max))))))
+
+;; Modelled after the similar function in vc-cvs.el
+(defun vc-hg-revision-completion-table (file)
+ (lexical-let ((file file)
+ table)
+ (setq table (lazy-completion-table
+ table (lambda () (vc-hg-revision-table file))))
+ table))
(defalias 'vc-hg-diff-tree 'vc-hg-diff)
@@ -317,7 +336,7 @@ Optional arg VERSION is a version to annotate from."
(let ((newrev (1+ (string-to-number rev)))
(tip-version
(with-temp-buffer
- (vc-hg-command t nil nil "tip")
+ (vc-hg-command t 0 nil "tip")
(goto-char (point-min))
(re-search-forward "^changeset:[ \t]*\\([0-9]+\\):")
(string-to-number (match-string-no-properties 1)))))
@@ -332,18 +351,18 @@ Optional arg VERSION is a version to annotate from."
(condition-case ()
(delete-file file)
(file-error nil))
- (vc-hg-command nil nil file "remove" "--after" "--force"))
+ (vc-hg-command nil 0 file "remove" "--after" "--force"))
;; Modelled after the similar function in vc-bzr.el
(defun vc-hg-rename-file (old new)
"Rename file from OLD to NEW using `hg mv'."
- (vc-hg-command nil nil new old "mv"))
+ (vc-hg-command nil 0 new old "mv"))
(defun vc-hg-register (file &optional rev comment)
"Register FILE under hg.
REV is ignored.
COMMENT is ignored."
- (vc-hg-command nil nil file "add"))
+ (vc-hg-command nil 0 file "add"))
(defalias 'vc-hg-responsible-p 'vc-hg-root)
@@ -366,18 +385,16 @@ COMMENT is ignored."
(defun vc-hg-checkin (file rev comment)
"HG-specific version of `vc-backend-checkin'.
REV is ignored."
- (vc-hg-command nil nil file "commit" "-m" comment))
+ (vc-hg-command nil 0 files "commit" "-m" comment))
(defun vc-hg-find-version (file rev buffer)
(let ((coding-system-for-read 'binary)
(coding-system-for-write 'binary))
(if rev
- (vc-hg-command buffer nil file "cat" "-r" rev)
- (vc-hg-command buffer nil file "cat"))))
+ (vc-hg-command buffer 0 file "cat" "-r" rev)
+ (vc-hg-command buffer 0 file "cat"))))
;; Modelled after the similar function in vc-bzr.el
-;; This should not be needed, `vc-hg-find-version' provides the same
-;; functionality.
(defun vc-hg-checkout (file &optional editable rev)
"Retrieve a revision of FILE.
EDITABLE is ignored.
@@ -386,8 +403,8 @@ REV is the revision to check out into WORKFILE."
(coding-system-for-write 'binary))
(with-current-buffer (or (get-file-buffer file) (current-buffer))
(if rev
- (vc-hg-command t nil file "cat" "-r" rev)
- (vc-hg-command t nil file "cat")))))
+ (vc-hg-command t 0 file "cat" "-r" rev)
+ (vc-hg-command t 0 file "cat")))))
(defun vc-hg-checkout-model (file)
'implicit)
@@ -408,7 +425,7 @@ REV is the revision to check out into WORKFILE."
;; Modelled after the similar function in vc-bzr.el
(defun vc-hg-revert (file &optional contents-done)
(unless contents-done
- (with-temp-buffer (vc-hg-command t nil file "revert"))))
+ (with-temp-buffer (vc-hg-command t 0 file "revert"))))
;;; Internal functions