Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
kill some dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
aakropotkin committed Jul 19, 2023
1 parent 4413b9b commit 4b85b4a
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 213 deletions.
15 changes: 3 additions & 12 deletions include/flox/flox-flake.hh
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,16 @@ class FloxFlake : public std::enable_shared_from_this<FloxFlake> {
std::shared_ptr<nix::flake::LockedFlake> getLockedFlake();
nix::ref<nix::eval_cache::EvalCache> openEvalCache();

FloxFlakeRef getFlakeRef() const { return this->_flakeRef; }
FloxFlakeRef getFlakeRef() const { return this->_flakeRef; }

FloxFlakeRef
getLockedFlakeRef()
{
return this->getLockedFlake()->flake.lockedRef;
}

std::list<std::string> getSystems() const;
std::list<std::list<std::string>> getDefaultFlakeAttrPathPrefixes() const;
std::list<std::list<std::string>> getFlakeAttrPathPrefixes() const;
std::list<std::string> getSystems() const;
std::list<std::list<std::string>> getFlakeAttrPathPrefixes() const;

/**
* Like `findAttrAlongPath' but without suggestions.
Expand All @@ -133,14 +132,6 @@ class FloxFlake : public std::enable_shared_from_this<FloxFlake> {
/** Opens `EvalCache' once, staying open until all cursors die. */
std::list<Cursor> getFlakePrefixCursors();

std::list<std::vector<std::string>> getActualFlakeAttrPathPrefixes();

/**
* Try opening cursors from an absolute or relative path with globs.
* Glob is only accepted for `system'.
*/
std::list<Cursor> openCursorsByAttrPathGlob( const AttrPathGlob & path );

/**
* Determine which output prefixes exist in this flake, ignoring
* `preferences' and mark them in the `DrvDb'.
Expand Down
174 changes: 0 additions & 174 deletions src/flox-flake.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,35 +83,6 @@ FloxFlake::getSystems() const
}


/* -------------------------------------------------------------------------- */

std::list<std::list<std::string>>
FloxFlake::getDefaultFlakeAttrPathPrefixes() const
{
std::string system = nix::settings.thisSystem.get();
if ( ! hasElement( this->_systems, system ) )
{
return {};
}
std::list<std::list<std::string>> rsl;
for ( auto & prefix : this->_prefsPrefixes )
{
if ( prefix == "catalog" )
{
for ( auto & stability : this->_prefsStabilities )
{
rsl.push_back( { "catalog", system, stability } );
}
}
else
{
rsl.push_back( { prefix, system } );
}
}
return rsl;
}


/* -------------------------------------------------------------------------- */

std::list<std::list<std::string>>
Expand Down Expand Up @@ -259,98 +230,6 @@ FloxFlake::getFlakePrefixCursors()
}


/* -------------------------------------------------------------------------- */

std::list<std::vector<std::string>>
FloxFlake::getActualFlakeAttrPathPrefixes()
{
this->recordPrefixes();
DrvDb db( this->getLockedFlake()->getFingerprint() );
std::list<std::vector<std::string>> rsl;

for ( std::list<std::string> & prefix : this->getFlakeAttrPathPrefixes() )
{
std::string subtree = std::move( prefix.front() );
prefix.pop_front();
std::string system = std::move( prefix.front() );
prefix.pop_front();
progress_status status = db.getProgress( subtree, system );
switch ( status )
{
case DBPS_EMPTY: continue; break;
case DBPS_MISSING: continue; break;
case DBPS_NONE:
throw ResolverException(
"FloxFlake::getActualFlakeAttrPathPrefixes(): Failed to read "
"progress from DrvDb."
);
break;
case DBPS_INFO_DONE:
case DBPS_PATHS_DONE:
/* Handle stabilities */
if ( prefix.empty() )
{
std::vector<std::string> path = {
std::move( subtree ), std::move( system )
};
rsl.push_back( std::move( path ) );
}
else
{
std::string stability = std::move( prefix.front() );
prefix.pop_front();
auto state = db.getDbState();
nix::SQLiteStmt stmt;
stmt.create( state->db
, "SELECT COUNT( subtree ) FROM Derivations WHERE "
"( subtree = ? ) AND ( system = ? ) AND ( path LIKE ? )"
);
std::string like( "[\"" + stability + "\",%" );
nix::SQLiteStmt::Use query =
stmt.use()( subtree )( system )( like );
assert( query.next() );
if ( query.getInt( 0 ) != 0 )
{
std::vector<std::string> path = {
std::move( subtree )
, std::move( system )
, std::move( stability )
};
rsl.push_back( std::move( path ) );
}
}
break;

default:
/* Handle stabilities */
if ( prefix.empty() )
{
std::vector<std::string> path = {
std::move( subtree ), std::move( system )
};
rsl.push_back( std::move( path ) );
}
else
{
std::vector<std::string> path = {
std::move( subtree )
, std::move( system )
, std::move( prefix.front() )
};
prefix.pop_front();
if ( this->maybeOpenCursor( path ) != nullptr )
{
rsl.push_back( std::move( path ) );
}
}
break;
}
}

return rsl;
}


/* -------------------------------------------------------------------------- */

void
Expand Down Expand Up @@ -643,59 +522,6 @@ FloxFlake::packagesDo(
}


/* -------------------------------------------------------------------------- */

// TODO: Use DrvDb
std::list<Cursor>
FloxFlake::openCursorsByAttrPathGlob( const AttrPathGlob & path )
{

std::list<Cursor> rsl;

if ( path.isAbsolute() )
{
MaybeCursor prefix = this->openEvalCache()->getRoot()->maybeGetAttr(
std::get<std::string>( path.path[0] )
);
if ( prefix == nullptr ) { return {}; }
if ( ! path.hasGlob() )
{
MaybeCursor c = prefix;
for ( size_t i = 1; ( i < path.size() ) && ( c != nullptr ); ++i )
{
c = c->maybeGetAttr( std::get<std::string>( path.path[i] ) );
}
if ( c != nullptr ) { rsl.push_back( std::move( (Cursor) c ) ); }
}
else
{
for ( const auto & system : this->_systems )
{
MaybeCursor c = prefix->maybeGetAttr( system );
for ( size_t i = 2; ( i < path.size() ) && ( c != nullptr ); ++i )
{
c = c->maybeGetAttr( std::get<std::string>( path.path[i] ) );
}
if ( c != nullptr ) { rsl.push_back( std::move( (Cursor) c ) ); }
}
}
}
else /* Relative */
{
for ( const auto & prefix : this->getFlakePrefixCursors() )
{
MaybeCursor c = prefix;
for ( size_t i = 0; ( i < path.size() ) && ( c != nullptr ); ++i )
{
c = c->maybeGetAttr( std::get<std::string>( path.path[i] ) );
}
if ( c != nullptr ) { rsl.push_back( std::move( (Cursor) c ) ); }
}
}
return rsl;
}


/* -------------------------------------------------------------------------- */

} /* End namespace `flox::resolve' */
Expand Down
13 changes: 0 additions & 13 deletions tests/drv-cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,6 @@ test_CachedPackageFromInfo1( DrvDb * cache )
}


/* -------------------------------------------------------------------------- */
bool
test_FloxFlake_getActualFlakeAttrPathPrefixes1( ResolverState & rs )
{
std::optional<nix::ref<FloxFlake>> mf = rs.getInput( "nixpkgs" );
nix::ref<FloxFlake> flake = mf.value();
std::list<std::vector<std::string>> prefixes =
flake->getActualFlakeAttrPathPrefixes();
return prefixes.size() == defaultSystems.size();
}


/* -------------------------------------------------------------------------- */

int
Expand Down Expand Up @@ -141,7 +129,6 @@ main( int argc, char * argv[], char ** envp )
RUN_TEST( CachedPackageFromDb1, cache );
RUN_TEST( CachedPackageFromDb2, cache, prefs );
RUN_TEST( CachedPackageFromInfo1, cache );
RUN_TEST( FloxFlake_getActualFlakeAttrPathPrefixes1, rs );

delete cache;

Expand Down
14 changes: 0 additions & 14 deletions tests/resolve.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,6 @@ test_ResolverStateLocking1()
}


/* -------------------------------------------------------------------------- */

bool
test_getActualFlakeAttrPathPrefixes()
{
Inputs inputs( (nlohmann::json) { { "nixpkgs", nixpkgsRef } } );
Preferences prefs;
ResolverState rs( inputs, prefs );
auto ps = rs.getInputs().at( "nixpkgs" )->getActualFlakeAttrPathPrefixes();
return ps.size() == defaultSystems.size();
}


/* -------------------------------------------------------------------------- */

/* Use relative path. */
Expand Down Expand Up @@ -105,7 +92,6 @@ main( int argc, char * argv[], char ** envp )
# define RUN_TEST( ... ) _RUN_TEST( ec, __VA_ARGS__ )

RUN_TEST( ResolverStateLocking1 );
RUN_TEST( getActualFlakeAttrPathPrefixes );
RUN_TEST( resolveInInput1 );
RUN_TEST( resolveInInput2 );
RUN_TEST( resolve_V2_1 );
Expand Down

0 comments on commit 4b85b4a

Please sign in to comment.