comparison lisp/vc-mcvs.el @ 50901:d3bb1d77a4b1

(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version) (vc-mcvs-checkout, vc-mcvs-diff, vc-mcvs-diff-tree): Use vc-switches.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 08 May 2003 19:01:04 +0000
parents 6b9cefee3eee
children 15bfd674106a
comparison
equal deleted inserted replaced
50900:d853a98e1678 50901:d3bb1d77a4b1
268 (pp types (current-buffer)) 268 (pp types (current-buffer))
269 (save-buffer) 269 (save-buffer)
270 (unless (get-buffer-window (current-buffer) t) 270 (unless (get-buffer-window (current-buffer) t)
271 (kill-buffer (current-buffer))))))) 271 (kill-buffer (current-buffer)))))))
272 ;; Now do the ADD. 272 ;; Now do the ADD.
273 (let ((switches (append 273 (prog1 (apply 'vc-mcvs-command nil 0 file
274 (if (stringp vc-register-switches) 274 "add"
275 (list vc-register-switches) 275 (and comment (string-match "[^\t\n ]" comment)
276 vc-register-switches) 276 (concat "-m" comment))
277 (if (stringp vc-mcvs-register-switches) 277 (vc-switches 'MCVS 'register))
278 (list vc-mcvs-register-switches) 278 ;; I'm not sure exactly why, but if we don't setup the inode and root
279 vc-mcvs-register-switches)))) 279 ;; prop of the file, things break later on in vc-mode-line that
280 (prog1 (apply 'vc-mcvs-command nil 0 file 280 ;; ends up calling vc-mcvs-workfile-version.
281 "add" 281 ;; We also need to set vc-checkout-time so that vc-workfile-unchanged-p
282 (and comment (string-match "[^\t\n ]" comment) 282 ;; doesn't try to call `mcvs diff' on the file.
283 (concat "-m" comment)) 283 (vc-mcvs-registered file)))
284 switches)
285 ;; I'm not sure exactly why, but if we don't setup the inode and root
286 ;; prop of the file, things break later on in vc-mode-line that
287 ;; ends up calling vc-mcvs-workfile-version.
288 ;; We also need to set vc-checkout-time so that vc-workfile-unchanged-p
289 ;; doesn't try to call `mcvs diff' on the file.
290 (vc-mcvs-registered file))))
291 284
292 (defalias 'vc-mcvs-responsible-p 'vc-mcvs-root 285 (defalias 'vc-mcvs-responsible-p 'vc-mcvs-root
293 "Return non-nil if CVS thinks it is responsible for FILE.") 286 "Return non-nil if CVS thinks it is responsible for FILE.")
294 287
295 (defalias 'vc-cvs-could-register 'vc-cvs-responsible-p 288 (defalias 'vc-cvs-could-register 'vc-cvs-responsible-p
296 "Return non-nil if FILE could be registered in Meta-CVS. 289 "Return non-nil if FILE could be registered in Meta-CVS.
297 This is only possible if Meta-CVS is responsible for FILE's directory.") 290 This is only possible if Meta-CVS is responsible for FILE's directory.")
298 291
299 (defun vc-mcvs-checkin (file rev comment) 292 (defun vc-mcvs-checkin (file rev comment)
300 "Meta-CVS-specific version of `vc-backend-checkin'." 293 "Meta-CVS-specific version of `vc-backend-checkin'."
301 (let ((switches (if (stringp vc-checkin-switches) 294 (unless (or (not rev) (vc-mcvs-valid-version-number-p rev))
302 (list vc-checkin-switches) 295 (if (not (vc-mcvs-valid-symbolic-tag-name-p rev))
303 vc-checkin-switches)) 296 (error "%s is not a valid symbolic tag name" rev)
304 status) 297 ;; If the input revison is a valid symbolic tag name, we create it
305 (if (or (not rev) (vc-mcvs-valid-version-number-p rev)) 298 ;; as a branch, commit and switch to it.
306 (setq status (apply 'vc-mcvs-command nil 1 file 299 (apply 'vc-mcvs-command nil 0 file "tag" "-b" (list rev))
307 "ci" (if rev (concat "-r" rev)) 300 (apply 'vc-mcvs-command nil 0 file "update" "-r" (list rev))
308 "-m" comment 301 (vc-file-setprop file 'vc-mcvs-sticky-tag rev)
309 switches)) 302 (setq rev nil)))
310 (if (not (vc-mcvs-valid-symbolic-tag-name-p rev)) 303 (let ((status (apply 'vc-mcvs-command nil 1 file
311 (error "%s is not a valid symbolic tag name" rev) 304 "ci" (if rev (concat "-r" rev))
312 ;; If the input revison is a valid symbolic tag name, we create it 305 "-m" comment
313 ;; as a branch, commit and switch to it. 306 (vc-switches 'MCVS 'checkin))))
314 (apply 'vc-mcvs-command nil 0 file "tag" "-b" (list rev))
315 (apply 'vc-mcvs-command nil 0 file "update" "-r" (list rev))
316 (setq status (apply 'vc-mcvs-command nil 1 file
317 "ci"
318 "-m" comment
319 switches))
320 (vc-file-setprop file 'vc-mcvs-sticky-tag rev)))
321 (set-buffer "*vc*") 307 (set-buffer "*vc*")
322 (goto-char (point-min)) 308 (goto-char (point-min))
323 (when (not (zerop status)) 309 (when (not (zerop status))
324 ;; Check checkin problem. 310 ;; Check checkin problem.
325 (cond 311 (cond
354 "-Q" ; suppress diagnostic output 340 "-Q" ; suppress diagnostic output
355 "update" 341 "update"
356 (and rev (not (string= rev "")) 342 (and rev (not (string= rev ""))
357 (concat "-r" rev)) 343 (concat "-r" rev))
358 "-p" 344 "-p"
359 (if (stringp vc-checkout-switches) 345 (vc-switches 'MCVS 'checkout)))
360 (list vc-checkout-switches)
361 vc-checkout-switches)))
362 346
363 (defun vc-mcvs-checkout (file &optional editable rev) 347 (defun vc-mcvs-checkout (file &optional editable rev)
364 (message "Checking out %s..." file) 348 (message "Checking out %s..." file)
365 (with-current-buffer (or (get-file-buffer file) (current-buffer)) 349 (with-current-buffer (or (get-file-buffer file) (current-buffer))
366 (let ((switches (if (stringp vc-checkout-switches) 350 (vc-call update file editable rev (vc-switches 'MCVS 'checkout)))
367 (list vc-checkout-switches)
368 vc-checkout-switches)))
369 (vc-call update file editable rev switches)))
370 (vc-mode-line file) 351 (vc-mode-line file)
371 (message "Checking out %s...done" file)) 352 (message "Checking out %s...done" file))
372 353
373 (defun vc-mcvs-update (file editable rev switches) 354 (defun vc-mcvs-update (file editable rev switches)
374 (if (and (file-exists-p file) (not rev)) 355 (if (and (file-exists-p file) (not rev))
474 (if (and (vc-mcvs-stay-local-p file) (fboundp 'start-process)) 'async 0) 455 (if (and (vc-mcvs-stay-local-p file) (fboundp 'start-process)) 'async 0)
475 file "log")) 456 file "log"))
476 457
477 (defun vc-mcvs-diff (file &optional oldvers newvers) 458 (defun vc-mcvs-diff (file &optional oldvers newvers)
478 "Get a difference report using Meta-CVS between two versions of FILE." 459 "Get a difference report using Meta-CVS between two versions of FILE."
479 (let (status (diff-switches-list (vc-diff-switches-list 'MCVS))) 460 (if (string= (vc-workfile-version file) "0")
480 (if (string= (vc-workfile-version file) "0") 461 ;; This file is added but not yet committed; there is no master file.
481 ;; This file is added but not yet committed; there is no master file. 462 (if (or oldvers newvers)
482 (if (or oldvers newvers) 463 (error "No revisions of %s exist" file)
483 (error "No revisions of %s exist" file) 464 ;; We regard this as "changed".
484 ;; We regard this as "changed". 465 ;; Diff it against /dev/null.
485 ;; Diff it against /dev/null. 466 ;; Note: this is NOT a "mcvs diff".
486 ;; Note: this is NOT a "mcvs diff". 467 (apply 'vc-do-command "*vc-diff*"
487 (apply 'vc-do-command "*vc-diff*" 468 1 "diff" file
488 1 "diff" file 469 (append (vc-switches nil 'diff) '("/dev/null")))
489 (append diff-switches-list '("/dev/null"))) 470 ;; Even if it's empty, it's locally modified.
490 ;; Even if it's empty, it's locally modified. 471 1)
491 1) 472 (let* ((async (and (vc-mcvs-stay-local-p file) (fboundp 'start-process)))
492 (setq status 473 (status
493 (apply 'vc-mcvs-command "*vc-diff*" 474 (apply 'vc-mcvs-command "*vc-diff*"
494 (if (and (vc-mcvs-stay-local-p file) 475 (if async 'async 1)
495 (fboundp 'start-process)) 476 file "diff"
496 'async 477 (and oldvers (concat "-r" oldvers))
497 1) 478 (and newvers (concat "-r" newvers))
498 file "diff" 479 (vc-switches 'MCVS 'diff))))
499 (and oldvers (concat "-r" oldvers)) 480 (if async 1 status)))) ; async diff, pessimistic assumption.
500 (and newvers (concat "-r" newvers))
501 diff-switches-list))
502 (if (vc-mcvs-stay-local-p file)
503 1 ;; async diff, pessimistic assumption
504 status))))
505 481
506 (defun vc-mcvs-diff-tree (dir &optional rev1 rev2) 482 (defun vc-mcvs-diff-tree (dir &optional rev1 rev2)
507 "Diff all files at and below DIR." 483 "Diff all files at and below DIR."
508 (with-current-buffer "*vc-diff*" 484 (with-current-buffer "*vc-diff*"
509 (setq default-directory dir) 485 (setq default-directory dir)
523 (let ((coding-system-for-read 499 (let ((coding-system-for-read
524 (or coding-system-for-read 'undecided))) 500 (or coding-system-for-read 'undecided)))
525 (apply 'vc-mcvs-command "*vc-diff*" 1 nil "diff" 501 (apply 'vc-mcvs-command "*vc-diff*" 1 nil "diff"
526 (and rev1 (concat "-r" rev1)) 502 (and rev1 (concat "-r" rev1))
527 (and rev2 (concat "-r" rev2)) 503 (and rev2 (concat "-r" rev2))
528 (vc-diff-switches-list 'MCVS)))))) 504 (vc-switches 'MCVS 'diff))))))
529 505
530 (defun vc-mcvs-annotate-command (file buffer &optional version) 506 (defun vc-mcvs-annotate-command (file buffer &optional version)
531 "Execute \"mcvs annotate\" on FILE, inserting the contents in BUFFER. 507 "Execute \"mcvs annotate\" on FILE, inserting the contents in BUFFER.
532 Optional arg VERSION is a version to annotate from." 508 Optional arg VERSION is a version to annotate from."
533 (vc-mcvs-command 509 (vc-mcvs-command