/[meta-cvs]/meta-cvs/F-BE2DE9340254D8E8E6E2649A55D3A742
ViewVC logotype

Contents of /meta-cvs/F-BE2DE9340254D8E8E6E2649A55D3A742

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (show annotations)
Fri Nov 24 04:53:50 2006 UTC (7 years, 4 months ago) by kaz
Branch: MAIN
CVS Tags: asdf-import-branch~merged-to-HEAD-0, mcvs-1-1-98, asdf-import-branch~branch-point, HEAD
Branch point for: asdf-import-branch
Changes since 1.11: +1 -1 lines
Stylistic change.

* code/add.lisp: Change in-package calls not to use the all-caps
"META-CVS" string string, but rather the :meta-cvs keyword.
* code/branch.lisp: Likewise.
* code/chatter.lisp: Likewise.
* code/checkout.lisp: Likewise.
* code/clisp-unix.lisp: Likewise.
* code/cmucl-unix.lisp: Likewise.
* code/convert.lisp: Likewise.
* code/create.lisp: Likewise.
* code/dirwalk.lisp: Likewise.
* code/error.lisp: Likewise.
* code/execute.lisp: Likewise.
* code/filt.lisp: Likewise.
* code/find-bind.lisp: Likewise.
* code/generic.lisp: Likewise.
* code/grab.lisp: Likewise.
* code/link.lisp: Likewise.
* code/main.lisp: Likewise.
* code/mapping.lisp: Likewise.
* code/memoize.lisp: Likewise.
* code/move.lisp: Likewise.
* code/multi-hash.lisp: Likewise.
* code/options.lisp: Likewise.
* code/paths.lisp: Likewise.
* code/print.lisp: Likewise.
* code/prop.lisp: Likewise.
* code/purge.lisp: Likewise.
* code/rcs-utils.lisp: Likewise.
* code/remap.lisp: Likewise.
* code/remove.lisp: Likewise.
* code/restart.lisp: Likewise.
* code/restore.lisp: Likewise.
* code/seqfuncs.lisp: Likewise.
* code/slot-refs.lisp: Likewise.
* code/split.lisp: Likewise.
* code/sync.lisp: Likewise.
* code/types.lisp: Likewise.
* code/unix.lisp: Likewise.
* code/update.lisp: Likewise.
* code/watch.lisp: Likewise.
1 ;;; This source file is part of the Meta-CVS program,
2 ;;; which is distributed under the GNU license.
3 ;;; Copyright 2002 Kaz Kylheku
4
5 (in-package :meta-cvs)
6
7 (defun synchronize-files (left-file right-file should-be-executable
8 &key (direction :either))
9 "Ensure that the two files have the same contents, using any means,
10 including the possibility of making them hard links to the same object.
11 If they are already the same object, nothing happens and the symbol
12 :same is returned. Otherwise the newer one prevails, and clobbers the older
13 one; the symbols :left or :right are returned to indicate which prevailed. If
14 one of them doesn't exist, then it is created. If neither exists, nothing
15 happens, and NIL is returned. If either file is actually a directory,
16 :dir is returned"
17 (flet ((exec-check (file-info)
18 (if should-be-executable
19 (make-executable file-info)
20 (make-non-executable file-info))))
21 (let ((left (exists left-file))
22 (right (exists right-file)))
23 (cond
24 ((not (or left right))
25 nil)
26 ((or (directory-p left) (directory-p right))
27 :dir)
28 ((not right)
29 (honor-dry-run (left-file right-file)
30 (exec-check left)
31 (or (unless (eq direction :left)
32 (ensure-directories-exist right-file)
33 (link left-file right-file)
34 :left)
35 :no-sync)))
36 ((not left)
37 (honor-dry-run (left-file right-file)
38 (exec-check right)
39 ;; Special case: do not re-create files missing in
40 ;; CVS sandbox! Either someone tampered with the sandbox,
41 ;; in which case we just let CVS resurrect the file,
42 ;; and a subsequent sync will properly have the clean-copy
43 ;; semantics, propagating the clean copy to the tree.
44 ;; Or else CVS itself made the file disappear, in which
45 ;; case if we restore it, CVS will later complain that the file
46 ;; is ``in the way''!
47 :no-sync))
48 ((same-file-p right left)
49 (honor-dry-run (right-file)
50 (exec-check right))
51 :same)
52 ((older-p left right)
53 (honor-dry-run (left-file right-file)
54 (exec-check right)
55 (or (unless (eq direction :right)
56 (unlink left-file)
57 (link right-file left-file)
58 :right)
59 :no-sync)))
60 ((older-p right left)
61 (honor-dry-run (left-file right-file)
62 (exec-check left)
63 (or (unless (eq direction :left)
64 (unlink right-file)
65 (link left-file right-file)
66 :left)
67 :no-sync)))
68 (t
69 (restart-case
70 (ecase direction
71 ((:right) (invoke-restart :choose-left))
72 ((:left) (invoke-restart :choose-right))
73 ((:either) (error "~a and ~a have the same modification time."
74 left-file right-file)))
75 (:choose-left () :report (lambda (s)
76 (format s "take ~a; clobber ~a."
77 left-file right-file))
78 (honor-dry-run (left-file right-file)
79 (unlink right-file)
80 (link left-file right-file)
81 (exec-check left))
82 :left)
83 (:choose-right () :report (lambda (s)
84 (format s "take ~a; clobber ~a."
85 right-file left-file))
86 (honor-dry-run (left-file right-file)
87 (unlink left-file)
88 (link right-file left-file)
89 (exec-check right))
90 :right)))))))

  ViewVC Help
Powered by ViewVC 1.1.5