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

Contents of /meta-cvs/F-BE2DE9340254D8E8E6E2649A55D3A742

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6.2.2 - (hide annotations)
Tue Dec 3 08:04:58 2002 UTC (11 years, 4 months ago) by kaz
Branch: mcvs-1-0-branch
CVS Tags: mcvs-1-0, mcvs-1-0-5, mcvs-1-0-4, mcvs-1-0-1, mcvs-1-0-2
Changes since 1.6.2.1: +7 -7 lines
* code/sync.lisp (synchronize-files): Call exec-check using
file info object, rather than file name. This cuts in half
the number of calls to stat().
1 kaz 1.3 ;;; This source file is part of the Meta-CVS program,
2 kaz 1.2 ;;; which is distributed under the GNU license.
3     ;;; Copyright 2002 Kaz Kylheku
4    
5 kaz 1.1 (require "system")
6     (provide "sync")
7    
8 kaz 1.6 (defun synchronize-files (left-file right-file should-be-executable)
9 kaz 1.1 "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 kaz 1.4 happens, and NIL is returned. If either file is actually a directory,
16     :dir is returned"
17 kaz 1.6 (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 kaz 1.6.2.1 (honor-dry-run (left-file right-file)
30     (ensure-directories-exist right-file)
31     (link left-file right-file)
32 kaz 1.6.2.2 (exec-check left))
33 kaz 1.6 :left)
34     ((not left)
35 kaz 1.6.2.1 (honor-dry-run (left-file right-file)
36     (ensure-directories-exist left-file)
37     (link right-file left-file)
38 kaz 1.6.2.2 (exec-check right))
39 kaz 1.6 :right)
40     ((same-file-p right left)
41 kaz 1.6.2.1 (honor-dry-run (right-file)
42 kaz 1.6.2.2 (exec-check right))
43 kaz 1.6 :same)
44     ((older-p left right)
45 kaz 1.6.2.1 (honor-dry-run (left-file right-file)
46     (unlink left-file)
47     (link right-file left-file)
48 kaz 1.6.2.2 (exec-check right))
49 kaz 1.6 :right)
50     ((older-p right left)
51 kaz 1.6.2.1 (honor-dry-run (left-file right-file)
52     (unlink right-file)
53     (link left-file right-file)
54 kaz 1.6.2.2 (exec-check left))
55 kaz 1.6 :left)
56     (t
57     (restart-case
58     (error "~a and ~a have the same modification time."
59     left-file right-file)
60     (:choose-left () :report (lambda (s)
61     (format s "take ~a; clobber ~a."
62     left-file right-file))
63 kaz 1.6.2.1 (honor-dry-run (left-file right-file)
64     (unlink right-file)
65     (link left-file right-file)
66 kaz 1.6.2.2 (exec-check left))
67 kaz 1.6 :left)
68     (:choose-right () :report (lambda (s)
69     (format s "take ~a; clobber ~a."
70     right-file left-file))
71 kaz 1.6.2.1 (honor-dry-run (left-file right-file)
72     (unlink left-file)
73     (link right-file left-file)
74 kaz 1.6.2.2 (exec-check right))
75 kaz 1.6 :right)))))))

  ViewVC Help
Powered by ViewVC 1.1.5