nix-store --export: Export paths in topologically sorted order

Fixes #118.
This commit is contained in:
Eelco Dolstra 2013-05-23 14:55:36 -04:00
parent 107505e13a
commit b09b87321c
2 changed files with 4 additions and 2 deletions

View File

@ -328,7 +328,7 @@ Path addPermRoot(StoreAPI & store, const Path & storePath,
/* Sort a set of paths topologically under the references relation. /* Sort a set of paths topologically under the references relation.
If p refers to q, then p follows q in this list. */ If p refers to q, then p preceeds q in this list. */
Paths topoSortPaths(StoreAPI & store, const PathSet & paths); Paths topoSortPaths(StoreAPI & store, const PathSet & paths);

View File

@ -694,7 +694,9 @@ static void opExport(Strings opFlags, Strings opArgs)
else throw UsageError(format("unknown flag `%1%'") % *i); else throw UsageError(format("unknown flag `%1%'") % *i);
FdSink sink(STDOUT_FILENO); FdSink sink(STDOUT_FILENO);
exportPaths(*store, opArgs, sign, sink); Paths sorted = topoSortPaths(*store, PathSet(opArgs.begin(), opArgs.end()));
reverse(sorted.begin(), sorted.end());
exportPaths(*store, sorted, sign, sink);
} }