;;; vc-arch.el --- VC backend for the Arch version-control system
-;; Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
;; Author: FSF (see vc.el for full credits)
;; Maintainer: Stefan Monnier <monnier@gnu.org>
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
(defun vc-arch-root (file)
"Return the root directory of a Arch project, if any."
(or (vc-file-getprop file 'arch-root)
- (vc-file-setprop
- ;; 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)
+ ;; Check the =tagging-method, in case someone naively manually
+ ;; creates a {arch} directory somewhere.
+ (let ((root (vc-find-root file "{arch}/=tagging-method")))
+ (when root
+ (vc-file-setprop
+ file 'arch-root root)))))
+
+(defun vc-arch-register (files &optional rev comment)
(if rev (error "Explicit initial revision not supported for Arch"))
- (let ((tagmet (vc-arch-tagging-method file)))
- (if (and (memq tagmet '(tagline implicit)) comment-start)
- (with-current-buffer (find-file-noselect file)
- (if (buffer-modified-p)
- (error "Save %s first" (buffer-name)))
- (vc-arch-add-tagline)
- (save-buffer))
- (vc-arch-command nil 0 file "add"))))
+ (dolist (file files)
+ (let ((tagmet (vc-arch-tagging-method file)))
+ (if (and (memq tagmet '(tagline implicit)) comment-start)
+ (with-current-buffer (find-file-noselect file)
+ (if (buffer-modified-p)
+ (error "Save %s first" (buffer-name)))
+ (vc-arch-add-tagline)
+ (save-buffer)))))
+ (vc-arch-command nil 0 files "add"))
(defun vc-arch-registered (file)
;; Don't seriously check whether it's source or not. Checking would
;; ID not found.
(if (equal (file-name-nondirectory sigfile)
(subst-char-in-string
- ?/ ?% (vc-arch-workfile-version file)))
+ ?/ ?% (vc-arch-working-revision file)))
'added
;; Might be `added' or `up-to-date' as well.
;; FIXME: Check in the patch logs to find out.
'up-to-date
'edited)))))))))
-(defun vc-arch-workfile-version (file)
+(defun vc-arch-working-revision (file)
(let* ((root (expand-file-name "{arch}" (vc-arch-root file)))
(defbranch (vc-arch-default-version file)))
(when (and defbranch (string-match "\\`\\(.+@[^/\n]+\\)/\\(\\(\\(.*?\\)\\(?:--.*\\)?\\)--.*\\)\\'" defbranch))
(defun vc-arch-mode-line-string (file)
"Return string for placement in modeline by `vc-mode-line' for FILE."
- (let ((rev (vc-workfile-version file)))
+ (let ((rev (vc-working-revision file)))
(dolist (rule vc-arch-mode-line-rewrite)
(if (string-match (car rule) rev)
(setq rev (replace-match (cdr rule) t nil rev))))
(save-excursion
(let ((rej (concat buffer-file-name ".rej")))
(when (and buffer-file-name (vc-arch-diff3-rej-p rej))
- (if (not (re-search-forward "^<<<<<<< " nil t))
- ;; The .rej file is obsolete.
- (condition-case nil (delete-file rej) (error nil)))))))
+ (unless (re-search-forward "^<<<<<<< " nil t)
+ ;; The .rej file is obsolete.
+ (condition-case nil (delete-file rej) (error nil))
+ ;; Remove the hook so that it is not called multiple times.
+ (remove-hook 'after-save-hook 'vc-arch-delete-rej-if-obsolete t))))))
(defun vc-arch-find-file-hook ()
(let ((rej (concat buffer-file-name ".rej")))
(message "There are unresolved conflicts in %s"
(file-name-nondirectory rej))))))
-(defun vc-arch-find-file-not-found-hook ()
- ;; Do nothing. We are not sure whether the file is `source' or not,
- ;; so we shouldn't ask the user whether she wants to check it out.
- )
-
(defun vc-arch-checkout-model (file) 'implicit)
-(defun vc-arch-checkin (file rev comment)
+(defun vc-arch-checkin (files rev comment)
(if rev (error "Committing to a specific revision is unsupported"))
- (let ((summary (file-relative-name file (vc-arch-root file))))
+ ;; FIXME: This implementation probably only works for singleton filesets
+ (let ((summary (file-relative-name (car files) (vc-arch-root (car files)))))
;; Extract a summary from the comment.
(when (or (string-match "\\`Summary:[ \t]*\\(.*[^ \t\n]\\)\\([ \t]*\n\\)*" comment)
(string-match "\\`[ \t]*\\(.*[^ \t\n]\\)[ \t]*\\(\n?\\'\\|\n\\([ \t]*\n\\)+\\)" comment))
(setq summary (match-string 1 comment))
(setq comment (substring comment (match-end 0))))
- (vc-arch-command nil 0 file "commit" "-s" summary "-L" comment "--"
+ (vc-arch-command nil 0 files "commit" "-s" summary "-L" comment "--"
(vc-switches 'Arch 'checkin))))
-(defun vc-arch-diff (file &optional oldvers newvers buffer)
- "Get a difference report using Arch between two versions of FILE."
- (if (and newvers
- (vc-up-to-date-p file)
- (equal newvers (vc-workfile-version file)))
- ;; Newvers is the base revision and the current file is unchanged,
- ;; so we can diff with the current file.
- (setq newvers nil))
- (if newvers
- (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
- (vc-arch-command
- (or buffer "*vc-diff*")
- (if async 'async 1)
- nil "file-diffs"
- ;; Arch does not support the typical flags.
- ;; (vc-switches 'Arch 'diff)
- (file-relative-name file)
- (if (equal oldvers (vc-workfile-version file))
- nil
- oldvers))))
- (if async 1 status)))) ; async diff, pessimistic assumption.
+(defun vc-arch-diff (files &optional oldvers newvers buffer)
+ "Get a difference report using Arch between two versions of FILES."
+ ;; FIXME: This implementation only works for singleton filesets. To make
+ ;; it work for more cases, we have to either call `file-diffs' manually on
+ ;; each and every `file' in the fileset, or use `changes --diffs' (and
+ ;; variants) and maybe filter the output with `filterdiff' to only include
+ ;; the files in which we're interested.
+ (let ((file (car files)))
+ (if (and newvers
+ (vc-up-to-date-p file)
+ (equal newvers (vc-working-revision file)))
+ ;; Newvers is the base revision and the current file is unchanged,
+ ;; so we can diff with the current file.
+ (setq newvers nil))
+ (if newvers
+ (error "Diffing specific revisions not implemented")
+ (let* ((async (not vc-disable-async-diff))
+ ;; Run the command from the root dir.
+ (default-directory (vc-arch-root file))
+ (status
+ (vc-arch-command
+ (or buffer "*vc-diff*")
+ (if async 'async 1)
+ nil "file-diffs"
+ ;; Arch does not support the typical flags.
+ ;; (vc-switches 'Arch 'diff)
+ (file-relative-name file)
+ (if (equal oldvers (vc-working-revision file))
+ nil
+ oldvers))))
+ (if async 1 status))))) ; async diff, pessimistic assumption.
(defun vc-arch-delete-file (file)
(vc-arch-command nil 0 file "rm"))
"A wrapper around `vc-do-command' for use in vc-arch.el."
(apply 'vc-do-command buffer okstatus vc-arch-command file flags))
-(defun vc-arch-init-version () nil)
+(defun vc-arch-init-revision () nil)
;;; Completion of versions and revisions.
(concat "*/" string))
"*"))))))
-(defun vc-arch-revision-completion-table (file)
- (lexical-let ((file file))
+(defun vc-arch-revision-completion-table (files)
+ (lexical-let ((files files))
(lambda (string pred action)
;; FIXME: complete revision patches as well.
- (let* ((root (expand-file-name "{arch}" (vc-arch-root file)))
+ (let* ((root (expand-file-name "{arch}" (vc-arch-root (car files))))
(table (vc-arch--version-completion-table root string)))
(complete-with-action action table string pred)))))
branches))))
(mapc 'vc-arch-trim-one-revlib versions))
))
-
+
+(defvar vc-arch-extra-menu-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map [add-tagline]
+ '(menu-item "Add tagline" vc-arch-add-tagline))
+ map))
+
+(defun vc-arch-extra-menu () vc-arch-extra-menu-map)
+
+
;;; Less obvious implementations.
-(defun vc-arch-find-version (file rev buffer)
+(defun vc-arch-find-revision (file rev buffer)
(let ((out (make-temp-file "vc-out")))
(unwind-protect
(progn