comparison lisp/vc-rcs.el @ 47797:d0555af982c8

(vc-rcs-find-version): New fun. (vc-rcs-checkout): Remove `workfile' arg and simplify.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 08 Oct 2002 15:33:18 +0000
parents 93af750650be
children 81b51b0d6e66
comparison
equal deleted inserted replaced
47796:cf312195338d 47797:d0555af982c8
3 ;; Copyright (C) 1992,93,94,95,96,97,98,99,2000,2001 Free Software Foundation, Inc. 3 ;; Copyright (C) 1992,93,94,95,96,97,98,99,2000,2001 Free Software Foundation, Inc.
4 4
5 ;; Author: FSF (see vc.el for full credits) 5 ;; Author: FSF (see vc.el for full credits)
6 ;; Maintainer: Andre Spiegel <spiegel@gnu.org> 6 ;; Maintainer: Andre Spiegel <spiegel@gnu.org>
7 7
8 ;; $Id: vc-rcs.el,v 1.26 2002/09/04 20:49:35 spiegel Exp $ 8 ;; $Id: vc-rcs.el,v 1.27 2002/10/04 18:38:04 monnier Exp $
9 9
10 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
11 11
12 ;; GNU Emacs is free software; you can redistribute it and/or modify 12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by 13 ;; it under the terms of the GNU General Public License as published by
353 ;; exit status of 1 is also accepted. 353 ;; exit status of 1 is also accepted.
354 ;; It means that the lock was removed before. 354 ;; It means that the lock was removed before.
355 (vc-do-command nil 1 "rcs" (vc-name file) 355 (vc-do-command nil 1 "rcs" (vc-name file)
356 (concat "-u" old-version)))))))) 356 (concat "-u" old-version))))))))
357 357
358 (defun vc-rcs-checkout (file &optional editable rev workfile) 358 (defun vc-rcs-find-version (file rev buffer)
359 "Retrieve a copy of a saved version of FILE into a workfile." 359 (apply 'vc-do-command
360 (let ((filename (or workfile file)) 360 buffer 0 "co" (vc-name file)
361 (file-buffer (get-file-buffer file)) 361 "-q" ;; suppress diagnostic output
362 (concat "-p" rev)
363 vc-checkout-switches))
364
365 (defun vc-rcs-checkout (file &optional editable rev)
366 "Retrieve a copy of a saved version of FILE."
367 (let ((file-buffer (get-file-buffer file))
362 switches) 368 switches)
363 (message "Checking out %s..." filename) 369 (message "Checking out %s..." file)
364 (save-excursion 370 (save-excursion
365 ;; Change buffers to get local value of vc-checkout-switches. 371 ;; Change buffers to get local value of vc-checkout-switches.
366 (if file-buffer (set-buffer file-buffer)) 372 (if file-buffer (set-buffer file-buffer))
367 (setq switches (if (stringp vc-checkout-switches) 373 (setq switches (if (stringp vc-checkout-switches)
368 (list vc-checkout-switches) 374 (list vc-checkout-switches)
372 ;; in the same buffer it was saved in. 378 ;; in the same buffer it was saved in.
373 (let ((default-directory default-directory)) 379 (let ((default-directory default-directory))
374 (save-excursion 380 (save-excursion
375 ;; Adjust the default-directory so that the check-out creates 381 ;; Adjust the default-directory so that the check-out creates
376 ;; the file in the right place. 382 ;; the file in the right place.
377 (setq default-directory (file-name-directory filename)) 383 (setq default-directory (file-name-directory file))
378 (if workfile ;; RCS 384 (let (new-version)
379 ;; RCS can't check out into arbitrary file names directly. 385 ;; if we should go to the head of the trunk,
380 ;; Use `co -p' and make stdout point to the correct file. 386 ;; clear the default branch first
381 (let ((vc-modes (logior (file-modes (vc-name file)) 387 (and rev (string= rev "")
382 (if editable 128 0))) 388 (vc-rcs-set-default-branch file nil))
383 (failed t)) 389 ;; now do the checkout
384 (unwind-protect 390 (apply 'vc-do-command
385 (progn 391 nil 0 "co" (vc-name file)
386 (let ((coding-system-for-read 'no-conversion) 392 ;; If locking is not strict, force to overwrite
387 (coding-system-for-write 'no-conversion)) 393 ;; the writable workfile.
388 (with-temp-file filename 394 (if (eq (vc-checkout-model file) 'implicit) "-f")
389 (apply 'vc-do-command 395 (if editable "-l")
390 (current-buffer) 0 "co" (vc-name file) 396 (if rev (concat "-r" rev)
391 "-q" ;; suppress diagnostic output 397 ;; if no explicit revision was specified,
392 (if editable "-l") 398 ;; check out that of the working file
393 (concat "-p" rev) 399 (let ((workrev (vc-workfile-version file)))
394 switches))) 400 (if workrev (concat "-r" workrev)
395 (set-file-modes filename 401 nil)))
396 (logior (file-modes (vc-name file)) 402 switches)
397 (if editable 128 0))) 403 ;; determine the new workfile version
398 (setq failed nil)) 404 (with-current-buffer "*vc*"
399 (and failed (file-exists-p filename) 405 (setq new-version
400 (delete-file filename)))) 406 (vc-parse-buffer "^revision \\([0-9.]+\\).*\n" 1)))
401 (let (new-version) 407 (vc-file-setprop file 'vc-workfile-version new-version)
402 ;; if we should go to the head of the trunk, 408 ;; if necessary, adjust the default branch
403 ;; clear the default branch first 409 (and rev (not (string= rev ""))
404 (and rev (string= rev "") 410 (vc-rcs-set-default-branch
405 (vc-rcs-set-default-branch file nil)) 411 file
406 ;; now do the checkout 412 (if (vc-rcs-latest-on-branch-p file new-version)
407 (apply 'vc-do-command 413 (if (vc-trunk-p new-version) nil
408 nil 0 "co" (vc-name file) 414 (vc-branch-part new-version))
409 ;; If locking is not strict, force to overwrite 415 new-version)))))
410 ;; the writable workfile. 416 (message "Checking out %s...done" file)))))
411 (if (eq (vc-checkout-model file) 'implicit) "-f")
412 (if editable "-l")
413 (if rev (concat "-r" rev)
414 ;; if no explicit revision was specified,
415 ;; check out that of the working file
416 (let ((workrev (vc-workfile-version file)))
417 (if workrev (concat "-r" workrev)
418 nil)))
419 switches)
420 ;; determine the new workfile version
421 (with-current-buffer "*vc*"
422 (setq new-version
423 (vc-parse-buffer "^revision \\([0-9.]+\\).*\n" 1)))
424 (vc-file-setprop file 'vc-workfile-version new-version)
425 ;; if necessary, adjust the default branch
426 (and rev (not (string= rev ""))
427 (vc-rcs-set-default-branch
428 file
429 (if (vc-rcs-latest-on-branch-p file new-version)
430 (if (vc-trunk-p new-version) nil
431 (vc-branch-part new-version))
432 new-version))))))
433 (message "Checking out %s...done" filename)))))
434 417
435 (defun vc-rcs-revert (file &optional contents-done) 418 (defun vc-rcs-revert (file &optional contents-done)
436 "Revert FILE to the version it was based on." 419 "Revert FILE to the version it was based on."
437 (vc-do-command nil 0 "co" (vc-name file) "-f" 420 (vc-do-command nil 0 "co" (vc-name file) "-f"
438 (concat "-u" (vc-workfile-version file)))) 421 (concat "-u" (vc-workfile-version file))))