/[meta-cvs]/meta-cvs/F-9A67B1893CE1CF23455CD1EF0F486B65
ViewVC logotype

Diff of /meta-cvs/F-9A67B1893CE1CF23455CD1EF0F486B65

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by kaz, Sun Oct 6 05:25:31 2002 UTC revision 1.7.2.3 by kaz, Thu Jan 29 05:50:39 2004 UTC
# Line 11  Line 11 
11  (provide "convert")  (provide "convert")
12    
13  (defun remove-attic-component (path)  (defun remove-attic-component (path)
14    (let* ((split-path (split-fields path "/"))    (let* ((split-path (nreverse (split-fields path "/"))))
15           (len (length split-path)))      (when (string= (first split-path) "Attic")
16      (when (and (>= len 2) (string= (nth (- len 2) split-path) "Attic"))        (pop split-path))
17        (setf split-path (append (butlast (butlast split-path))      (reduce #'(lambda (x y) (format nil "~a/~a" x y)) (nreverse split-path))))
                                (last split-path))))  
     (reduce #'(lambda (x y) (format nil "~a/~a" x y)) split-path)))  
18    
19  (defun classify-tags (tags)  (defun classify-tags (tags)
20    (let (version-tags branch-tags)    (let (version-tags branch-tags)
# Line 40  Line 38 
38    
39    (let (filemap all-version-tags all-branch-tags)    (let (filemap all-version-tags all-branch-tags)
40      (current-dir-restore      (current-dir-restore
41          (chatter-info "descending into ~a~%" source-dir)
42        (chdir source-dir)        (chdir source-dir)
43        (for-each-file-info (fi ".")        (for-each-file-info (fi ".")
44            (when (and (directory-p fi)
45                       (path-equal (basename (file-name fi)) "CVS"))
46              (skip))
47          (when (regular-p fi)          (when (regular-p fi)
48            (let ((canon-name (canonicalize-path (file-name fi))))            (let ((canon-name (canonicalize-path (file-name fi))))
49              (multiple-value-bind (suffix v-suffix-free-name)              (multiple-value-bind (suffix basename dir)
50                                   (suffix canon-name #\,)                                   (suffix canon-name #\,)
51                (when (and suffix (string= suffix "v"))                (when (and suffix (string= suffix "v"))
52                  (let ((attic-free-name                  (let* ((dir (or dir "."))
53                          (remove-attic-component v-suffix-free-name))                         (no-attic-dir (remove-attic-component dir))
54                        (f-name (mapping-generate-id :suffix (suffix v-suffix-free-name)                         (no-attic-suffix-name
55                                                     :no-dir t)))                           (canonicalize-path (path-cat no-attic-dir basename)))
56                    (link canon-name (path-cat *up-dir*                         (f-name (mapping-generate-id :suffix (suffix basename)
57                                               target-dir                                                      :no-dir t))
58                                               (format nil "~A,v" f-name)))                         (rcs-name (path-cat *up-dir* target-dir
59                                               (format nil "~A,v" f-name))))
60                      (chatter-info "hard linking ~a -> ~a~%"
61                                    canon-name
62                                    rcs-name)
63                      (link canon-name rcs-name)
64                    (push (make-mapping-entry :kind :file                    (push (make-mapping-entry :kind :file
65                                              :id (path-cat *mcvs-dir* f-name)                                              :id (path-cat *mcvs-dir* f-name)
66                                              :path attic-free-name                                              :path no-attic-suffix-name
67                                              :executable (executable-p fi))                                              :executable (executable-p fi))
68                          filemap)                          filemap)
69                    (with-open-file (f (parse-posix-namestring canon-name)                    (with-open-file (f (parse-posix-namestring canon-name)
70                                       :direction :input)                                       :direction :input)
71                      (chatter-info "scanning ~a.~%" canon-name)                      (chatter-info "scanning ~a~%" canon-name)
72                      (let ((rcs-file (rcs-parse f)))                      (let ((rcs-file (rcs-parse f)))
73                        (multiple-value-bind (version-tags branch-tags)                        (multiple-value-bind (version-tags branch-tags)
74                                             (classify-tags (rcs-admin-symbols (rcs-file-admin rcs-file)))                                             (classify-tags (rcs-admin-symbols (rcs-file-admin rcs-file)))
# Line 73  Line 80 
80    
81      (current-dir-restore      (current-dir-restore
82        (chdir target-dir)        (chdir target-dir)
83        (chatter-info "Writing map.")        (chatter-info "writing ~a~%" *mcvs-map-name*)
84        (mapping-write filemap *mcvs-map-name*)        (mapping-write filemap *mcvs-map-name*)
85    
86        (execute-program `("ci" "-mMeta-CVS MAP file created by mcvs convert."        (execute-program `("ci" "-mMeta-CVS MAP file created by mcvs convert."
87                           "-t/dev/null" ,*mcvs-map-name*))                           "-t/dev/null" ,*mcvs-map-name*))
88        (execute-program `("chmod" "ug+rw" ,(format nil "~A,v" *mcvs-map-name*)))        (execute-program `("chmod" "ug+rw" ,(format nil "~A,v" *mcvs-map-name*)))
89    
90        (execute-program-xargs '("rcs")        (chatter-info "setting up version and branch tags in ~a~%" *mcvs-map-name*)
91                               (mapcar #'(lambda (tag)        (unless (null all-version-tags)
92                                           (format nil "-n~A:1.1" tag))          (execute-program-xargs '("rcs")
93                                       all-version-tags)                                 (mapcar #'(lambda (tag)
94                               (list *mcvs-map-name*))                                             (format nil "-n~A:1.1" tag))
95                                           all-version-tags)
96                                   (list *mcvs-map-name*)))
97    
98        (let ((branch-counter 0))        (let ((branch-counter 0))
99          (execute-program-xargs '("rcs")          (unless (null all-branch-tags)
100                                 (mapcar #'(lambda (tag)            (execute-program-xargs '("rcs")
101                                             (format nil                                   (mapcar #'(lambda (tag)
102                                                     "-n~A:1.1.0.~A"                                               (format nil
103                                                     tag (+ 2 branch-counter)))                                                       "-n~A:1.1.0.~A"
104                                         all-branch-tags)                                                       tag (incf branch-counter
105                                 (list *mcvs-map-name*))))))                                                                 2)))
106                                             all-branch-tags)
107                                     (list *mcvs-map-name*)))))))
108    
109  (defun mcvs-convert-wrapper (cvs-options cvs-command-options mcvs-args)  (defun mcvs-convert-wrapper (cvs-options cvs-command-options mcvs-args)
110    (declare (ignore cvs-options cvs-command-options))    (declare (ignore cvs-options cvs-command-options))
111    (if (/= (length mcvs-args) 2)    (if (/= (length mcvs-args) 2)
112      (error "specify cvs source dir and new target dir."))      (error "specify cvs source dir and new target dir."))
113    (mcvs-convert (first mcvs-args) (second mcvs-args)))    (mcvs-convert (first mcvs-args) (second mcvs-args)))
114    
115    (defconstant *convert-help*
116    "Syntax:
117    
118      mcvs convert source-cvs-module target-mcvs-module
119    
120    Options:
121    
122      None.
123    
124    Semantics:
125    
126      The convert command builds a Meta-CVS module directly out of the RCS files of
127      a CVS module.  It must be run in the root directory of a CVS repository.
128      It requires the chmod and rcs command line tools.
129    
130      The algorithm is extremely naive. A list of the pathnames of the RCS files
131      is collected, as the basis for creating the MAP file. The Attic directory
132      components are removed from these paths, and the ,v suffixes are stripped.
133    
134      The execute property of files is lifted from the permission bits on
135      the RCS files.
136    
137      The MAP,v file is created using the ``rcs ci'' command.
138    
139      The F- files are generated as hard links to the RCS files, to save space
140      and avoid the overhead of copying.
141    
142      All of the RCS files are scanned to find version and branch tags.  Quite
143      naively, the version tags are installed in the MAP file, all pointing to
144      revision 1.1. The branch tags are installed in MAP, pointing to revisions
145      1.1.0.2, 1.1.0.4, ...  This is a lame attempt to make it possible to check
146      out past baselines. But note that the contents of MAP don't vary: only a
147      single version node is generated with a fixed set of files. It is not taken
148      into consideration that some of the CVS files may be deleted in the head
149      revision or some branches.  Therefore, when the resulting Meta-CVS project is
150      checked out, or when past versions are retrieved, there may be complaints
151      from Meta-CVS about nonexistent files.
152    
153      The hard linking of the original RCS objects under F- names means that any
154      permission, ownership or time-stamp changes done in the CVS module will
155      affect the content of the Meta-CVS module and vice versa. Destructive
156      modifications to the file contents, ditto. Be careful!
157    
158      If the hard links make you nervous, do a deep copy of the module,
159      using ``cp -a source-dir target-dir''.
160    
161      Note that CVS does not destructively manipulate RCS files. A commit
162      or tagging operation creates a new RCS object which atomically replaces the
163      old hard link. This means that a commit to a file in the Meta-CVS module will
164      not affect the CVS module and vice versa.")

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.7.2.3

  ViewVC Help
Powered by ViewVC 1.1.5