VersionMap2Directories.Mesa
Copyright Ó 1990 by Xerox Corporation. All rights reserved.
Last tweaked by Mike Spreitzer on April 10, 1992 9:34 am PDT
DIRECTORY MorePfsNames, PFS, PFSNames, VersionMapClassify, VersionMap2, VersionMap2Implr;
VersionMap2Directories: CEDAR PROGRAM
IMPORTS MorePfsNames, PFS, PFSNames, VersionMapClassify, VersionMap2, VersionMap2Implr
EXPORTS VersionMap2
=
BEGIN OPEN MPfsN:MorePfsNames, PVMC:VersionMapClassify, VersionMap2, VersionMap2Implr;
DirectoriesMap: TYPE ~ REF DirectoriesMapPrivate;
DirectoriesMapPrivate: TYPE ~ RECORD [
dirs, cache, hints: Map,
cg, hg: BOOL
];
dmClass: MapClass ~ FillinDefaults[FALSE, readonly, [
Scan: DmScan,
data: NIL]];
localStar: Name ~ PFSNames.ConstructName[components: LIST[MPfsN.ConstructComponent[name: ["*"], version: [all]]], absolute: FALSE, directory: FALSE];
CreateDirectoriesMap: PUBLIC PROC [dirs: Map, cache, hints: Map ← nullMap] RETURNS [Map] ~ {
{dm: DirectoriesMap ~ NEW [DirectoriesMapPrivate ← [dirs, cache, hints, cache#nullMap, hints#nullMap]];
RETURN [[dmClass, dm]]}};
DmScan: PROC [map: Map, Consume: TupleConsumer, inOrder: BOOL, pfml: PatternFactoredMapList] RETURNS [MaybeTuple] ~ {
dm: DirectoriesMap ~ NARROW[map.data];
IF pfml.stampInd = listOfEmpty THEN RETURN [noMaybe];
{mt: MaybeTuple ← noMaybe;
testName: BOOL ~ pfml.pattern.name # nullName;
dirPart: Name ~ IF testName THEN pfml.pattern.name.SubName[count: pfml.pattern.name.ComponentCount[] - 1, absolute: TRUE, directory: TRUE] ELSE nullName;
lc: MPfsN.Component ~ IF testName THEN pfml.pattern.name.ShortName[] ELSE [];
PerDir: PROC [dt: VersionTuple] RETURNS [BOOL] ~ {
dir: Name ~ dt.name;
enumPat: Name ← NIL;
IF testName THEN {
enumPat ← dir.Cat[PFSNames.ConstructName[LIST[lc], FALSE, FALSE]];
}
ELSE enumPat ← dir.Cat[localStar];
PFS.EnumerateForInfo[enumPat, PerInfo];
RETURN [mt.found]};
PerInfo: PFS.InfoProc ~ {
nameR: ROPE ~ PFS.RopeFromPath[fullFName];
thet: MaybeTuple ← noMaybe;
IF NOT CreatedMatch[uniqueID, pfml.pattern.created] THEN RETURN [TRUE];
IF pfml.stampInd#NIL AND NOT AllHave[pfml.stampInd, [fullFName, uniqueID]] THEN RETURN [TRUE];
{thisLC: MPfsN.Component ~ fullFName.ShortName[];
seek: VersionTuple ~ [name: LastComponentToPattern[[name: thisLC.name, version: [all]]].name, created: uniqueID];
IF dm.cg THEN thet ← dm.cache.ScanMatches[AlwaysAccept, FALSE, seek];
IF dm.hg AND NOT thet.found THEN thet ← dm.hints.ScanMatches[AlwaysAccept, FALSE, seek];
IF NOT thet.found THEN {
kind: PVMC.Kind ~ PVMC.Classify[nameR];
thet.it ← [fullFName, uniqueID, PVMC.ReadVersionStamp[kind, nameR, uniqueID.egmt.gmt, FALSE].stamp];
IF dm.cg THEN [] ← dm.cache.AddTuple[thet.it]};
IF NOT StampMatch[thet.it.stamp, pfml.pattern.stamp] THEN RETURN [TRUE];
IF pfml.general#NIL AND NOT AllHave[pfml.general, thet.it] THEN RETURN [TRUE];
IF Consume[thet.it] THEN {mt ← [TRUE, thet.it]; RETURN [FALSE]};
RETURN [TRUE]}};
[] ← dm.dirs.ScanMatches[PerDir, FALSE, [name: dirPart]];
RETURN [mt]}};
END.