aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2007-07-16 03:58:54 +0000
committerDan Nicolaescu2007-07-16 03:58:54 +0000
commit908265fc31cd7ed89c0170ed7b427e549847ce75 (patch)
treed2b87d89ead4342d9560f4a653a7d30dd6616550
parentf6be091c471ba7a0c4b4f3e8ce851f96daae7bbe (diff)
downloademacs-908265fc31cd7ed89c0170ed7b427e549847ce75.tar.gz
emacs-908265fc31cd7ed89c0170ed7b427e549847ce75.zip
(vc-hg-state): Handle removed files.
(vc-hg-dir-state, vc-hg-dired-state-info): New functions. (vc-hg-checkout): Re-enable.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/vc-hg.el72
2 files changed, 57 insertions, 21 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1711a9862b4..1fc3057761c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12007-07-16 Dan Nicolaescu <dann@ics.uci.edu>
2
3 * vc-hg.el (vc-hg-state): Handle removed files.
4 (vc-hg-dir-state, vc-hg-dired-state-info): New functions.
5 (vc-hg-checkout): Re-enable.
6
12007-07-15 Richard Stallman <rms@gnu.org> 72007-07-15 Richard Stallman <rms@gnu.org>
2 8
3 * kmacro.el (kmacro-bind-to-key): Avoid comparisons on function keys. 9 * kmacro.el (kmacro-bind-to-key): Avoid comparisons on function keys.
diff --git a/lisp/vc-hg.el b/lisp/vc-hg.el
index 31391f2d2c8..70488009232 100644
--- a/lisp/vc-hg.el
+++ b/lisp/vc-hg.el
@@ -42,13 +42,13 @@
42;; * registered (file) OK 42;; * registered (file) OK
43;; * state (file) OK 43;; * state (file) OK
44;; - state-heuristic (file) ?? PROBABLY NOT NEEDED 44;; - state-heuristic (file) ?? PROBABLY NOT NEEDED
45;; - dir-state (dir) NEEDED 45;; - dir-state (dir) OK
46;; * workfile-version (file) OK 46;; * workfile-version (file) OK
47;; - latest-on-branch-p (file) ?? 47;; - latest-on-branch-p (file) ??
48;; * checkout-model (file) OK 48;; * checkout-model (file) OK
49;; - workfile-unchanged-p (file) ?? 49;; - workfile-unchanged-p (file) ??
50;; - mode-line-string (file) NOT NEEDED 50;; - mode-line-string (file) NOT NEEDED
51;; - dired-state-info (file) NEEDED 51;; - dired-state-info (file) OK
52;; STATE-CHANGING FUNCTIONS 52;; STATE-CHANGING FUNCTIONS
53;; * register (file &optional rev comment) OK 53;; * register (file &optional rev comment) OK
54;; - init-version () NOT NEEDED 54;; - init-version () NOT NEEDED
@@ -58,7 +58,7 @@
58;; - unregister (file) COMMENTED OUT, MAY BE INCORRECT 58;; - unregister (file) COMMENTED OUT, MAY BE INCORRECT
59;; * checkin (file rev comment) OK 59;; * checkin (file rev comment) OK
60;; * find-version (file rev buffer) OK 60;; * find-version (file rev buffer) OK
61;; * checkout (file &optional editable rev) NOT NEEDED, COMMENTED OUT 61;; * checkout (file &optional editable rev) OK
62;; * revert (file &optional contents-done) OK 62;; * revert (file &optional contents-done) OK
63;; - cancel-version (file editable) ?? PROBABLY NOT NEEDED 63;; - cancel-version (file editable) ?? PROBABLY NOT NEEDED
64;; - merge (file rev1 rev2) NEEDED 64;; - merge (file rev1 rev2) NEEDED
@@ -113,10 +113,6 @@
113(eval-when-compile 113(eval-when-compile
114 (require 'vc)) 114 (require 'vc))
115 115
116;; XXX This should be moved to vc-hooks after this gets a bit more
117;; testing in the trunk.
118(add-to-list 'vc-handled-backends 'HG)
119
120;;; Customization options 116;;; Customization options
121 117
122(defcustom vc-hg-global-switches nil 118(defcustom vc-hg-global-switches nil
@@ -165,12 +161,39 @@
165 (if (eq 0 (length out)) 'up-to-date 161 (if (eq 0 (length out)) 'up-to-date
166 (let ((state (aref out 0))) 162 (let ((state (aref out 0)))
167 (cond 163 (cond
168 ((eq state ?M) 'edited)
169 ((eq state ?A) 'edited) 164 ((eq state ?A) 'edited)
170 ((eq state ?P) 'needs-patch) 165 ((eq state ?M) 'edited)
166 ((eq state ?R) nil)
171 ((eq state ??) nil) 167 ((eq state ??) nil)
172 (t 'up-to-date))))))) 168 (t 'up-to-date)))))))
173 169
170(defun vc-hg-dir-state (dir)
171 (with-temp-buffer
172 (vc-hg-command (current-buffer) nil nil "status")
173 (goto-char (point-min))
174 (let ((status-char nil)
175 (file nil))
176 (while (eq 0 (forward-line))
177 (setq status-char (char-after))
178 (setq file
179 (expand-file-name
180 (buffer-substring-no-properties (+ (point) 2) (line-end-position))))
181 (cond
182 ;; The rest of the possible states in "hg status" output:
183 ;; R = removed
184 ;; ! = deleted, but still tracked
185 ;; ? = not tracked
186 ;; should not show up in vc-dired, so don't deal with them
187 ;; here.
188 ((eq status-char ?A)
189 (vc-file-setprop file 'vc-workfile-version "0")
190 (vc-file-setprop file 'vc-state 'edited))
191 ((eq status-char ?M)
192 (vc-file-setprop file 'vc-state 'edited))
193 ((eq status-char ??)
194 (vc-file-setprop file 'vc-backend 'none)
195 (vc-file-setprop file 'vc-state 'nil)))))))
196
174(defun vc-hg-workfile-version (file) 197(defun vc-hg-workfile-version (file)
175 "Hg-specific version of `vc-workfile-version'." 198 "Hg-specific version of `vc-workfile-version'."
176 (let* 199 (let*
@@ -355,22 +378,29 @@ REV is ignored."
355;; Modelled after the similar function in vc-bzr.el 378;; Modelled after the similar function in vc-bzr.el
356;; This should not be needed, `vc-hg-find-version' provides the same 379;; This should not be needed, `vc-hg-find-version' provides the same
357;; functionality. 380;; functionality.
358;; (defun vc-hg-checkout (file &optional editable rev workfile) 381(defun vc-hg-checkout (file &optional editable rev)
359;; "Retrieve a revision of FILE into a WORKFILE. 382 "Retrieve a revision of FILE.
360;; EDITABLE is ignored. 383EDITABLE is ignored.
361;; REV is the revision to check out into WORKFILE." 384REV is the revision to check out into WORKFILE."
362;; (unless workfile 385 (let ((coding-system-for-read 'binary)
363;; (setq workfile (vc-version-backup-file-name file rev))) 386 (coding-system-for-write 'binary))
364;; (let ((coding-system-for-read 'binary) 387 (with-current-buffer (or (get-file-buffer file) (current-buffer))
365;; (coding-system-for-write 'binary)) 388 (if rev
366;; (with-temp-file workfile 389 (vc-hg-command t nil file "cat" "-r" rev)
367;; (if rev 390 (vc-hg-command t nil file "cat")))))
368;; (vc-hg-command t nil file "cat" "-r" rev)
369;; (vc-hg-command t nil file "cat")))))
370 391
371(defun vc-hg-checkout-model (file) 392(defun vc-hg-checkout-model (file)
372 'implicit) 393 'implicit)
373 394
395(defun vc-hg-dired-state-info (file)
396 "Hg-specific version of `vc-dired-state-info'."
397 (let ((hg-state (vc-state file)))
398 (if (eq hg-state 'edited)
399 (if (equal (vc-workfile-version file) "0")
400 "(added)" "(modified)")
401 ;; fall back to the default VC representation
402 (vc-default-dired-state-info 'HG file))))
403
374;; Modelled after the similar function in vc-bzr.el 404;; Modelled after the similar function in vc-bzr.el
375(defun vc-hg-revert (file &optional contents-done) 405(defun vc-hg-revert (file &optional contents-done)
376 (unless contents-done 406 (unless contents-done