/[meta-cvs]/meta-cvs/F-5E30677BF94A6FA7AD45BAA270984CFA.lisp
ViewVC logotype

Contents of /meta-cvs/F-5E30677BF94A6FA7AD45BAA270984CFA.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations)
Tue Nov 28 07:47:22 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.9: +3 -3 lines
More renaming to get rid of mcvs- prefix.

* code/chatter.lisp (*mcvs-debug*): Renamed to *chatter-debug*.
(*mcvs-info*, *mcvs-terse*, *mcvs-silent*): Similarly.
(*mcvs-chatter-level*): Renamed to *chatter-level*.

* code/unix.lisp (*mcvs-editor*): Renamed to *edit-program*.

* code/types.lisp (*mcvs-types-name*): Renamed to *types-file*.
(*mcvs-types*): Renamed to *types-path*.
(*mcvs-new-types*): Renamed to *types-new-path*.

* code/mapping.lisp (*mcvs-dir*): Renamed to *admin-dir*.
(*mcvs-map-name*): Renamed to *map-file*.
(*mcvs-map-local-name*): Renamed to *map-local-file*.
(*mcvs-displaced-name*): Renamed to *displaced-file*.
(*mcvs-map*): Renamed to *map-path*.
(*mcvs-map-local*): Renamed to *map-local-path*.
(*mcvs-displaced*): Renamed to *displaced-path*.
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 ln (target name)
8 (when (or (string= "" target)
9 (string= "" name))
10 (error "empty path names are invalid."))
11 (in-sandbox-root-dir
12 (let* ((mapping (mapping-read *map-path*))
13 (real-name (sandbox-translate-path name))
14 (abs-name (real-to-abstract-path real-name))
15 (trailing-slash (string= (char name (1- (length name))) *path-sep*))
16 (file-info (no-existence-error (stat real-name)))
17 (in-map (mapping-lookup mapping abs-name))
18 (prefix-in-map (mapping-prefix-lookup mapping abs-name))
19 (is-non-dir (or in-map (and file-info (not (directory-p file-info)))))
20 (is-dir (and (not is-non-dir)
21 (or prefix-in-map (directory-p file-info) trailing-slash)))
22 (need-new-entry t))
23 (when (path-prefix-equal *admin-dir* abs-name)
24 (error "path ~a is in a reserved Meta-CVS area." abs-name))
25
26 ;; In case a link clobbers some object that has local edits,
27 ;; we need to synchronize it to the MCVS directory.
28 (chatter-debug "Synchronizing.~%")
29 (mapping-synchronize :direction :left)
30
31 (flet ((edit-map (entry)
32 (with-slots (path kind (tgt target)) entry
33 (chatter-debug "Clobbering existing object ~a.~%" path)
34 (unlink (abstract-to-real-path path))
35 (cond
36 ((eq kind :symlink)
37 (chatter-debug "Editing existing link.~%")
38 (setf tgt target)
39 (setf need-new-entry nil)
40 (symlink target (abstract-to-real-path path)))
41 (t (setf mapping
42 (remove entry mapping
43 :test #'eq))))))
44 (make-new-entry (abs-name)
45 (when need-new-entry
46 (chatter-debug "Making new symlink entry ~a.~%" abs-name)
47 (push (make-mapping-entry :kind :symlink
48 :id (mapping-generate-id :no-dir t :prefix "S-")
49 :path abs-name
50 :target target)
51 mapping))))
52
53 (cond
54 (in-map
55 (edit-map in-map)
56 (make-new-entry abs-name))
57 (is-dir
58 (let* ((base (basename target))
59 (real-name (canonicalize-path (path-cat real-name base)))
60 (abs-name (canonicalize-path (path-cat abs-name base)))
61 (name (path-cat name base))
62 (file-info (no-existence-error (stat real-name)))
63 (in-map (mapping-lookup mapping abs-name))
64 (prefix-in-map (mapping-prefix-lookup mapping abs-name))
65 (is-non-dir (or in-map (and file-info (not (directory-p file-info)))))
66 (is-dir (and (not is-non-dir)
67 (or prefix-in-map (directory-p file-info)))))
68 (when is-dir
69 (error "~a is a directory." name))
70 (when in-map
71 (edit-map in-map))
72 (make-new-entry abs-name)))
73 (t (make-new-entry abs-name))))
74 (mapping-write mapping *map-path* :sort-map t)
75 (chatter-debug "Updating file structure.~%")
76 (mapping-update)))
77 (values))
78
79 (defun link-wrapper (global-options command-options args)
80 (declare (ignore global-options command-options))
81 (when (/= (length args) 2)
82 (error "specify link target and link name."))
83 (ln (first args) (second args)))
84
85 (defconstant *link-help*
86 "Syntax:
87
88 mcvs link target-path name
89
90 Semantics:
91
92 Create a symbolic link with the given name, containing the target path.
93 Note the braindamaged reverse syntax, which is deliberately consistent
94 with the Unix ``ln'' command. To make the symbolic link @foo -> bar,
95 use ``mcvs ln bar foo''.
96
97 Another way to add links is to create a symlink, and then use the add
98 command.")

  ViewVC Help
Powered by ViewVC 1.1.5