* PSEUDOHOSTS: Overlay a file system at the end of a path in another file system New package, please look through it. * REGIONMANAGER: added RELCREATEPOSITION, allow for arguments to be spread If the WIDTH argument looks like a list of arguments, the arguments are spread out. Means that a relative region can be passed through intermediate functions. * EXAMINEDEFS: More control over regions and windows Examination windows are returned so that callers can manipulate them * TEDIT-PF-SEE: tf respects reader environment and bold faces of DEFUN and DEFMACRO names * COMPAREDIRECTORIES: refactored for more flexibility and easier maintenance Also, based on SPY, made more internal operations work on streams that are located and created once, rather than on file Added CDMERGE to merge CDVALUES for different subdirectories, to permit scrolling of all differences in a single browser window * COMPARESOURCES: Region for CS browser is passed through, window is returned Also tried to eliminate mismatching of simple edit timestamps * COMPARETEXT: Files can be input streams, region is passed in, window is returned * COMPAREDIRECTORIES again: Fixed a promptwindow bug * GITFNS: New package for comparing and copying back and forth from My Medley to the git clone
41 lines
21 KiB
Plaintext
41 lines
21 KiB
Plaintext
XEROX COMPAREDIRECTORIES2
|
||
|
||
4
|
||
|
||
1
|
||
|
||
COMPAREDIRECTORIES
|
||
1
|
||
|
||
4
|
||
|
||
By: Larry Masinter and Ron Kaplan
|
||
This document edited on
|
||
December 2, 1987
|
||
December 28, 1998 (Ron Kaplan)
|
||
April 7, 2018 (Ron Kaplan)
|
||
Rewritten December, 2021 (Ron Kaplan)
|
||
|
||
COMPAREDIRECTORIES compares the contents of two directories, identifying files according to their creation dates and lengths. It is called using the function
|
||
(COMPAREDIRECTORIES DIR1 DIR2 SELECT INCLUDEDFILES EXCLUDEDFILES USEDIRECTORYDATES OUTPUTFILE ALLVERSIONS) [Function]
|
||
Compares the creation dates of files with matching names in the lists that CDFILES returns for DIR1 and DIR2. Collects or prints CDENTRIES for those files that meet the SELECT criteria. May also collect or print entries for relevant files that exist in DIR1 or DIR2 but not both.
|
||
SELECT specifies which the match/mismatch criteria for filtering the output. If SELECT is or contains
|
||
AFTER or >: select entries where file1 has a later date than file2
|
||
BEFORE or <: select entries where file1 has an earlier date than file2
|
||
SAMEDATE or =: select entries where file1 and file2 have the same date
|
||
-*: exclude entries where file1 does not exist
|
||
*-: exclude entries where file2 does not exist
|
||
~=: exclude entries where file1 and file2 are byte-equivalent
|
||
SELECT = NIL is equivalent to (< > -* *-). Excludes files with matching dates, a useful default for identifying files that may require further attention.
|
||
SELECT = T is equivalent to (= < > -* *-). Includes all files for processing by other functions or later filtering by CDSUBSET (below).
|
||
SELECT may also contain the token AUTHOR to indicate that authors should be provided in the printed output (see CDPRINT below).
|
||
Unless USEDIRECTORYDATES, the FILECREATED date is used for the date comparison of Lisp source and compiled files, otherwise the file-system CREATIONDATE is used.
|
||
If OUTPUTFILE=NIL, then the value is a CDVALUE structure with fields (CDPARAMETERS . CDENTRIES). CDPARAMETERS records the parameters in the call to COMPAREDIRECTORIES and CDENTRIES is the list of per-file comparison results. CDPARAMETERS has fields
|
||
CDDIR1 CDDIR2 CDCOMPAREDATE CDSELECT.
|
||
CDENTRIES contains one entry for each of the file-comparisons that meets the SELECT criteria. Each entry is a CDENTRY record with fields
|
||
MATCHNAME INFO1 DATERULE INFO2 EQUIV
|
||
where MATCHNAME is the name.extension shared by the two files, and each file info is either NIL (for nonexistent files) or a CDINFO record with fields
|
||
(FULLNAME DATE LENGTH AUTHOR TYPE EOL)
|
||
TYPE is SOURCE for Lisp source (filecreated) files, COMPILED for Lisp compiled files, otherwise the PRINTFILETYPE (TEXT, TEDIT...) or NIL. EOL is CR, LF, CRLF, or NIL.
|
||
When both files exist, the date relation is one of <, =, or >. Otherwise, the date relation is * if only one file exists.
|
||
EQUIV is T for files that contain the same bytes. In that case, the date of the earlier file is assumed to be more accurate, it replaces the CREATIONDATE of the earlier file, and the date relation is changed to =.
|
||
If OUTPUTFILE is not NIL, then it is a filename or open stream on which selected entries will be printed (T for the terminal) by CDPRINT.
|
||
COMPAREDIRECTORIES always sets the variable LASTCDVALUE to the CDVALUE data structure. This is used by the functions below if their CDENTRIES is NIL.
|
||
|
||
(CDPRINT CDVALUE FILE COLHEADINGS PRINTAUTHOR ) [Function]
|
||
Prints CDVALUE on FILE, with one line for each entry. The line for each entry is of the form
|
||
FILE1 (AUTHOR) SIZE DATE DATEREL DATE FILE2 (AUTHOR) SIZE
|
||
For example
|
||
ACE.;1 (Joe) 235 2-May-1985 18:03:54 < 30-Sep-1985 11:14:48 ACE.;3 (Sam) 396
|
||
The line for byte-equivalent files is prefixed with ==. If the files are equivalent except for a difference in end-of-line conventions, the equivalence prefix will indicate the convention for each file (C for CR, L, for LF, 2 for CRLF). Thus C2 indicates that the files are equivalent except that file1 marks line ends with CR and file2 with CRLF.
|
||
COLHEADINGS can be a pair (col1 col2) of strings to be printed as column headings.
|
||
Note that because COMPAREDIRECTORIES sets LASTCDVALUE, evaluating (CDPRINT) after COMPAREDIRECTORIES prints the results of the last comparision.
|
||
For conciseness, authors are included only if PRINTAUTHOR or if AUTHOR is included in the CDSELECT parameter of CDVALUE. Also, redundant file-name hosts/directories are not printed.
|
||
|
||
(CDTEDIT CDVALUE TITLE COLHEADINGS PRINTAUTHOR) [Function]
|
||
Produces the CDPRINT output in a read-only TEDIT window, with TITLE if given.
|
||
|
||
(CDBROWSER CDVALUE TITLE COLHEADINGS BROWSERPROPS SEPARATEDIRECTIONS MENUITEMS PRINTAUTHOR) [Function]
|
||
Produce the CDPRINT output in a TABLEBROWSER window with menu commands for comparing the contents of individual files, viewing files in read-only TEDIT windows, copying files from one directory to another, etc. Lisp source files are compared with COMPARESOURCES, text files with COMPARETEXT. If SEPARATEDIRECTIONS, the entry lines are grouped according to whether the date relation is < or >.
|
||
(CDFILES DIR INCLUDEDFILES EXCLUDEDFILES ALLVERSIONS DEPTH) [Function]
|
||
Returns a list of full filenames for files in directory DIR (NIL=T=the connected directory) that match the other file-name filtering criteria. Files are excluded if:
|
||
Their name does not match a pattern in INCLUDEDFILES (NIL = *.*). Dotted files are excluded unless FILEPATTERNS includes .* and files in subdirectories are excluded if the number of subdirectories exceeds DEPTH (below).
|
||
They do not match patterns on the list EXCLUDEDFILES. *.* excludes all extensions, *.COM or just COM excludes extentsions on *COMPILED-EXTENSIONS*. EXCLUDEDFILES contains .* to suppress dotted files unless .* also appears in INCLUDEDFILES.
|
||
They are not the highest version unless ALLVERSIONS=T.
|
||
DEPTH controls the depth of subdirectory exploration. T means all levels, NIL means no subdirectories. Otherwise the maximum number of > or / characters below the starting DIR in the fullname of files.
|
||
(CDFILES) produces all the newest, undotted files in the immediate connected directory.
|
||
(CDMERGE CDVALUES) [Function]
|
||
Merges all subsets of CDVALUES that have the same CDSELECT into a single CDVALUE with the union of their CDENTRIES. The CDCOMPAREDATE of the merger will be the latest of the dates, and the directories and match names will be adjusted to reflect the original subdirectory sources.
|
||
|
||
(CDMAP CDVALUE FN) [Function]
|
||
(CDSUBSET CDVALUE FN) [Function]
|
||
CDMAP applies FN to each CDENTRY in CDVALUE. CDSUBSET applies FN and also returns the subset of the entries for which FN is non-NIL and preserves in the value the parameters of CDVALUE. For convenience, at each invocation the variables MATCHNAME INFO1 DATEREL INFO2 and EQUIV are bound to the corresponding fields and can be used freely by FN.
|
||
|
||
USEFUL UTILITIES
|
||
(FIX-DIRECTORY-DATES FILES) [Function]
|
||
For every file included in or specified by FILES, if it is a Lisp source or compiled whose directory creation date is more than 30 seconds later than its internal filecreated date (presumably because of copying), then its directory date is reset to match the internal date. FILES can be a list of file names or a pattern interpretable by FILDIR. Returns a list of files whose dates have been changed.
|
||
|
||
(FIX-EQUIV-DATES CDVALUE) [Function]
|
||
If there is an entry in CDVALUE whose files are EQUIVALENT but with different directory creation dates, the directory date of the file with the later date (presumably a copy) is reset to match the date of the earlier file. In the end all equivalent files will have the same (earliest) date. Returns a list of files whose dates have been changed.
|
||
|
||
(COPY-MISSING-FILES CDVALUE TARGET MATCHNAMES) [Function]
|
||
Target is 1 or 2, indicating the direction of potential copies. If an entry with a source file but no target file has a matchname in MATCHNAMES, the source file is copied to the target directory. All target-absent files are copied if MATCNAMES is NIL. Source properties (including version number) are preserved in the target.
|
||
|
||
(COPY-COMPARED-FILES CDVALUE TARGET MATCHNAMES) [Function]
|
||
TARGET is 1 or 2, indicating the direction of potential copies. If an entry with both source and target files has a matchname in MATCHNAMES, the source file is copied to a new version of the target file. All files are copied if MATCHNAMES is NIL.
|
||
|
||
(COMPILED-ON-SAME-SOURCE CDVALUE) [Function]
|
||
Returns the subset of entries with Lisp compiled files (dfasl or lcom) that are compiled on the same source, according to SOURCE-FOR-COMPILED-P below. Presumably one should be removed to avoid confusion.
|
||
|
||
(FIND-SOURCE-FILES CFILES SDIRS DFASLMARGIN) [Function]
|
||
Returns (CFILE . SFILES) pairs where CFILE is a Lisp compiled file in CFILES and SFILES is list of files in SDIRS that CFILE was compiled on according to SOURCE-FOR-COMPILED-P. This suggests that at least one of SFILES should be copied to CFILE's location (or vice versa).
|
||
|
||
(FIND-COMPILED-FILES SFILES CDIRS DFASLMARGIN) [Function]
|
||
Returns (CFILE . SFILES) pairs where SFILE is a Lisp source file in SFILES and CFILES are files in CDIRS that are compiled on SFILE according to SOURCE-FOR-COMPILED-P. This suggests that at least one of CFILES should be copied to SFILE's location.
|
||
|
||
(FIND-UNCOMPILED-FILES FILES DFASLMARGIN COMPILEXTS) [Function]
|
||
Returns a list of elements each of which corresponds to a source file in FILES for which no appropriate compiled file can be found. An appropriate compiled file is a file in the same location with extension in COMPILEEXTS (defaulting to *COMPILED-EXTENSIONS*) that satisfies SOURCE-FOR-COMPILED-P. Each element is a list of the form
|
||
(sourcefile . cfiles)
|
||
cfiles contains compiled files that were compiled on a different version of sourcefile, NIL if no such files exist. Each cfile item is a pair (cfile timediff) where timediff is the time difference (in minutes) between the creation date of the compiled-file's source and the creation date of sourcefile (positive if the cfile was compiled later, as should be the case). FILES can be an explicit list of files, or a file specification interpretable by FILDIR; in that case only the newest source-file versions are processed.
|
||
|
||
(FIND-UNSOURCED-FILES CFILES DFASLMARGIN COMPILEXTS) [Function]
|
||
Returns the subset of the compiled files specified by CFILES for which a corresponding source file according to SOURCE-FOR-COMPILED-P cannot be found in the same directory. CFILES can be a list of files or a pattern that FILDIR can interpret. COMPILEEXTS can be one or more explicit compile-file extensions, defaulting to *COMPILED-EXTENSIONS*.
|
||
|
||
(SOURCE-FOR-COMPILED-P SOURCE COMPILED DFASLMARGIN) [Function]
|
||
Returns T if it can confirm that Lisp COMPILED file was compiled on Lisp SOURCE file. SOURCE and COMPILED can be provided as CREATED-AS values, to avoid repetitive computation. This compares the information in the filecreated expressions, original file names and original dates, and not the current directory names and dates.
|
||
It appears that the times in DFASL files may differ from the filecreated source dates by a few minutes. The DFASLMARGIN can be provided to loosen up the date matching criterion. DFASLMARGIN is a pair (max min) and a DFASL COMPILED is deemed to be compiled on SOURCE if the compiled's source date is no more than max and no less than min minutes after the source date. A negative min allows for the possibility that the compiled-source date is earlier than the candidate source date. DFASLMARGIN defaults to (20 0). A single positive number x is coerced to (x 0). A single negative number is coerced to (-x x) (compiled file is no more than x minutes later or earlier). T is infinity in either direction. Examples:
|
||
(T 0): COMPILED compiled on source later than SOURCE
|
||
(0 T): COMPILED compiled on source earlier than SOURCE (odd)
|
||
12: COMPILED compiled on source later than SOURCE by no more than 12 minutes -12: COMPILED compiled on source 12 minutes before or after SOURCE
|
||
|
||
(FIND-MULTICOMPILED-FILES FILES SHOWINFO) [Function]
|
||
Returns a list of files in FILES that have more than one type of compiled file (e.g. LCOM and DFASL). FILES is interpretable by FILDIR. If SHOWINFO, then the value contains a list for each file of the form
|
||
<20><> |