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

Contents of /meta-cvs/F-BE2DE9340254D8E8E6E2649A55D3A742

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations)
Mon Nov 4 02:09:17 2002 UTC (11 years, 5 months ago) by kaz
Branch: MAIN
Changes since 1.7: +26 -19 lines
Merging from mcvs-1-0-branch.
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 (require "system")
6 (require "mcvs-package")
7 (provide "sync")
8
9 (in-package "META-CVS")
10
11 (defun synchronize-files (left-file right-file should-be-executable)
12 "Ensure that the two files have the same contents, using any means,
13 including the possibility of making them hard links to the same object.
14 If they are already the same object, nothing happens and the symbol
15 :same is returned. Otherwise the newer one prevails, and clobbers the older
16 one; the symbols :left or :right are returned to indicate which prevailed. If
17 one of them doesn't exist, then it is created. If neither exists, nothing
18 happens, and NIL is returned. If either file is actually a directory,
19 :dir is returned"
20 (flet ((exec-check (file-info)
21 (if should-be-executable
22 (make-executable file-info)
23 (make-non-executable file-info))))
24 (let ((left (exists left-file))
25 (right (exists right-file)))
26 (cond
27 ((not (or left right))
28 nil)
29 ((or (directory-p left) (directory-p right))
30 :dir)
31 ((not right)
32 (honor-dry-run (left-file right-file)
33 (ensure-directories-exist right-file)
34 (link left-file right-file)
35 (exec-check left-file))
36 :left)
37 ((not left)
38 (honor-dry-run (left-file right-file)
39 (ensure-directories-exist left-file)
40 (link right-file left-file)
41 (exec-check right-file))
42 :right)
43 ((same-file-p right left)
44 (honor-dry-run (right-file)
45 (exec-check right-file))
46 :same)
47 ((older-p left right)
48 (honor-dry-run (left-file right-file)
49 (unlink left-file)
50 (link right-file left-file)
51 (exec-check right-file))
52 :right)
53 ((older-p right left)
54 (honor-dry-run (left-file right-file)
55 (unlink right-file)
56 (link left-file right-file)
57 (exec-check left-file))
58 :left)
59 (t
60 (restart-case
61 (error "~a and ~a have the same modification time."
62 left-file right-file)
63 (:choose-left () :report (lambda (s)
64 (format s "take ~a; clobber ~a."
65 left-file right-file))
66 (honor-dry-run (left-file right-file)
67 (unlink right-file)
68 (link left-file right-file)
69 (exec-check left-file))
70 :left)
71 (:choose-right () :report (lambda (s)
72 (format s "take ~a; clobber ~a."
73 right-file left-file))
74 (honor-dry-run (left-file right-file)
75 (unlink left-file)
76 (link right-file left-file)
77 (exec-check right-file))
78 :right)))))))

  ViewVC Help
Powered by ViewVC 1.1.5