2012-04-25 23:18:47 -04:00
|
|
|
;;; vc-arch.el --- VC backend for the Arch version-control system -*- lexical-binding: t -*-
|
2004-03-15 03:39:09 +00:00
|
|
|
|
2019-01-01 00:59:58 +00:00
|
|
|
;; Copyright (C) 2004-2019 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>
|
2010-08-29 12:17:13 -04:00
|
|
|
;; Package: vc
|
2004-03-15 03:39:09 +00:00
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2004-03-15 03:39:09 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
2004-03-15 03:39:09 +00:00
|
|
|
|
|
|
|
;; 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
|
2017-09-13 15:52:52 -07:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
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:
|
|
|
|
|
2011-07-03 03:15:38 +02: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.
|
2008-05-02 07:38:11 +00:00
|
|
|
;; - VC directory listings do not work.
|
2004-03-15 03:39:09 +00:00
|
|
|
;; - And more...
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 19:13:41 -04:00
|
|
|
(eval-when-compile (require 'vc))
|
2004-03-15 03:39:09 +00:00
|
|
|
|
2008-05-02 17:47:25 +00:00
|
|
|
;;; Properties of the backend
|
|
|
|
|
|
|
|
(defun vc-arch-revision-granularity () 'repository)
|
2012-04-25 23:18:47 -04:00
|
|
|
(defun vc-arch-checkout-model (_files) 'implicit)
|
2008-05-02 17:47:25 +00:00
|
|
|
|
2004-03-15 03:39:09 +00:00
|
|
|
;;;
|
|
|
|
;;; Customization options
|
|
|
|
;;;
|
|
|
|
|
2012-02-25 12:29:09 +08:00
|
|
|
(defgroup vc-arch nil
|
|
|
|
"VC Arch backend."
|
|
|
|
:version "24.1"
|
|
|
|
:group 'vc)
|
|
|
|
|
2008-12-03 07:35:14 +00:00
|
|
|
;; It seems Arch diff does not accept many options, so this is not
|
|
|
|
;; very useful. It exists mainly so that the VC backends are all
|
|
|
|
;; consistent with regards to their treatment of diff switches.
|
|
|
|
(defcustom vc-arch-diff-switches t
|
|
|
|
"String or list of strings specifying switches for Arch diff under VC.
|
|
|
|
If nil, use the value of `vc-diff-switches'. If t, use no switches."
|
|
|
|
:type '(choice (const :tag "Unspecified" nil)
|
|
|
|
(const :tag "None" t)
|
|
|
|
(string :tag "Argument String")
|
|
|
|
(repeat :tag "Argument List" :value ("") string))
|
|
|
|
:version "23.1"
|
2012-02-25 12:29:09 +08:00
|
|
|
:group 'vc-arch)
|
2008-12-03 07:35:14 +00:00
|
|
|
|
2008-11-22 03:30:22 +00:00
|
|
|
(define-obsolete-variable-alias 'vc-arch-command 'vc-arch-program "23.1")
|
|
|
|
|
|
|
|
(defcustom vc-arch-program
|
2007-06-13 18:00:34 +00:00
|
|
|
(let ((candidates '("tla" "baz")))
|
2004-03-15 03:39:09 +00:00
|
|
|
(while (and candidates (not (executable-find (car candidates))))
|
|
|
|
(setq candidates (cdr candidates)))
|
2008-11-22 03:30:22 +00:00
|
|
|
(or (car candidates) "tla"))
|
|
|
|
"Name of the Arch executable."
|
|
|
|
:type 'string
|
2012-02-25 12:29:09 +08:00
|
|
|
:group 'vc-arch)
|
2004-03-15 03:39:09 +00:00
|
|
|
|
|
|
|
;; 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
|
2013-02-01 18:19:24 +01:00
|
|
|
;;;###autoload (load "vc-arch" nil t)
|
2004-09-13 20:39:59 +00:00
|
|
|
;;;###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)
|
2007-06-26 17:59:52 +00:00
|
|
|
(skip-chars-forward " \t\n")
|
|
|
|
(cond
|
|
|
|
((not (bolp)) (insert "\n\n"))
|
|
|
|
((not (eq ?\n (char-before (1- (point))))) (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
|
New (TICKS . HZ) timestamp format
This follows on a suggestion by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00991.html
(Bug#32902).
* doc/lispref/buffers.texi (Modification Time):
* doc/lispref/os.texi (Processor Run Time, Time Calculations)
* doc/lispref/processes.texi (System Processes):
* doc/lispref/text.texi (Undo):
Let the "Time of Day" section cover timestamp format details.
* doc/lispref/os.texi (Time of Day):
Say that timestamp internal format should not be assumed.
Document new (ticks . hz) format. Omit mention of seconds-to-time
since it is now just an alias for encode-time.
(Time Conversion): Document encode-time extension.
* etc/NEWS: Mention changes.
* lisp/calendar/cal-dst.el (calendar-system-time-basis): Now const.
* lisp/calendar/cal-dst.el (calendar-absolute-from-time)
(calendar-time-from-absolute)
(calendar-next-time-zone-transition):
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums, (TICKS . HZ), and new encode-time.
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums and new encode-time.
* lisp/calendar/parse-time.el (parse-iso8601-time-string):
Handle DST more accurately, by using new encode-time.
* lisp/calendar/time-date.el (seconds-to-time):
* lisp/calendar/timeclock.el (timeclock-seconds-to-time):
Now just an alias for encode-time.
* lisp/calendar/time-date.el (days-to-time):
* lisp/emacs-lisp/timer.el (timer--time-setter):
* lisp/net/ntlm.el (ntlm-compute-timestamp):
* lisp/obsolete/vc-arch.el (vc-arch-add-tagline):
* lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36):
* lisp/tar-mode (tar-octal-time):
Don't assume timestamps default to list form.
* lisp/tar-mode.el (tar-parse-octal-long-integer):
Now an obsolete alias for tar-parse-octal-integer.
* src/keyboard.c (decode_timer): Adjust to changes to
time decoding functions elsewhere.
* src/timefns.c: Include bignum.h, limits.h.
(FASTER_TIMEFNS): New macro.
(WARN_OBSOLETE_TIMESTAMPS, CURRENT_TIME_LIST)
(timespec_hz, trillion, ztrillion):
New constants.
(make_timeval): Use TIME_T_MAX instead of its definiens.
(check_time_validity, time_add, time_subtract):
Remove. All uses removed.
(disassemble_lisp_time): Remove; old code now folded into
decode_lisp_time. All callers changed.
(invalid_hz, s_ns_to_double, ticks_hz_list4, mpz_set_time)
(timespec_mpz, timespec_ticks, time_hz_ticks)
(lisp_time_hz_ticks, lisp_time_seconds)
(time_form_stamp, lisp_time_form_stamp, decode_ticks_hz)
(decode_lisp_time, mpz_time, list4_to_timespec):
New functions.
(decode_float_time, decode_time_components, lisp_to_timespec):
Adjust to new struct lisp_time, which does not lose
information like the old one did.
(enum timeform): New enum.
(decode_time_components): New arg FORM. All callers changed.
RESULT and DRESULT are now mutually exclusive; no callers need
to change because of this.
(decode_time_components, lisp_time_struct)
(lisp_seconds_argument, time_arith, make_lisp_time, Ffloat_time)
(Fencode_time):
Add support for (TICKS . HZ) form.
(DECODE_SECS_ONLY): New constant.
(lisp_time_struct): 2nd arg is now enum timeform, not int.
All callers changed.
(check_tm_member): Support bignums.m
(Fencode_time): Add new two-arg functionality.
* src/systime.h (struct lisp_time): Now ticks+hz rather than
hi+lo+us+ps, since ticks+hz does not lose info.
* test/src/systime-tests.el (time-equal-p-nil-nil):
New test.
2018-10-03 09:10:01 -07:00
|
|
|
(+ (% (car (encode-time nil 1000000))
|
|
|
|
1000000)
|
2004-03-23 21:34:06 +00:00
|
|
|
(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)
|
2010-01-14 19:59:31 +01:00
|
|
|
"Return the root directory of an Arch project, if any."
|
2004-03-15 03:39:09 +00:00
|
|
|
(or (vc-file-getprop file 'arch-root)
|
2008-01-04 08:34:15 +00:00
|
|
|
;; 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)))))
|
2004-03-15 03:39:09 +00:00
|
|
|
|
2013-10-05 07:47:00 +08:00
|
|
|
(defun vc-arch-find-admin-dir (file)
|
|
|
|
"Return the administrative directory of FILE."
|
|
|
|
(expand-file-name "{arch}" (vc-arch-root file)))
|
|
|
|
|
2014-12-01 06:23:10 -05:00
|
|
|
(defun vc-arch-register (files &optional _comment)
|
2007-07-18 16:32:40 +00:00
|
|
|
(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"))
|
2004-03-23 21:34:06 +00:00
|
|
|
|
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)))))))))
|
|
|
|
|
|
|
|
(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
|
2007-10-10 18:52:45 +00:00
|
|
|
?/ ?% (vc-arch-working-revision file)))
|
2004-03-23 21:34:06 +00:00
|
|
|
'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)))
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
(if (and (eq (file-attribute-size ats) (string-to-number (match-string 2)))
|
|
|
|
(equal (format-time-string
|
|
|
|
"%s" (file-attribute-modification-time ats))
|
2004-03-23 21:34:06 +00:00
|
|
|
(match-string 1)))
|
|
|
|
'up-to-date
|
|
|
|
'edited)))))))))
|
2004-04-12 04:23:38 +00:00
|
|
|
|
2015-10-28 02:43:14 +02:00
|
|
|
;; dir-status-files called from vc-dir, which loads vc,
|
|
|
|
;; which loads vc-dispatcher.
|
|
|
|
(declare-function vc-exec-after "vc-dispatcher" (code))
|
|
|
|
|
2014-12-02 10:10:55 -05:00
|
|
|
(defun vc-arch-dir-status-files (dir _files callback)
|
Prefer directed to neutral quotes
Prefer directed to neutral quotes in docstings and diagnostics.
In docstrings, escape apostrophes that would otherwise be translated
to curved quotes using the newer, simpler rules.
* admin/unidata/unidata-gen.el (unidata-gen-table):
* lisp/align.el (align-region):
* lisp/allout.el (allout-mode, allout-solicit-alternate-bullet):
* lisp/bookmark.el (bookmark-default-annotation-text):
* lisp/calc/calc-aent.el (math-read-if, math-read-factor):
* lisp/calc/calc-lang.el (math-read-giac-subscr)
(math-read-math-subscr):
* lisp/calc/calc-misc.el (report-calc-bug):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-read-parse-table-part):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/semantic/complete.el (semantic-displayor-show-request):
* lisp/dabbrev.el (dabbrev-expand):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/emacs-lisp/elint.el (elint-get-top-forms):
* lisp/emacs-lisp/lisp-mnt.el (lm-verify):
* lisp/emulation/viper-cmd.el (viper-toggle-search-style):
* lisp/erc/erc-button.el (erc-nick-popup):
* lisp/erc/erc.el (erc-cmd-LOAD, erc-handle-login):
* lisp/eshell/em-dirs.el (eshell/cd):
* lisp/eshell/em-glob.el (eshell-glob-regexp):
* lisp/eshell/em-pred.el (eshell-parse-modifiers):
* lisp/eshell/esh-arg.el (eshell-parse-arguments):
* lisp/eshell/esh-opt.el (eshell-show-usage):
* lisp/files-x.el (modify-file-local-variable):
* lisp/filesets.el (filesets-add-buffer, filesets-remove-buffer)
(filesets-update-pre010505):
* lisp/find-cmd.el (find-generic, find-to-string):
* lisp/gnus/auth-source.el (auth-source-netrc-parse-entries):
* lisp/gnus/gnus-agent.el (gnus-agent-check-overview-buffer)
(gnus-agent-fetch-headers):
* lisp/gnus/gnus-int.el (gnus-start-news-server):
* lisp/gnus/gnus-registry.el:
(gnus-registry--split-fancy-with-parent-internal):
* lisp/gnus/gnus-score.el (gnus-summary-increase-score):
* lisp/gnus/gnus-start.el (gnus-convert-old-newsrc):
* lisp/gnus/gnus-topic.el (gnus-topic-rename):
* lisp/gnus/legacy-gnus-agent.el (gnus-agent-unlist-expire-days):
* lisp/gnus/nnmairix.el (nnmairix-widget-create-query):
* lisp/gnus/spam.el (spam-check-blackholes):
* lisp/mail/feedmail.el (feedmail-run-the-queue):
* lisp/mpc.el (mpc-playlist-rename):
* lisp/net/ange-ftp.el (ange-ftp-shell-command):
* lisp/net/mairix.el (mairix-widget-create-query):
* lisp/net/tramp-cache.el:
* lisp/obsolete/otodo-mode.el (todo-more-important-p):
* lisp/obsolete/pgg-gpg.el (pgg-gpg-process-region):
* lisp/obsolete/pgg-pgp.el (pgg-pgp-process-region):
* lisp/obsolete/pgg-pgp5.el (pgg-pgp5-process-region):
* lisp/org/ob-core.el (org-babel-goto-named-src-block)
(org-babel-goto-named-result):
* lisp/org/ob-fortran.el (org-babel-fortran-ensure-main-wrap):
* lisp/org/ob-ref.el (org-babel-ref-resolve):
* lisp/org/org-agenda.el (org-agenda-prepare):
* lisp/org/org-bibtex.el (org-bibtex-fields):
* lisp/org/org-clock.el (org-clock-notify-once-if-expired)
(org-clock-resolve):
* lisp/org/org-feed.el (org-feed-parse-atom-entry):
* lisp/org/org-habit.el (org-habit-parse-todo):
* lisp/org/org-mouse.el (org-mouse-popup-global-menu)
(org-mouse-context-menu):
* lisp/org/org-table.el (org-table-edit-formulas):
* lisp/org/ox.el (org-export-async-start):
* lisp/play/dunnet.el (dun-score, dun-help, dun-endgame-question)
(dun-rooms, dun-endgame-questions):
* lisp/progmodes/ada-mode.el (ada-goto-matching-start):
* lisp/progmodes/ada-xref.el (ada-find-executable):
* lisp/progmodes/antlr-mode.el (antlr-options-alists):
* lisp/progmodes/flymake.el (flymake-parse-err-lines)
(flymake-start-syntax-check-process):
* lisp/progmodes/python.el (python-define-auxiliary-skeleton):
* lisp/progmodes/sql.el (sql-comint):
* lisp/progmodes/verilog-mode.el (verilog-load-file-at-point):
* lisp/server.el (server-get-auth-key):
* lisp/subr.el (version-to-list):
* lisp/textmodes/reftex-ref.el (reftex-label):
* lisp/textmodes/reftex-toc.el (reftex-toc-rename-label):
* lisp/vc/ediff-diff.el (ediff-same-contents):
* lisp/vc/vc-cvs.el (vc-cvs-mode-line-string):
* test/automated/tramp-tests.el (tramp-test33-asynchronous-requests):
Use directed rather than neutral quotes in diagnostics.
2015-08-24 23:39:33 -07:00
|
|
|
"Run `tla inventory' for DIR and pass results to CALLBACK.
|
2008-10-16 11:48:42 +00:00
|
|
|
CALLBACK expects (ENTRIES &optional MORE-TO-COME); see
|
|
|
|
`vc-dir-refresh'."
|
|
|
|
(let ((default-directory dir))
|
|
|
|
(vc-arch-command t 'async nil "changes"))
|
|
|
|
;; The updating could be done asynchronously.
|
* lisp/vc/vc-dispatcher.el (vc-run-delayed): New macro.
(vc-do-command, vc-set-async-update):
* lisp/vc/vc-mtn.el (vc-mtn-dir-status):
* lisp/vc/vc-hg.el (vc-hg-dir-status, vc-hg-dir-status-files)
(vc-hg-pull, vc-hg-merge-branch):
* lisp/vc/vc-git.el (vc-git-dir-status-goto-stage, vc-git-pull)
(vc-git-merge-branch):
* lisp/vc/vc-cvs.el (vc-cvs-print-log, vc-cvs-dir-status)
(vc-cvs-dir-status-files):
* lisp/vc/vc-bzr.el (vc-bzr-pull, vc-bzr-merge-branch, vc-bzr-dir-status)
(vc-bzr-dir-status-files):
* lisp/vc/vc-arch.el (vc-arch-dir-status): Use vc-run-delayed.
* lisp/vc/vc-annotate.el: Use lexical-binding.
(vc-annotate-display-select, vc-annotate): Use vc-run-delayed.
(vc-sentinel-movepoint): Declare.
(vc-annotate): Don't use `goto-line'.
* lisp/vc/vc.el (vc-diff-internal): Prefer a closure to `(lambda...).
(vc-diff-internal, vc-log-internal-common): Use vc-run-delayed.
(vc-sentinel-movepoint): Declare.
* lisp/vc/vc-svn.el: Use lexical-binding.
(vc-svn-dir-status, vc-svn-dir-status-files): Use vc-run-delayed.
* lisp/vc/vc-sccs.el:
* lisp/vc/vc-rcs.el: Use lexical-binding.
2013-09-04 17:09:42 -04:00
|
|
|
(vc-run-delayed
|
|
|
|
(vc-arch-after-dir-status callback)))
|
2008-10-16 11:48:42 +00:00
|
|
|
|
|
|
|
(defun vc-arch-after-dir-status (callback)
|
|
|
|
(let* ((state-map '(("M " . edited)
|
|
|
|
("Mb" . edited) ;binary
|
|
|
|
("D " . removed)
|
|
|
|
("D/" . removed) ;directory
|
|
|
|
("A " . added)
|
|
|
|
("A/" . added) ;directory
|
|
|
|
("=>" . renamed)
|
|
|
|
("/>" . renamed) ;directory
|
|
|
|
("lf" . symlink-to-file)
|
|
|
|
("fl" . file-to-symlink)
|
|
|
|
("--" . permissions-changed)
|
|
|
|
("-/" . permissions-changed) ;directory
|
|
|
|
))
|
|
|
|
(state-map-regexp (regexp-opt (mapcar 'car state-map) t))
|
|
|
|
(entry-regexp (concat "^" state-map-regexp " \\(.*\\)$"))
|
|
|
|
result)
|
|
|
|
(goto-char (point-min))
|
|
|
|
;;(message "Got %s" (buffer-string))
|
|
|
|
(while (re-search-forward entry-regexp nil t)
|
|
|
|
(let* ((state-string (match-string 1))
|
|
|
|
(state (cdr (assoc state-string state-map)))
|
|
|
|
(filename (match-string 2)))
|
|
|
|
(push (list filename state) result)))
|
|
|
|
|
|
|
|
(funcall callback result nil)))
|
|
|
|
|
2007-10-10 18:52:45 +00:00
|
|
|
(defun vc-arch-working-revision (file)
|
2004-03-15 03:39:09 +00:00
|
|
|
(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))
|
2012-02-25 12:29:09 +08:00
|
|
|
:group 'vc-arch)
|
2004-03-15 03:39:09 +00:00
|
|
|
|
|
|
|
(defun vc-arch-mode-line-string (file)
|
2012-06-02 18:56:09 +08:00
|
|
|
"Return a string for `vc-mode-line' to put in the mode line for FILE."
|
2007-10-10 18:52:45 +00:00
|
|
|
(let ((rev (vc-working-revision file)))
|
2004-03-15 03:39:09 +00:00
|
|
|
(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"
|
More CL cleanups and reduction of use of cl.el.
* woman.el, winner.el, vc/vc-rcs.el, vc/vc-hooks.el, vc/vc-hg.el:
* vc/vc-git.el, vc/vc-dir.el, vc/vc-bzr.el, vc/vc-annotate.el:
* textmodes/tex-mode.el, textmodes/sgml-mode.el, tar-mode.el:
* strokes.el, ses.el, server.el, progmodes/js.el, progmodes/gdb-mi.el:
* progmodes/flymake.el, progmodes/ebrowse.el, progmodes/compile.el:
* play/tetris.el, play/snake.el, play/pong.el, play/landmark.el:
* play/hanoi.el, play/decipher.el, play/5x5.el, nxml/nxml-mode.el:
* net/secrets.el, net/quickurl.el, midnight.el, mail/footnote.el:
* image-dired.el, ibuffer.el, ibuf-macs.el, ibuf-ext.el, hexl.el:
* eshell/eshell.el, eshell/esh-io.el, eshell/esh-ext.el:
* eshell/esh-cmd.el, eshell/em-ls.el, eshell/em-hist.el:
* eshell/em-cmpl.el, eshell/em-banner.el:
* url/url.el, url/url-queue.el, url/url-parse.el, url/url-http.el:
* url/url-future.el, url/url-dav.el, url/url-cookie.el:
* calendar/parse-time.el, test/eshell.el: Use cl-lib.
* wid-browse.el, wdired.el, vc/vc.el, vc/vc-mtn.el, vc/vc-cvs.el:
* vc/vc-arch.el, tree-widget.el, textmodes/texinfo.el:
* textmodes/refill.el, textmodes/css-mode.el, term/tvi970.el:
* term/ns-win.el, term.el, shell.el, ps-samp.el:
* progmodes/perl-mode.el, progmodes/pascal.el, progmodes/gud.el:
* progmodes/glasses.el, progmodes/etags.el, progmodes/cwarn.el:
* play/gamegrid.el, play/bubbles.el, novice.el, notifications.el:
* net/zeroconf.el, net/xesam.el, net/snmp-mode.el, net/mairix.el:
* net/ldap.el, net/eudc.el, net/browse-url.el, man.el:
* mail/mailheader.el, mail/feedmail.el:
* url/url-util.el, url/url-privacy.el, url/url-nfs.el, url/url-misc.el:
* url/url-methods.el, url/url-gw.el, url/url-file.el, url/url-expand.el:
Dont use CL.
* ibuf-ext.el (ibuffer-mark-old-buffers): Use float-time.
* eshell/esh-opt.el (eshell-eval-using-options): Quote code with
`lambda' rather than with `quote'.
(eshell-do-opt): Adjust accordingly.
(eshell-process-option): Simplify.
* eshell/esh-var.el:
* eshell/em-script.el: Require `esh-opt' for eshell-eval-using-options.
* emacs-pcase.el (pcase--dontcare-upats, pcase--let*)
(pcase--expand, pcase--u1): Rename pcase's internal `dontcare' pattern
to `pcase--dontcare'.
* emacs-cl.el (labels): Mark obsolete.
(cl--letf, letf): Move to cl-lib.
(cl--letf*, letf*): Remove.
* emacs-cl-lib.el (cl-nth-value): Use defalias.
* emacs-cl-macs.el (cl-dolist, cl-dotimes): Add indent rule.
(cl-progv): Rewrite.
(cl--letf, cl-letf): Move from cl.el.
(cl-letf*): New macro.
* emacs-cl-extra.el (cl--progv-before, cl--progv-after): Remove.
2012-07-11 19:13:41 -04:00
|
|
|
(pcase (vc-state file)
|
2018-11-05 01:22:15 +01:00
|
|
|
((or 'up-to-date 'needs-update) ?-)
|
|
|
|
('added ?@)
|
2015-06-16 20:04:35 -04:00
|
|
|
(_ ?:))
|
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)))
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
(and attrs (< (file-attribute-size attrs) 60)
|
2004-03-23 21:34:06 +00:00
|
|
|
(with-temp-buffer
|
|
|
|
(insert-file-contents rej)
|
|
|
|
(goto-char (point-min))
|
2011-11-19 18:29:42 -08:00
|
|
|
(looking-at "Conflicts occurred, 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))
|
2008-01-15 04:37:20 +00:00
|
|
|
(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))))))
|
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))
|
2008-01-16 06:22:59 +00:00
|
|
|
(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))))))
|
|
|
|
|
Silence some vc compilation warnings
* lisp/vc/vc-arch.el (vc-exec-after): Declare.
(vc-switches): Autoload.
* lisp/vc/vc-bzr.el: No need to require vc when compiling.
(vc-exec-after, vc-set-async-update, vc-default-dir-printer)
(vc-resynch-buffer, vc-dir-refresh): Declare.
(vc-setup-buffer, vc-switches): Autoload.
* lisp/vc/vc-dir.el (desktop-missing-file-warning): Declare.
* lisp/vc/vc-mtn.el (vc-exec-after): Declare.
(vc-switches): Autoload.
* lisp/vc/vc-rcs.el (vc-expand-dirs, vc-switches)
(vc-tag-precondition, vc-buffer-sync, vc-rename-master): Autoload.
(vc-file-tree-walk): Declare.
* lisp/vc/vc-svn.el (vc-exec-after): Declare.
(vc-switches, vc-setup-buffer): Autoload.
* lisp/obsolete/vc-mcvs.el (vc-checkout, vc-switches, vc-default-revert):
Autoload.
(vc-resynch-buffer): Declare.
2013-05-28 00:01:59 -07:00
|
|
|
(autoload 'vc-switches "vc")
|
|
|
|
|
Remove never-used rev argument from VC's backend checkin methods.
Alters vc/vc-arch.el, vc/vc-bzr.el, vc/vc-cvs.el, vc/vc-dav.el,
vc/vc-git.el, vc/vc-hg.el, vc/vc-mtn.el, vc/vc-rcs.el,
vc/vc-sccs.el, vc/vc-svn.el, vc/vc.el.
Only the RCS, SCCS, and CVS back ends tried to do anything with it,
and that code was never exercised. Chiseling away the cruft of
decades...
2014-11-20 02:37:06 -05:00
|
|
|
(defun vc-arch-checkin (files comment)
|
2007-07-18 16:32:40 +00:00
|
|
|
;; FIXME: This implementation probably only works for singleton filesets
|
2007-09-07 19:00:30 +00:00
|
|
|
(let ((summary (file-relative-name (car files) (vc-arch-root (car files)))))
|
2004-03-18 02:48:06 +00:00
|
|
|
;; 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))))
|
2007-07-18 16:32:40 +00:00
|
|
|
(vc-arch-command nil 0 files "commit" "-s" summary "-L" comment "--"
|
2004-03-18 02:48:06 +00:00
|
|
|
(vc-switches 'Arch 'checkin))))
|
2004-03-15 03:39:09 +00:00
|
|
|
|
2014-12-14 12:49:08 +02:00
|
|
|
(defun vc-arch-diff (files &optional oldvers newvers buffer async)
|
2007-07-18 16:32:40 +00:00
|
|
|
"Get a difference report using Arch between two versions of FILES."
|
2007-07-20 20:02:32 +00:00
|
|
|
;; 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)
|
2007-10-10 18:52:45 +00:00
|
|
|
(equal newvers (vc-working-revision file)))
|
2007-07-20 20:02:32 +00:00
|
|
|
;; 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")
|
2009-08-25 08:49:24 +00:00
|
|
|
(let* (process-file-side-effects
|
2007-07-20 20:02:32 +00:00
|
|
|
;; 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"
|
2008-12-03 07:35:14 +00:00
|
|
|
(vc-switches 'Arch 'diff)
|
2007-07-20 20:02:32 +00:00
|
|
|
(file-relative-name file)
|
2007-10-10 18:52:45 +00:00
|
|
|
(if (equal oldvers (vc-working-revision file))
|
2007-07-20 20:02:32 +00:00
|
|
|
nil
|
|
|
|
oldvers))))
|
|
|
|
(if async 1 status))))) ; async diff, pessimistic assumption.
|
2004-03-15 03:39:09 +00:00
|
|
|
|
|
|
|
(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."
|
2008-11-22 03:30:22 +00:00
|
|
|
(apply 'vc-do-command (or buffer "*vc*") okstatus vc-arch-program file flags))
|
2004-03-15 03:39:09 +00:00
|
|
|
|
2007-06-26 17:59:52 +00:00
|
|
|
;;; Completion of versions and revisions.
|
|
|
|
|
|
|
|
(defun vc-arch--version-completion-table (root string)
|
|
|
|
(delq nil
|
|
|
|
(mapcar
|
|
|
|
(lambda (d)
|
|
|
|
(when (string-match "/\\([^/]+\\)/\\([^/]+\\)\\'" d)
|
|
|
|
(concat (match-string 2 d) "/" (match-string 1 d))))
|
|
|
|
(let ((default-directory root))
|
|
|
|
(file-expand-wildcards
|
|
|
|
(concat "*/*/"
|
|
|
|
(if (string-match "/" string)
|
|
|
|
(concat (substring string (match-end 0))
|
|
|
|
"*/" (substring string 0 (match-beginning 0)))
|
|
|
|
(concat "*/" string))
|
|
|
|
"*"))))))
|
|
|
|
|
2007-10-20 01:05:50 +00:00
|
|
|
(defun vc-arch-revision-completion-table (files)
|
2012-04-25 23:18:47 -04:00
|
|
|
(lambda (string pred action)
|
|
|
|
;; FIXME: complete revision patches as well.
|
|
|
|
(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))))
|
2007-06-26 17:59:52 +00:00
|
|
|
|
|
|
|
;;; Trimming revision libraries.
|
|
|
|
|
|
|
|
;; This code is not directly related to VC and there are many variants of
|
|
|
|
;; this functionality available as scripts, but I like this version better,
|
|
|
|
;; so maybe others will like it too.
|
|
|
|
|
|
|
|
(defun vc-arch-trim-find-least-useful-rev (revs)
|
|
|
|
(let* ((first (pop revs))
|
|
|
|
(second (pop revs))
|
|
|
|
(third (pop revs))
|
|
|
|
;; We try to give more importance to recent revisions. The idea is
|
|
|
|
;; that it's OK if checking out a revision 1000-patch-old is ten
|
|
|
|
;; times slower than checking out a revision 100-patch-old. But at
|
|
|
|
;; the same time a 2-patch-old rev isn't really ten times more
|
|
|
|
;; important than a 20-patch-old, so we use an arbitrary constant
|
|
|
|
;; "100" to reduce this effect for recent revisions. Making this
|
|
|
|
;; constant a float has the side effect of causing the subsequent
|
|
|
|
;; computations to be done as floats as well.
|
|
|
|
(max (+ 100.0 (car (or (car (last revs)) third))))
|
|
|
|
(cost (lambda () (/ (- (car third) (car first)) (- max (car second)))))
|
|
|
|
(minrev second)
|
|
|
|
(mincost (funcall cost)))
|
|
|
|
(while revs
|
|
|
|
(setq first second)
|
|
|
|
(setq second third)
|
|
|
|
(setq third (pop revs))
|
|
|
|
(when (< (funcall cost) mincost)
|
|
|
|
(setq minrev second)
|
|
|
|
(setq mincost (funcall cost))))
|
|
|
|
minrev))
|
|
|
|
|
|
|
|
(defun vc-arch-trim-make-sentinel (revs)
|
2012-04-25 23:18:47 -04:00
|
|
|
(if (null revs) (lambda (_proc _msg) (message "VC-Arch trimming ... done"))
|
|
|
|
(lambda (_proc _msg)
|
|
|
|
(message "VC-Arch trimming %s..." (file-name-nondirectory (car revs)))
|
|
|
|
(rename-file (car revs) (concat (car revs) "*rm*"))
|
|
|
|
(let ((proc (start-process "vc-arch-trim" nil
|
|
|
|
"rm" "-rf" (concat (car revs) "*rm*"))))
|
2008-07-22 17:16:52 +00:00
|
|
|
(set-process-sentinel proc (vc-arch-trim-make-sentinel (cdr revs)))))))
|
2007-06-26 17:59:52 +00:00
|
|
|
|
|
|
|
(defun vc-arch-trim-one-revlib (dir)
|
|
|
|
"Delete half of the revisions in the revision library."
|
|
|
|
(interactive "Ddirectory: ")
|
2008-07-22 17:16:52 +00:00
|
|
|
(let ((garbage (directory-files dir 'full "\\`,," 'nosort)))
|
|
|
|
(when garbage
|
|
|
|
(funcall (vc-arch-trim-make-sentinel garbage) nil nil)))
|
2007-06-26 17:59:52 +00:00
|
|
|
(let ((revs
|
|
|
|
(sort (delq nil
|
|
|
|
(mapcar
|
|
|
|
(lambda (f)
|
|
|
|
(when (string-match "-\\([0-9]+\\)\\'" f)
|
|
|
|
(cons (string-to-number (match-string 1 f)) f)))
|
|
|
|
(directory-files dir nil nil 'nosort)))
|
|
|
|
'car-less-than-car))
|
|
|
|
(subdirs nil))
|
|
|
|
(when (cddr revs)
|
2012-04-25 23:18:47 -04:00
|
|
|
(dotimes (_i (/ (length revs) 2))
|
2007-06-26 17:59:52 +00:00
|
|
|
(let ((minrev (vc-arch-trim-find-least-useful-rev revs)))
|
|
|
|
(setq revs (delq minrev revs))
|
|
|
|
(push minrev subdirs)))
|
|
|
|
(funcall (vc-arch-trim-make-sentinel
|
|
|
|
(mapcar (lambda (x) (expand-file-name (cdr x) dir)) subdirs))
|
|
|
|
nil nil))))
|
|
|
|
|
|
|
|
(defun vc-arch-trim-revlib ()
|
|
|
|
"Delete half of the revisions in the revision library."
|
|
|
|
(interactive)
|
|
|
|
(let ((rl-dir (with-output-to-string
|
2008-11-22 03:30:22 +00:00
|
|
|
(call-process vc-arch-program nil standard-output nil
|
2007-06-26 17:59:52 +00:00
|
|
|
"my-revision-library"))))
|
|
|
|
(while (string-match "\\(.*\\)\n" rl-dir)
|
|
|
|
(let ((dir (match-string 1 rl-dir)))
|
|
|
|
(setq rl-dir
|
|
|
|
(if (and (file-directory-p dir) (file-writable-p dir))
|
|
|
|
dir
|
|
|
|
(substring rl-dir (match-end 0))))))
|
|
|
|
(unless (file-writable-p rl-dir)
|
|
|
|
(error "No writable revlib directory found"))
|
|
|
|
(message "Revlib at %s" rl-dir)
|
|
|
|
(let* ((archives (directory-files rl-dir 'full "[^.]\\|..."))
|
|
|
|
(categories
|
|
|
|
(apply 'append
|
|
|
|
(mapcar (lambda (dir)
|
|
|
|
(when (file-directory-p dir)
|
|
|
|
(directory-files dir 'full "[^.]\\|...")))
|
|
|
|
archives)))
|
|
|
|
(branches
|
|
|
|
(apply 'append
|
|
|
|
(mapcar (lambda (dir)
|
|
|
|
(when (file-directory-p dir)
|
|
|
|
(directory-files dir 'full "[^.]\\|...")))
|
|
|
|
categories)))
|
|
|
|
(versions
|
|
|
|
(apply 'append
|
|
|
|
(mapcar (lambda (dir)
|
|
|
|
(when (file-directory-p dir)
|
|
|
|
(directory-files dir 'full "--.*--")))
|
|
|
|
branches))))
|
|
|
|
(mapc 'vc-arch-trim-one-revlib versions))
|
|
|
|
))
|
2007-08-21 15:18:06 +00:00
|
|
|
|
|
|
|
(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)
|
2008-11-22 03:30:22 +00:00
|
|
|
|
2007-08-21 15:18:06 +00:00
|
|
|
|
2006-12-27 16:26:34 +00:00
|
|
|
;;; Less obvious implementations.
|
|
|
|
|
2007-10-10 18:52:45 +00:00
|
|
|
(defun vc-arch-find-revision (file rev buffer)
|
2006-12-27 16:26:34 +00:00
|
|
|
(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)
|
|
|
|
|
|
|
|
;;; vc-arch.el ends here
|