]> code.delx.au - gnu-emacs/blobdiff - lisp/vc-arch.el
Merge from emacs--devo--0
[gnu-emacs] / lisp / vc-arch.el
index a0fc8af83456a0ff2513f0230c2e2665fe132b4d..488f9108d367c5571d7f4a9ced3312732a70713b 100644 (file)
@@ -1,6 +1,6 @@
 ;;; vc-arch.el --- VC backend for the Arch version-control system
 
-;; Copyright (C) 2004, 2005, 2006 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 :-(."
@@ -122,7 +135,7 @@ 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)
@@ -152,7 +165,7 @@ Only the value `maybe' can be trusted :-(."
        (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))
@@ -161,7 +174,7 @@ Only the value `maybe' can be trusted :-(."
                    (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
@@ -406,6 +419,20 @@ Return non-nil if FILE is unchanged."
 
 (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