ViewVC logotype

Contents of /meta-cvs/F-BE2DE9340254D8E8E6E2649A55D3A742

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.10 - (hide annotations)
Sun Apr 13 14:39:12 2003 UTC (11 years ago) by kaz
Branch: MAIN
Changes since 1.9: +35 -19 lines
Merging from mcvs-1-0-branch.

* code/mapping.lisp (mapping-read): Provide a restart for
file errors, which lets the user interactively substitute an
empty map if the file can't be read. This is intended to handle
the case when MCVS/MAP is missing; for example, the user
updated to a sticky date for which no revision of the MAP
exists. The effect of continuing will be that all files
will disappear.
(mapping-synchronize): New :direction key
parameter, passed down to synchronize-filed. The new :no-sync
return value from synchronize-files is handled.
(mapping-update): Select the :right direction for synchronizing
moves, adds or rollbacks.

Revamped the synchronization logic. Synchronization now happens
in a specific direction.  For example, if we are doing a diff,
we just need to push changes from the tree to the MCVS directory,
not the other way around. Or: before an update or commit, we push from
the tree to MCVS, then after the update, in the other direction.

* code/update.lisp (mcvs-update): The before update is done
in the :left direction only, and the after update in the :right.

* code/move.lisp (mcvs-move): The just-in-case sync is done
in the :left direction only.

* code/link.lisp (mcvs-link): Likewise.

* code/remove.lisp (mcvs-remove): Likewise.

* code/add.lisp (mcvs-add): Get rid of mapping-synchronize call;
it's completely unnecessary, since the new files are not even
in the MAP-LOCAL, and the add logic explicitly links them into
the MCVS directory.

* code/generic.lisp (mcvs-generic): New keyword parameter,
need-sync-before. Before-synchronization done in :left direction,
after-synchronization in :right direction. Before-synchronization
is now not done by default; need-sync-before must be specified.
(mcvs-commit-wrapper): Specify before and after sync.
(mcvs-diff-wrapper, mcvs-status-wrapper,
mcvs-edit-wrapper): Explicitly specify before sync.
(mcvs-tag-wrapper, mcvs-annotate-wrapper): Implicitly specify no sync.
(mcvs-unedit-wrapper): Add before sync.

* code/sync.lisp (synchronize-files):  New key parameter :direction,
values can be :left, :right or :either. Default is :either.
If the value is :left or :right, then a sync is done only in that
direction, otherwise the value :no-sync is returned.
Behavior change: if the left file is missing (F- file in MCVS
directory) it is not re-created, but rather :no-sync is returned.
Also, if both files exist, have the same timestamp, and are
distinct objects, if the direction is :left or :right, then
the appropriate restart is automatically chosen. So this will
do the right thing on filesystems where link() is performed by
copying, without bothering the user with the error.
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
5 kaz 1.1 (require "system")
6 kaz 1.7 (require "mcvs-package")
7 kaz 1.1 (provide "sync")
8 kaz 1.7
9     (in-package "META-CVS")
10 kaz 1.1
11 kaz 1.10 (defun synchronize-files (left-file right-file should-be-executable
12     &key (direction :either))
13 kaz 1.1 "Ensure that the two files have the same contents, using any means,
14     including the possibility of making them hard links to the same object.
15     If they are already the same object, nothing happens and the symbol
16     :same is returned. Otherwise the newer one prevails, and clobbers the older
17     one; the symbols :left or :right are returned to indicate which prevailed. If
18     one of them doesn't exist, then it is created. If neither exists, nothing
19 kaz 1.4 happens, and NIL is returned. If either file is actually a directory,
20     :dir is returned"
21 kaz 1.6 (flet ((exec-check (file-info)
22     (if should-be-executable
23     (make-executable file-info)
24     (make-non-executable file-info))))
25     (let ((left (exists left-file))
26     (right (exists right-file)))
27     (cond
28     ((not (or left right))
29     nil)
30     ((or (directory-p left) (directory-p right))
31     :dir)
32     ((not right)
33 kaz 1.8 (honor-dry-run (left-file right-file)
34 kaz 1.10 (exec-check left)
35     (or (unless (eq direction :left)
36     (ensure-directories-exist right-file)
37     (link left-file right-file)
38     :left)
39     :no-sync)))
40 kaz 1.6 ((not left)
41 kaz 1.8 (honor-dry-run (left-file right-file)
42 kaz 1.10 (exec-check right)
43     ;; Special case: do not re-create files missing in
44     ;; CVS sandbox! Either someone tampered with the sandbox,
45     ;; in which case we just let CVS resurrect the file,
46     ;; and a subsequent sync will properly have the clean-copy
47     ;; semantics, propagating the clean copy to the tree.
48     ;; Or else CVS itself made the file disappear, in which
49     ;; case if we restore it, CVS will later complain that the file
50     ;; is ``in the way''!
51     :no-sync))
52 kaz 1.6 ((same-file-p right left)
53 kaz 1.8 (honor-dry-run (right-file)
54 kaz 1.9 (exec-check right))
55 kaz 1.6 :same)
56     ((older-p left right)
57 kaz 1.8 (honor-dry-run (left-file right-file)
58 kaz 1.10 (exec-check right)
59     (or (unless (eq direction :right)
60     (unlink left-file)
61     (link right-file left-file)
62     :right)
63     :no-sync)))
64 kaz 1.6 ((older-p right left)
65 kaz 1.8 (honor-dry-run (left-file right-file)
66 kaz 1.10 (exec-check left)
67     (or (unless (eq direction :left)
68     (unlink right-file)
69     (link left-file right-file)
70     :left)
71     :no-sync)))
72 kaz 1.6 (t
73     (restart-case
74 kaz 1.10 (ecase direction
75     ((:right) (invoke-restart :choose-left))
76     ((:left) (invoke-restart :choose-right))
77     ((:either) (error "~a and ~a have the same modification time."
78     left-file right-file)))
79 kaz 1.6 (:choose-left () :report (lambda (s)
80     (format s "take ~a; clobber ~a."
81     left-file right-file))
82 kaz 1.8 (honor-dry-run (left-file right-file)
83     (unlink right-file)
84     (link left-file right-file)
85 kaz 1.9 (exec-check left))
86 kaz 1.6 :left)
87     (:choose-right () :report (lambda (s)
88     (format s "take ~a; clobber ~a."
89     right-file left-file))
90 kaz 1.8 (honor-dry-run (left-file right-file)
91     (unlink left-file)
92     (link right-file left-file)
93 kaz 1.9 (exec-check right))
94 kaz 1.6 :right)))))))

  ViewVC Help
Powered by ViewVC 1.1.5