2004-03-15 03:39:09 +00:00
|
|
|
;;; vc-arch.el --- VC backend for the Arch version-control system
|
|
|
|
|
2007-01-21 03:53:13 +00:00
|
|
|
;; Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
2004-03-15 03:39:09 +00:00
|
|
|
|
|
|
|
;; Author: FSF (see vc.el for full credits)
|
|
|
|
;; Maintainer: Stefan Monnier <monnier@gnu.org>
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
;; 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
|
2007-07-25 04:50:21 +00:00
|
|
|
;; the Free Software Foundation; either version 3, or (at your option)
|
2004-03-15 03:39:09 +00:00
|
|
|
;; any later version.
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; 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
|
2005-07-04 23:32:44 +00:00
|
|
|
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
;; Boston, MA 02110-1301, USA.
|
2004-03-15 03:39:09 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; The home page of the Arch version control system is at
|
2004-03-23 21:34:06 +00:00
|
|
|
;;
|
2004-03-15 03:39:09 +00:00
|
|
|
;; http://www.gnuarch.org/
|
2004-03-23 21:34:06 +00:00
|
|
|
;;
|
2004-03-15 03:39:09 +00:00
|
|
|
;; This is derived from vc-mcvs.el as follows:
|
|
|
|
;; - cp vc-mcvs.el vc-arch.el and then M-% mcvs RET arch RET
|
|
|
|
;;
|
|
|
|
;; Then of course started the hacking.
|
|
|
|
;;
|
|
|
|
;; What has been partly tested:
|
2004-03-23 21:34:06 +00:00
|
|
|
;; - Open a file.
|
|
|
|
;; - C-x v = without any prefix arg.
|
|
|
|
;; - C-x v v to commit a change to a single file.
|
2004-03-15 03:39:09 +00:00
|
|
|
|
|
|
|
;; Bugs:
|
|
|
|
|
2004-03-18 02:48:06 +00:00
|
|
|
;; - *VC-log*'s initial content lacks the `Summary:' lines.
|
2004-03-15 03:39:09 +00:00
|
|
|
;; - All files under the tree are considered as "under Arch's control"
|
|
|
|
;; without regards to =tagging-method and such.
|
|
|
|
;; - Files are always considered as `edited'.
|
2004-03-18 02:48:06 +00:00
|
|
|
;; - C-x v l does not work.
|
2004-03-15 03:39:09 +00:00
|
|
|
;; - C-x v i does not work.
|
2004-03-18 02:48:06 +00:00
|
|
|
;; - C-x v ~ does not work.
|
|
|
|
;; - C-x v u does not work.
|
|
|
|
;; - C-x v s does not work.
|
|
|
|
;; - C-x v r does not work.
|
2004-03-15 03:39:09 +00:00
|
|
|
;; - VC-dired does not work.
|
|
|
|
;; - And more...
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2004-03-23 21:36:49 +00:00
|
|
|
(eval-when-compile (require 'vc) (require 'cl))
|
2004-03-15 03:39:09 +00:00
|
|
|
|
|
|
|
;;;
|
|
|
|
;;; Customization options
|
|
|
|
;;;
|
|
|
|
|
|
|
|
(defvar vc-arch-command
|
|
|
|
(let ((candidates '("tla")))
|
|
|
|
(while (and candidates (not (executable-find (car candidates))))
|
|
|
|
(setq candidates (cdr candidates)))
|
|
|
|
(or (car candidates) "tla")))
|
|
|
|
|
|
|
|
;; Clear up the cache to force vc-call to check again and discover
|
|
|
|
;; new functions when we reload this file.
|
|
|
|
(put 'Arch 'vc-functions nil)
|
|
|
|
|
|
|
|
;;;###autoload (defun vc-arch-registered (file)
|
2004-09-13 20:39:59 +00:00
|
|
|
;;;###autoload (if (vc-find-root file "{arch}/=tagging-method")
|
|
|
|
;;;###autoload (progn
|
|
|
|
;;;###autoload (load "vc-arch")
|
|
|
|
;;;###autoload (vc-arch-registered file))))
|
2004-03-15 03:39:09 +00:00
|
|
|
|
2004-03-23 21:34:06 +00:00
|
|
|
(defun vc-arch-add-tagline ()
|
2004-03-15 03:39:09 +00:00
|
|
|
"Add an `arch-tag' to the end of the current file."
|
|
|
|
(interactive)
|
2004-03-23 21:34:06 +00:00
|
|
|
(comment-normalize-vars)
|
2004-03-15 03:39:09 +00:00
|
|
|
(goto-char (point-max))
|
|
|
|
(forward-comment -1)
|
|
|
|
(unless (bolp) (insert "\n"))
|
2004-03-23 21:34:06 +00:00
|
|
|
(let ((beg (point))
|
|
|
|
(idfile (and buffer-file-name
|
|
|
|
(expand-file-name
|
|
|
|
(concat ".arch-ids/"
|
|
|
|
(file-name-nondirectory buffer-file-name)
|
|
|
|
".id")
|
|
|
|
(file-name-directory buffer-file-name)))))
|
2004-03-15 03:39:09 +00:00
|
|
|
(insert "arch-tag: ")
|
2004-03-23 21:34:06 +00:00
|
|
|
(if (and idfile (file-exists-p idfile))
|
|
|
|
;; If the file is unreadable, we do want to get an error here.
|
|
|
|
(progn
|
|
|
|
(insert-file-contents idfile)
|
|
|
|
(forward-line 1)
|
|
|
|
(delete-file idfile))
|
|
|
|
(condition-case nil
|
|
|
|
(call-process "uuidgen" nil t)
|
|
|
|
(file-error (insert (format "%s <%s> %s"
|
|
|
|
(current-time-string)
|
|
|
|
user-mail-address
|
|
|
|
(+ (nth 2 (current-time))
|
|
|
|
(buffer-size)))))))
|
2004-03-15 03:39:09 +00:00
|
|
|
(comment-region beg (point))))
|
|
|
|
|
2004-03-23 21:34:06 +00:00
|
|
|
(defconst vc-arch-tagline-re "^\\W*arch-tag:[ \t]*\\(.*[^ \t\n]\\)")
|
|
|
|
|
2007-03-28 01:19:43 +00:00
|
|
|
(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-))))))
|
|
|
|
|
2004-03-23 21:34:06 +00:00
|
|
|
(defun vc-arch-file-source-p (file)
|
|
|
|
"Can return nil, `maybe' or a non-nil value.
|
|
|
|
Only the value `maybe' can be trusted :-(."
|
|
|
|
;; FIXME: Check the tag and name of parent dirs.
|
|
|
|
(unless (string-match "\\`[,+]" (file-name-nondirectory file))
|
|
|
|
(or (string-match "\\`{arch}/"
|
|
|
|
(file-relative-name file (vc-arch-root file)))
|
|
|
|
(file-exists-p
|
|
|
|
;; Check the presence of an ID file.
|
|
|
|
(expand-file-name
|
|
|
|
(concat ".arch-ids/" (file-name-nondirectory file) ".id")
|
|
|
|
(file-name-directory file)))
|
|
|
|
;; Check the presence of a tagline.
|
2007-03-28 01:19:43 +00:00
|
|
|
(vc-with-current-file-buffer file
|
2004-03-23 21:34:06 +00:00
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-max))
|
|
|
|
(or (re-search-backward vc-arch-tagline-re (- (point) 1000) t)
|
|
|
|
(progn
|
|
|
|
(goto-char (point-min))
|
|
|
|
(re-search-forward vc-arch-tagline-re (+ (point) 1000) t)))))
|
|
|
|
;; FIXME: check =tagging-method to see whether untagged files might
|
|
|
|
;; be source or not.
|
|
|
|
(with-current-buffer
|
|
|
|
(find-file-noselect (expand-file-name "{arch}/=tagging-method"
|
|
|
|
(vc-arch-root file)))
|
|
|
|
(let ((untagged-source t)) ;Default is `names'.
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-min))
|
|
|
|
(if (re-search-forward "^[ \t]*\\(\\(tagline\\|implicit\\|names\\)\\|explicit\\)" nil t)
|
|
|
|
(setq untagged-source (match-end 2)))
|
|
|
|
(if (re-search-forward "^[ \t]*untagged-source[ \t]+\\(\\(source\\)\\|precious\\|backup\\|junk\\|unrecognized\\)" nil t)
|
|
|
|
(setq untagged-source (match-end 2))))
|
|
|
|
(if untagged-source 'maybe))))))
|
|
|
|
|
|
|
|
(defun vc-arch-file-id (file)
|
|
|
|
;; Don't include the kind of ID this is because it seems to be too messy.
|
|
|
|
(let ((idfile (expand-file-name
|
|
|
|
(concat ".arch-ids/" (file-name-nondirectory file) ".id")
|
|
|
|
(file-name-directory file))))
|
|
|
|
(if (file-exists-p idfile)
|
|
|
|
(with-temp-buffer
|
|
|
|
(insert-file-contents idfile)
|
|
|
|
(looking-at ".*[^ \n\t]")
|
2007-01-28 07:05:42 +00:00
|
|
|
(match-string 0))
|
2004-03-23 21:34:06 +00:00
|
|
|
(with-current-buffer (find-file-noselect file)
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-max))
|
|
|
|
(if (or (re-search-backward vc-arch-tagline-re (- (point) 1000) t)
|
|
|
|
(progn
|
|
|
|
(goto-char (point-min))
|
|
|
|
(re-search-forward vc-arch-tagline-re (+ (point) 1000) t)))
|
|
|
|
(match-string 1)
|
2007-01-28 07:05:42 +00:00
|
|
|
(concat "./" (file-relative-name file (vc-arch-root file)))))))))
|
2004-03-23 21:34:06 +00:00
|
|
|
|
|
|
|
(defun vc-arch-tagging-method (file)
|
|
|
|
(with-current-buffer
|
|
|
|
(find-file-noselect
|
|
|
|
(expand-file-name "{arch}/=tagging-method" (vc-arch-root file)))
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-min))
|
|
|
|
(if (re-search-forward
|
|
|
|
"^[ \t]*\\(tagline\\|implicit\\|names\\|explicit\\)" nil t)
|
|
|
|
(intern (match-string 1))
|
|
|
|
'names))))
|
|
|
|
|
2004-03-15 03:39:09 +00:00
|
|
|
(defun vc-arch-root (file)
|
|
|
|
"Return the root directory of a Arch project, if any."
|
|
|
|
(or (vc-file-getprop file 'arch-root)
|
2005-06-14 15:21:33 +00:00
|
|
|
(vc-file-setprop
|
2004-09-13 20:39:59 +00:00
|
|
|
;; Check the =tagging-method, in case someone naively manually
|
|
|
|
;; creates a {arch} directory somewhere.
|
|
|
|
file 'arch-root (vc-find-root file "{arch}/=tagging-method"))))
|
2004-03-15 03:39:09 +00:00
|
|
|
|
2004-03-23 21:34:06 +00:00
|
|
|
(defun vc-arch-register (file &optional rev comment)
|
2004-04-12 04:23:38 +00:00
|
|
|
(if rev (error "Explicit initial revision not supported for Arch"))
|
2004-03-23 21:34:06 +00:00
|
|
|
(let ((tagmet (vc-arch-tagging-method file)))
|
|
|
|
(if (and (memq tagmet '(tagline implicit)) comment-start)
|
|
|
|
(with-current-buffer (find-file-noselect file)
|
2004-04-12 04:23:38 +00:00
|
|
|
(if (buffer-modified-p)
|
|
|
|
(error "Save %s first" (buffer-name)))
|
|
|
|
(vc-arch-add-tagline)
|
|
|
|
(save-buffer))
|
2004-03-23 21:34:06 +00:00
|
|
|
(vc-arch-command nil 0 file "add"))))
|
|
|
|
|
2004-03-15 03:39:09 +00:00
|
|
|
(defun vc-arch-registered (file)
|
2004-03-23 21:34:06 +00:00
|
|
|
;; Don't seriously check whether it's source or not. Checking would
|
|
|
|
;; require running TLA, so it's better to not do it, so it also works if
|
|
|
|
;; TLA is not installed.
|
|
|
|
(and (vc-arch-root file)
|
|
|
|
(vc-arch-file-source-p file)))
|
2004-03-15 03:39:09 +00:00
|
|
|
|
|
|
|
(defun vc-arch-default-version (file)
|
|
|
|
(or (vc-file-getprop (vc-arch-root file) 'arch-default-version)
|
|
|
|
(let* ((root (vc-arch-root file))
|
|
|
|
(f (expand-file-name "{arch}/++default-version" root)))
|
|
|
|
(if (file-readable-p f)
|
|
|
|
(vc-file-setprop
|
|
|
|
root 'arch-default-version
|
|
|
|
(with-temp-buffer
|
|
|
|
(insert-file-contents f)
|
|
|
|
;; Strip the terminating newline.
|
|
|
|
(buffer-substring (point-min) (1- (point-max)))))))))
|
|
|
|
|
2004-03-16 15:20:17 +00:00
|
|
|
(defun vc-arch-workfile-unchanged-p (file)
|
|
|
|
"Check if FILE is unchanged by diffing against the master version.
|
|
|
|
Return non-nil if FILE is unchanged."
|
|
|
|
nil)
|
|
|
|
|
2004-03-15 03:39:09 +00:00
|
|
|
(defun vc-arch-state (file)
|
|
|
|
;; There's no checkout operation and merging is not done from VC
|
|
|
|
;; so the only operation that's state dependent that VC supports is commit
|
|
|
|
;; which is only activated if the file is `edited'.
|
2004-03-23 21:34:06 +00:00
|
|
|
(let* ((root (vc-arch-root file))
|
|
|
|
(ver (vc-arch-default-version file))
|
|
|
|
(pat (concat "\\`" (subst-char-in-string ?/ ?% ver)))
|
|
|
|
(dir (expand-file-name ",,inode-sigs/"
|
|
|
|
(expand-file-name "{arch}" root)))
|
|
|
|
(sigfile nil))
|
|
|
|
(dolist (f (if (file-directory-p dir) (directory-files dir t pat)))
|
|
|
|
(if (or (not sigfile) (file-newer-than-file-p f sigfile))
|
|
|
|
(setq sigfile f)))
|
|
|
|
(if (not sigfile)
|
|
|
|
'edited ;We know nothing.
|
|
|
|
(let ((id (vc-arch-file-id file)))
|
|
|
|
(setq id (replace-regexp-in-string "[ \t]" "_" id))
|
|
|
|
(with-current-buffer (find-file-noselect sigfile)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (and (search-forward id nil 'move)
|
2004-09-08 22:15:34 +00:00
|
|
|
(save-excursion
|
|
|
|
(goto-char (- (match-beginning 0) 2))
|
|
|
|
;; For `names', the lines start with `?./foo/bar'.
|
|
|
|
;; For others there's 2 chars before the ./foo/bar.
|
|
|
|
(or (not (or (bolp) (looking-at "\n?")))
|
|
|
|
;; Ignore E_ entries used for foo.id files.
|
|
|
|
(looking-at "E_")))))
|
2004-03-23 21:34:06 +00:00
|
|
|
(if (eobp)
|
|
|
|
;; ID not found.
|
|
|
|
(if (equal (file-name-nondirectory sigfile)
|
|
|
|
(subst-char-in-string
|
|
|
|
?/ ?% (vc-arch-workfile-version file)))
|
|
|
|
'added
|
|
|
|
;; Might be `added' or `up-to-date' as well.
|
|
|
|
;; FIXME: Check in the patch logs to find out.
|
|
|
|
'edited)
|
|
|
|
;; Found the ID, let's check the inode.
|
|
|
|
(if (not (re-search-forward
|
|
|
|
"\t.*mtime=\\([0-9]+\\):size=\\([0-9]+\\)"
|
|
|
|
(line-end-position) t))
|
|
|
|
;; Buh? Unexpected format.
|
|
|
|
'edited
|
|
|
|
(let ((ats (file-attributes file)))
|
2004-06-01 00:25:50 +00:00
|
|
|
(if (and (eq (nth 7 ats) (string-to-number (match-string 2)))
|
2004-03-23 21:34:06 +00:00
|
|
|
(equal (format-time-string "%s" (nth 5 ats))
|
|
|
|
(match-string 1)))
|
|
|
|
'up-to-date
|
|
|
|
'edited)))))))))
|
2004-04-12 04:23:38 +00:00
|
|
|
|
2004-03-15 03:39:09 +00:00
|
|
|
(defun vc-arch-workfile-version (file)
|
|
|
|
(let* ((root (expand-file-name "{arch}" (vc-arch-root file)))
|
|
|
|
(defbranch (vc-arch-default-version file)))
|
2005-01-02 22:07:52 +00:00
|
|
|
(when (and defbranch (string-match "\\`\\(.+@[^/\n]+\\)/\\(\\(\\(.*?\\)\\(?:--.*\\)?\\)--.*\\)\\'" defbranch))
|
2004-03-15 03:39:09 +00:00
|
|
|
(let* ((archive (match-string 1 defbranch))
|
|
|
|
(category (match-string 4 defbranch))
|
|
|
|
(branch (match-string 3 defbranch))
|
|
|
|
(version (match-string 2 defbranch))
|
2004-03-18 02:48:06 +00:00
|
|
|
(sealed nil) (rev-nb 0)
|
2004-03-15 03:39:09 +00:00
|
|
|
(rev nil)
|
|
|
|
logdir tmp)
|
|
|
|
(setq logdir (expand-file-name category root))
|
|
|
|
(setq logdir (expand-file-name branch logdir))
|
|
|
|
(setq logdir (expand-file-name version logdir))
|
|
|
|
(setq logdir (expand-file-name archive logdir))
|
|
|
|
(setq logdir (expand-file-name "patch-log" logdir))
|
2004-10-17 23:01:25 +00:00
|
|
|
(dolist (file (if (file-directory-p logdir) (directory-files logdir)))
|
|
|
|
;; Revision names go: base-0, patch-N, version-0, versionfix-M.
|
2004-03-18 02:48:06 +00:00
|
|
|
(when (and (eq (aref file 0) ?v) (not sealed))
|
|
|
|
(setq sealed t rev-nb 0))
|
2004-03-15 03:39:09 +00:00
|
|
|
(if (and (string-match "-\\([0-9]+\\)\\'" file)
|
|
|
|
(setq tmp (string-to-number (match-string 1 file)))
|
2004-03-18 02:48:06 +00:00
|
|
|
(or (not sealed) (eq (aref file 0) ?v))
|
2004-03-15 03:39:09 +00:00
|
|
|
(>= tmp rev-nb))
|
|
|
|
(setq rev-nb tmp rev file)))
|
2004-09-07 04:49:03 +00:00
|
|
|
;; Use "none-000" if the tree hasn't yet been committed on the
|
|
|
|
;; default branch. We'll then get "Arch:000[branch]" on the mode-line.
|
|
|
|
(concat defbranch "--" (or rev "none-000"))))))
|
2004-03-15 03:39:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
(defcustom vc-arch-mode-line-rewrite
|
2004-03-18 02:48:06 +00:00
|
|
|
'(("\\`.*--\\(.*--.*\\)--\\(v?\\).*-\\([0-9]+\\)\\'" . "\\2\\3[\\1]"))
|
2004-03-15 03:39:09 +00:00
|
|
|
"Rewrite rules to shorten Arch's revision names on the mode-line."
|
2004-06-29 13:00:49 +00:00
|
|
|
:type '(repeat (cons regexp string))
|
|
|
|
:group 'vc)
|
2004-03-15 03:39:09 +00:00
|
|
|
|
|
|
|
(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)))
|
|
|
|
(dolist (rule vc-arch-mode-line-rewrite)
|
|
|
|
(if (string-match (car rule) rev)
|
|
|
|
(setq rev (replace-match (cdr rule) t nil rev))))
|
|
|
|
(format "Arch%c%s"
|
2004-03-23 21:34:06 +00:00
|
|
|
(case (vc-state file)
|
|
|
|
((up-to-date needs-patch) ?-)
|
|
|
|
(added ?@)
|
|
|
|
(t ?:))
|
2004-03-15 03:39:09 +00:00
|
|
|
rev)))
|
|
|
|
|
|
|
|
(defun vc-arch-diff3-rej-p (rej)
|
2004-03-23 21:34:06 +00:00
|
|
|
(let ((attrs (file-attributes rej)))
|
|
|
|
(and attrs (< (nth 7 attrs) 60)
|
|
|
|
(with-temp-buffer
|
|
|
|
(insert-file-contents rej)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(looking-at "Conflicts occured, diff3 conflict markers left in file\\.")))))
|
2004-03-15 03:39:09 +00:00
|
|
|
|
|
|
|
(defun vc-arch-delete-rej-if-obsolete ()
|
2004-04-12 04:23:38 +00:00
|
|
|
"For use in `after-save-hook'."
|
|
|
|
(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)))))))
|
2004-03-15 03:39:09 +00:00
|
|
|
|
|
|
|
(defun vc-arch-find-file-hook ()
|
|
|
|
(let ((rej (concat buffer-file-name ".rej")))
|
|
|
|
(when (and buffer-file-name (file-exists-p rej))
|
|
|
|
(if (vc-arch-diff3-rej-p rej)
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-min))
|
2004-04-12 04:23:38 +00:00
|
|
|
(if (not (re-search-forward "^<<<<<<< " nil t))
|
2004-03-15 03:39:09 +00:00
|
|
|
;; The .rej file is obsolete.
|
|
|
|
(condition-case nil (delete-file rej) (error nil))
|
|
|
|
(smerge-mode 1)
|
2004-04-12 04:23:38 +00:00
|
|
|
(add-hook 'after-save-hook
|
2004-03-15 03:39:09 +00:00
|
|
|
'vc-arch-delete-rej-if-obsolete nil t)
|
|
|
|
(message "There are unresolved conflicts in this file")))
|
|
|
|
(message "There are unresolved conflicts in %s"
|
|
|
|
(file-name-nondirectory rej))))))
|
|
|
|
|
2004-03-23 21:34:06 +00:00
|
|
|
(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.
|
|
|
|
)
|
|
|
|
|
2004-03-15 03:39:09 +00:00
|
|
|
(defun vc-arch-checkout-model (file) 'implicit)
|
|
|
|
|
|
|
|
(defun vc-arch-checkin (file rev comment)
|
2005-06-14 15:21:33 +00:00
|
|
|
(if rev (error "Committing to a specific revision is unsupported"))
|
2004-03-18 02:48:06 +00:00
|
|
|
(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)
|
|
|
|
(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-switches 'Arch 'checkin))))
|
2004-03-15 03:39:09 +00:00
|
|
|
|
2004-05-28 23:04:07 +00:00
|
|
|
(defun vc-arch-diff (file &optional oldvers newvers buffer)
|
2004-03-15 03:39:09 +00:00
|
|
|
"Get a difference report using Arch between two versions of FILE."
|
2004-03-23 21:34:06 +00:00
|
|
|
(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))
|
2004-03-15 03:39:09 +00:00
|
|
|
(if newvers
|
2005-06-14 15:21:33 +00:00
|
|
|
(error "Diffing specific revisions not implemented")
|
2005-01-09 21:29:27 +00:00
|
|
|
(let* ((async (and (not vc-disable-async-diff) (fboundp 'start-process)))
|
2004-03-15 03:39:09 +00:00
|
|
|
;; Run the command from the root dir.
|
|
|
|
(default-directory (vc-arch-root file))
|
|
|
|
(status
|
|
|
|
(vc-arch-command
|
2004-05-28 23:04:07 +00:00
|
|
|
(or buffer "*vc-diff*")
|
2004-03-15 03:39:09 +00:00
|
|
|
(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-delete-file (file)
|
|
|
|
(vc-arch-command nil 0 file "rm"))
|
|
|
|
|
|
|
|
(defun vc-arch-rename-file (old new)
|
|
|
|
(vc-arch-command nil 0 new "mv" (file-relative-name old)))
|
|
|
|
|
2004-04-12 04:23:38 +00:00
|
|
|
(defalias 'vc-arch-responsible-p 'vc-arch-root)
|
|
|
|
|
2004-03-15 03:39:09 +00:00
|
|
|
(defun vc-arch-command (buffer okstatus file &rest flags)
|
|
|
|
"A wrapper around `vc-do-command' for use in vc-arch.el."
|
|
|
|
(apply 'vc-do-command buffer okstatus vc-arch-command file flags))
|
|
|
|
|
2004-04-12 04:23:38 +00:00
|
|
|
(defun vc-arch-init-version () nil)
|
|
|
|
|
2006-12-27 16:26:34 +00:00
|
|
|
;;; 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))))
|
|
|
|
|
2004-03-15 03:39:09 +00:00
|
|
|
(provide 'vc-arch)
|
|
|
|
|
2004-09-07 04:49:03 +00:00
|
|
|
;; arch-tag: a35c7c1c-5237-429d-88ef-3d718fd2e704
|
2004-03-15 03:39:09 +00:00
|
|
|
;;; vc-arch.el ends here
|