Add copyClosure utility function for Hydra
This commit is contained in:
		
							parent
							
								
									629ab80022
								
							
						
					
					
						commit
						35db4f65a0
					
				
					 2 changed files with 29 additions and 0 deletions
				
			
		|  | @ -414,6 +414,30 @@ void copyStorePath(ref<Store> srcStore, ref<Store> dstStore, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | void copyClosure(ref<Store> srcStore, ref<Store> dstStore, | ||||||
|  |     const PathSet & storePaths, bool repair) | ||||||
|  | { | ||||||
|  |     PathSet closure; | ||||||
|  |     for (auto & path : storePaths) | ||||||
|  |         srcStore->computeFSClosure(path, closure); | ||||||
|  | 
 | ||||||
|  |     PathSet valid = dstStore->queryValidPaths(closure); | ||||||
|  | 
 | ||||||
|  |     if (valid.size() == closure.size()) return; | ||||||
|  | 
 | ||||||
|  |     Paths sorted = srcStore->topoSortPaths(closure); | ||||||
|  | 
 | ||||||
|  |     Paths missing; | ||||||
|  |     for (auto i = sorted.rbegin(); i != sorted.rend(); ++i) | ||||||
|  |         if (!valid.count(*i)) missing.push_back(*i); | ||||||
|  | 
 | ||||||
|  |     printMsg(lvlDebug, format("copying %1% missing paths") % missing.size()); | ||||||
|  | 
 | ||||||
|  |     for (auto & i : missing) | ||||||
|  |         copyStorePath(srcStore, dstStore, i, repair); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| ValidPathInfo decodeValidPathInfo(std::istream & str, bool hashGiven) | ValidPathInfo decodeValidPathInfo(std::istream & str, bool hashGiven) | ||||||
| { | { | ||||||
|     ValidPathInfo info; |     ValidPathInfo info; | ||||||
|  |  | ||||||
|  | @ -585,6 +585,11 @@ void copyStorePath(ref<Store> srcStore, ref<Store> dstStore, | ||||||
|     const Path & storePath, bool repair = false); |     const Path & storePath, bool repair = false); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | /* Copy the closure of the specified paths from one store to another. */ | ||||||
|  | void copyClosure(ref<Store> srcStore, ref<Store> dstStore, | ||||||
|  |     const PathSet & storePaths, bool repair = false); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| /* Remove the temporary roots file for this process.  Any temporary
 | /* Remove the temporary roots file for this process.  Any temporary
 | ||||||
|    root becomes garbage after this point unless it has been registered |    root becomes garbage after this point unless it has been registered | ||||||
|    as a (permanent) root. */ |    as a (permanent) root. */ | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue