X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/c9cb3a267c2c62a26cafd10e3e06567853f56f8a..ba830ecbfe8ee433167f73d60e87822399b8ff9f:/lisp/vc-arch.el diff --git a/lisp/vc-arch.el b/lisp/vc-arch.el index c4c484a934..488f9108d3 100644 --- a/lisp/vc-arch.el +++ b/lisp/vc-arch.el @@ -1,7 +1,6 @@ ;;; vc-arch.el --- VC backend for the Arch version-control system -;; Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004 -;; 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 @@ -20,8 +19,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: @@ -73,18 +72,10 @@ (put 'Arch 'vc-functions nil) ;;;###autoload (defun vc-arch-registered (file) -;;;###autoload (let ((dir file)) -;;;###autoload (while (and (stringp dir) -;;;###autoload (not (equal -;;;###autoload dir (setq dir (file-name-directory dir)))) -;;;###autoload dir) -;;;###autoload (setq dir (if (file-directory-p -;;;###autoload (expand-file-name "{arch}" dir)) -;;;###autoload t (directory-file-name dir)))) -;;;###autoload (if (eq dir t) -;;;###autoload (progn -;;;###autoload (load "vc-arch") -;;;###autoload (vc-arch-registered file))))) +;;;###autoload (if (vc-find-root file "{arch}/=tagging-method") +;;;###autoload (progn +;;;###autoload (load "vc-arch") +;;;###autoload (vc-arch-registered file)))) (defun vc-arch-add-tagline () "Add an `arch-tag' to the end of the current file." @@ -118,6 +109,19 @@ (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 :-(." @@ -131,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) @@ -161,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)) @@ -170,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 @@ -187,17 +191,9 @@ Only the value `maybe' can be trusted :-(." "Return the root directory of a Arch project, if any." (or (vc-file-getprop file 'arch-root) (vc-file-setprop - file 'arch-root - (let ((root nil)) - (while (not (or root - (equal file (setq file (file-name-directory file))) - (null file))) - ;; Check the =tagging-method, in case someone naively manually - ;; creates a {arch} directory somewhere. - (if (file-exists-p (expand-file-name "{arch}/=tagging-method" file)) - (setq root file) - (setq file (directory-file-name file)))) - root)))) + ;; Check the =tagging-method, in case someone naively manually + ;; creates a {arch} directory somewhere. + file 'arch-root (vc-find-root file "{arch}/=tagging-method")))) (defun vc-arch-register (file &optional rev comment) (if rev (error "Explicit initial revision not supported for Arch")) @@ -286,7 +282,7 @@ Return non-nil if FILE is unchanged." (defun vc-arch-workfile-version (file) (let* ((root (expand-file-name "{arch}" (vc-arch-root file))) (defbranch (vc-arch-default-version file))) - (when (and defbranch (string-match "\\`\\(.+@[^/\n]+\\)/\\(\\(\\(.*\\)--.*\\)--.*\\)\\'" defbranch)) + (when (and defbranch (string-match "\\`\\(.+@[^/\n]+\\)/\\(\\(\\(.*?\\)\\(?:--.*\\)?\\)--.*\\)\\'" defbranch)) (let* ((archive (match-string 1 defbranch)) (category (match-string 4 defbranch)) (branch (match-string 3 defbranch)) @@ -299,8 +295,8 @@ Return non-nil if FILE is unchanged." (setq logdir (expand-file-name version logdir)) (setq logdir (expand-file-name archive logdir)) (setq logdir (expand-file-name "patch-log" logdir)) - ;; Revision names go: base-0, patch-N, version-0, versionfix-N. - (dolist (file (directory-files logdir)) + (dolist (file (if (file-directory-p logdir) (directory-files logdir))) + ;; Revision names go: base-0, patch-N, version-0, versionfix-M. (when (and (eq (aref file 0) ?v) (not sealed)) (setq sealed t rev-nb 0)) (if (and (string-match "-\\([0-9]+\\)\\'" file) @@ -373,7 +369,7 @@ Return non-nil if FILE is unchanged." (defun vc-arch-checkout-model (file) 'implicit) (defun vc-arch-checkin (file rev comment) - (if rev (error "Committing to a specific revision is unsupported.")) + (if rev (error "Committing to a specific revision is unsupported")) (let ((summary (file-relative-name file (vc-arch-root file)))) ;; Extract a summary from the comment. (when (or (string-match "\\`Summary:[ \t]*\\(.*[^ \t\n]\\)\\([ \t]*\n\\)*" comment) @@ -392,8 +388,8 @@ Return non-nil if FILE is unchanged." ;; so we can diff with the current file. (setq newvers nil)) (if newvers - (error "Diffing specific revisions not implemented.") - (let* ((async (fboundp 'start-process)) + (error "Diffing specific revisions not implemented") + (let* ((async (and (not vc-disable-async-diff) (fboundp 'start-process))) ;; Run the command from the root dir. (default-directory (vc-arch-root file)) (status @@ -423,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