/[meta-cvs]/meta-cvs/F-03920784C6CF416F52879781889C107B
ViewVC logotype

Contents of /meta-cvs/F-03920784C6CF416F52879781889C107B

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Sat Mar 8 02:20:31 2008 UTC (6 years, 1 month ago) by kaz
Branch: MAIN
CVS Tags: mcvs-1-1-98, HEAD
* SCRIPTING: New file.
1 Scripting in Meta-CVS
2
3 The -i and -x options can be used to do some useful things. They allows the
4 users of Meta-CVS to write arbitrary scripts which make direct calls to the
5 Meta-CVS internals, taking advantage of its functions and macros.
6
7 Scripts are read and evaluated in the META-CVS package, and so may conveniently
8 make unqualified references to the software's internal symbols.
9
10 After scripts are evaluated, Meta-CVS still dispatches a command, if one was
11 specified.
12
13
14 Example 1.
15
16 Here is a script which lists all of the files which have an :EXEC property;
17 i.e. are executable:
18
19 (in-sandbox-root-dir
20 (let ((map (mapping-read *map-path*)))
21 (dolist (entry map)
22 (with-slots (raw-plist path) entry
23 (when (getf raw-plist :exec)
24 (princ path) (terpri))))))
25
26 If this is stored in a file called print-exec, then
27
28 mcvs -i print-exec
29
30 will run it.
31
32
33 Example 2.
34
35 Script to make an archive of files tagged with :ARCHIVE property,
36 using GNU tar:
37
38 (in-sandbox-root-dir
39 (let* ((map (mapping-read *map-path*))
40 (paths (loop for entry in map
41 when (getf (slot-value entry 'raw-plist) :archive)
42 collect (slot-value entry 'path))))
43 (execute-program `("tar" "czf" "foo.tar.gz" ,@paths))))
44
45
46 But this contains a bug! More than one, in fact!
47
48 It, or rather tar, fails when the paths list is empty. But let's
49 regard that as a feature.
50
51 More importantly, it will not work in partial sandboxes, because it will feed
52 GNU tar the abstract paths from the mapping file, rather than the real paths.
53
54 In a partial sandbox, some, or even all of these files might not be
55 visible, since they are in sibling or parent parts of the tree, outside
56 of the subtree that was checked out.
57
58 So, for each abstract path, a test must be applied whether it is in fact
59 mapped into the sandbox. And if so, the path must be translated.
60
61 Meta-CVS has functions for dealing with this: REAL-PATH-EXISTS,
62 ABSTRACT-TO-REAL-PATH and REAL-TO-ABSTRACT-PATH. They only work within
63 the dynamic contour of an IN-SANDBOX-ROOT-DIR form.
64
65 (in-sandbox-root-dir
66 (let* ((map (mapping-read *map-path*))
67 (paths (loop for entry in map
68 when
69 (getf (slot-value entry 'raw-plist) :archive)
70 when
71 (real-path-exists (slot-value entry 'path))
72 collect (abstract-to-real-path
73 (slot-value entry 'path)))))
74 (execute-program `("tar" "czf" "foo.tar.gz" ,@paths))))
75
76

  ViewVC Help
Powered by ViewVC 1.1.5