;;; vc-arch.el --- VC backend for the Arch version-control system
-;; Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
;; Author: FSF (see vc.el for full credits)
;; Maintainer: Stefan Monnier <monnier@gnu.org>
(defconst vc-arch-tagline-re "^\\W*arch-tag:[ \t]*\\(.*[^ \t\n]\\)")
+(defmacro vc-with-current-file-buffer (file &rest body)
+ (declare (indent 2) (debug t))
+ `(let ((-kill-buf- nil)
+ (-file- ,file))
+ (with-current-buffer (or (find-buffer-visiting -file-)
+ (setq -kill-buf- (generate-new-buffer " temp")))
+ ;; Avoid find-file-literally since it can do many undesirable extra
+ ;; things (among which, call us back into an infinite loop).
+ (if -kill-buf- (insert-file-contents -file-))
+ (unwind-protect
+ (progn ,@body)
+ (if (buffer-live-p -kill-buf-) (kill-buffer -kill-buf-))))))
+
(defun vc-arch-file-source-p (file)
"Can return nil, `maybe' or a non-nil value.
Only the value `maybe' can be trusted :-(."
(concat ".arch-ids/" (file-name-nondirectory file) ".id")
(file-name-directory file)))
;; Check the presence of a tagline.
- (with-current-buffer (find-file-noselect file)
+ (vc-with-current-file-buffer file
(save-excursion
(goto-char (point-max))
(or (re-search-backward vc-arch-tagline-re (- (point) 1000) t)
(with-temp-buffer
(insert-file-contents idfile)
(looking-at ".*[^ \n\t]")
- (match-string 0)))
+ (match-string 0))
(with-current-buffer (find-file-noselect file)
(save-excursion
(goto-char (point-max))
(goto-char (point-min))
(re-search-forward vc-arch-tagline-re (+ (point) 1000) t)))
(match-string 1)
- (concat "./" (file-relative-name file (vc-arch-root file))))))))
+ (concat "./" (file-relative-name file (vc-arch-root file)))))))))
(defun vc-arch-tagging-method (file)
(with-current-buffer
(defun vc-arch-init-version () nil)
+;;; Less obvious implementations.
+
+(defun vc-arch-find-version (file rev buffer)
+ (let ((out (make-temp-file "vc-out")))
+ (unwind-protect
+ (progn
+ (with-temp-buffer
+ (vc-arch-command (current-buffer) 1 nil "file-diffs" file rev)
+ (call-process-region (point-min) (point-max)
+ "patch" nil nil nil "-R" "-o" out file))
+ (with-current-buffer buffer
+ (insert-file-contents out)))
+ (delete-file out))))
+
(provide 'vc-arch)
;; arch-tag: a35c7c1c-5237-429d-88ef-3d718fd2e704