Mercurial > emacs
comparison lisp/vc-hg.el @ 87455:06f57a4af48c
(vc-hg-registered): Return the false when vc-hg-state
returns 'ignored or 'unregistered.
(vc-hg-state): Pass "-A" to the status command and deal with the
output.
(vc-hg-dir-state): Pass "-A" to the status command.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Fri, 28 Dec 2007 22:50:18 +0000 |
parents | 71fc7b1db920 |
children | dc4354c7a6c7 |
comparison
equal
deleted
inserted
replaced
87454:0cbc451989a7 | 87455:06f57a4af48c |
---|---|
145 | 145 |
146 ;; Modelled after the similar function in vc-bzr.el | 146 ;; Modelled after the similar function in vc-bzr.el |
147 (defun vc-hg-registered (file) | 147 (defun vc-hg-registered (file) |
148 "Return non-nil if FILE is registered with hg." | 148 "Return non-nil if FILE is registered with hg." |
149 (when (vc-hg-root file) ; short cut | 149 (when (vc-hg-root file) ; short cut |
150 (vc-file-setprop file 'vc-state (vc-hg-state file)))) ; expensive | 150 (let ((state (vc-hg-state file))) ; expensive |
151 (vc-file-setprop file 'vc-state state) | |
152 (not (memq state '(ignored unregistered)))))) | |
151 | 153 |
152 (defun vc-hg-state (file) | 154 (defun vc-hg-state (file) |
153 "Hg-specific version of `vc-state'." | 155 "Hg-specific version of `vc-state'." |
154 (let* | 156 (let* |
155 ((status nil) | 157 ((status nil) |
160 (setq status | 162 (setq status |
161 (condition-case nil | 163 (condition-case nil |
162 ;; Ignore all errors. | 164 ;; Ignore all errors. |
163 (call-process | 165 (call-process |
164 "hg" nil t nil "--cwd" (file-name-directory file) | 166 "hg" nil t nil "--cwd" (file-name-directory file) |
165 "status" (file-name-nondirectory file)) | 167 "status" "-A" (file-name-nondirectory file)) |
166 ;; Some problem happened. E.g. We can't find an `hg' | 168 ;; Some problem happened. E.g. We can't find an `hg' |
167 ;; executable. | 169 ;; executable. |
168 (error nil))))))) | 170 (error nil))))))) |
169 (when (eq 0 status) | 171 (when (eq 0 status) |
170 (if (eq 0 (length out)) 'up-to-date | |
171 (when (null (string-match ".*: No such file or directory$" out)) | 172 (when (null (string-match ".*: No such file or directory$" out)) |
172 (let ((state (aref out 0))) | 173 (let ((state (aref out 0))) |
173 (cond | 174 (cond |
175 ((eq state ?C) 'up-to-date) | |
174 ((eq state ?A) 'edited) | 176 ((eq state ?A) 'edited) |
175 ((eq state ?M) 'edited) | 177 ((eq state ?M) 'edited) |
176 ((eq state ?I) 'ignored) | 178 ((eq state ?I) 'ignored) |
177 ((eq state ?R) 'unregistered) | 179 ((eq state ?R) 'unregistered) |
178 ((eq state ??) 'unregistered) | 180 ((eq state ??) 'unregistered) |
179 (t 'up-to-date)))))))) | 181 (t 'up-to-date))))))) |
180 | 182 |
181 (defun vc-hg-dir-state (dir) | 183 (defun vc-hg-dir-state (dir) |
182 (with-temp-buffer | 184 (with-temp-buffer |
183 (buffer-disable-undo) ;; Because these buffers can get huge | 185 (buffer-disable-undo) ;; Because these buffers can get huge |
184 (vc-hg-command (current-buffer) nil nil "status") | 186 (vc-hg-command (current-buffer) nil nil "status" "-A") |
185 (goto-char (point-min)) | 187 (goto-char (point-min)) |
186 (let ((status-char nil) | 188 (let ((status-char nil) |
187 (file nil)) | 189 (file nil)) |
188 (while (not (eobp)) | 190 (while (not (eobp)) |
189 (setq status-char (char-after)) | 191 (setq status-char (char-after)) |