@@ -52,7 +52,7 @@ class RepoIndex[T >: Null](proc: ConfProcessor[T]) extends Logging {
52
52
53
53
/**
54
54
* @param fileHashes map of all the file names to their hashes in the branch.
55
- * @param newNodes nodes that aren't present in the index's [[ fileHashToContent ]] table. New nodes typically .
55
+ * @param newNodes nodes that aren't already present in the index. De-duped across branches .
56
56
* @param branch branch on which the user is making the changes.
57
57
* @param dryRun when true shows potential versions that will be assigned to nodes without modifying the index.
58
58
* @return
@@ -74,8 +74,7 @@ class RepoIndex[T >: Null](proc: ConfProcessor[T]) extends Logging {
74
74
*
75
75
* we use memoization to avoid recomputing global hashes via the [[globalHashes ]] map
76
76
*/
77
- val globalHashes = mutable.Map .empty[Name , GlobalHash ]
78
- def computeGlobalHash (name : Name ): GlobalHash = {
77
+ def computeGlobalHash (name : Name , globalHashes : mutable.Map [Name , GlobalHash ]): GlobalHash = {
79
78
80
79
if (globalHashes.contains(name)) return globalHashes(name)
81
80
@@ -107,7 +106,7 @@ class RepoIndex[T >: Null](proc: ConfProcessor[T]) extends Logging {
107
106
// recursively compute parent hashes
108
107
val parentHashes = parents
109
108
.map { parent =>
110
- val parentHash = computeGlobalHash(parent).hash
109
+ val parentHash = computeGlobalHash(parent, globalHashes ).hash
111
110
s " ${parent.name}: $parentHash"
112
111
}
113
112
.mkString(" ," )
@@ -123,7 +122,9 @@ class RepoIndex[T >: Null](proc: ConfProcessor[T]) extends Logging {
123
122
globalHash
124
123
}
125
124
126
- fileHashes.foreach { case (name, _) => computeGlobalHash(name) }
125
+ val globalHashes = mutable.Map .empty[Name , GlobalHash ]
126
+ // this line fills global hashes
127
+ fileHashes.foreach { case (name, _) => computeGlobalHash(name, globalHashes) }
127
128
128
129
val existingVersions = branchVersionIndex.getOrElse(branch, mutable.Map .empty)
129
130
val mainVersions = branchVersionIndex.getOrElse(Branch .main, mutable.Map .empty)
@@ -146,19 +147,20 @@ class RepoIndex[T >: Null](proc: ConfProcessor[T]) extends Logging {
146
147
branchToFileHash.update(branch, enrichedFileHashes)
147
148
branchVersionIndex.update(branch, newVersions)
148
149
149
- return VersionUpdate .join(newVersions, existingVersions, mainVersions)
150
- }
150
+ VersionUpdate .join(newVersions, existingVersions, mainVersions)
151
151
152
- // dry run - don't insert into any members of the index
153
- val newVersions = mutable.Map .empty[Name , Version ]
154
- globalHashes.foreach {
155
- case (name, globalHash) =>
156
- val versionIndex = versionSequencer.potentialIndex(name, globalHash)
157
- newVersions.update(name, Version (" v" + versionIndex.toString))
158
- }
152
+ } else {
153
+
154
+ // dry run - don't insert into any members of the index
155
+ val newVersions = mutable.Map .empty[Name , Version ]
156
+ globalHashes.foreach {
157
+ case (name, globalHash) =>
158
+ val versionIndex = versionSequencer.potentialIndex(name, globalHash)
159
+ newVersions.update(name, Version (" v" + versionIndex.toString))
160
+ }
159
161
160
- val versionUpdates = VersionUpdate .join(newVersions, existingVersions, mainVersions)
161
- versionUpdates
162
+ VersionUpdate .join(newVersions, existingVersions, mainVersions)
163
+ }
162
164
}
163
165
164
166
def addFiles (fileHashes : mutable.Map [Name , FileHash ], updatedFiles : Map [String , String ], branch : Branch ): Unit = {
@@ -171,7 +173,9 @@ class RepoIndex[T >: Null](proc: ConfProcessor[T]) extends Logging {
171
173
addNodes(fileHashes, nodes, branch)
172
174
}
173
175
174
- // returns the contents of the files not present in the index
176
+ /**
177
+ * returns the names of the files whose contents haven't been found in the index across any of the versions
178
+ */
175
179
def diff (incomingFileHashes : mutable.Map [Name , FileHash ]): Seq [Name ] = {
176
180
177
181
incomingFileHashes
0 commit comments