1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-15 06:52:43 +01:00

* Sync with the trunk.

This commit is contained in:
Eelco Dolstra 2010-06-21 07:55:38 +00:00
commit bf87cc44b4
16 changed files with 140 additions and 16 deletions

View file

@ -59,6 +59,7 @@ std::ostream & operator << (std::ostream & str, const Value & v)
str << "]";
break;
case tThunk:
case tApp:
case tCopy:
str << "<CODE>";
break;
@ -901,12 +902,18 @@ string EvalState::forceString(Value & v)
}
string EvalState::forceString(Value & v, PathSet & context)
void copyContext(const Value & v, PathSet & context)
{
string s = forceString(v);
if (v.string.context)
for (const char * * p = v.string.context; *p; ++p)
context.insert(*p);
}
string EvalState::forceString(Value & v, PathSet & context)
{
string s = forceString(v);
copyContext(v, context);
return s;
}
@ -937,9 +944,7 @@ string EvalState::coerceToString(Value & v, PathSet & context,
string s;
if (v.type == tString) {
if (v.string.context)
for (const char * * p = v.string.context; *p; ++p)
context.insert(*p);
copyContext(v, context);
return v.string.s;
}

View file

@ -163,6 +163,8 @@ void mkString(Value & v, const char * s);
void mkString(Value & v, const string & s, const PathSet & context = PathSet());
void mkPath(Value & v, const char * s);
void copyContext(const Value & v, PathSet & context);
typedef std::map<Path, Hash> DrvHashes;

View file

@ -15,6 +15,7 @@ MakeError(AssertionError, EvalError)
MakeError(ThrownError, AssertionError)
MakeError(Abort, EvalError)
MakeError(TypeError, EvalError)
MakeError(ImportError, EvalError) // error building an imported derivation
/* Position objects. */

View file

@ -37,7 +37,11 @@ static void prim_import(EvalState & state, Value * * args, Value & v)
throw EvalError(format("cannot import `%1%', since path `%2%' is not valid")
% path % *i);
if (isDerivation(*i))
store->buildDerivations(singleton<PathSet>(*i));
try {
store->buildDerivations(singleton<PathSet>(*i));
} catch (Error & e) {
throw ImportError(e.msg());
}
}
state.evalFile(path, v);

View file

@ -69,6 +69,7 @@ static void printValueAsXML(EvalState & state, bool strict, bool location,
case tString:
/* !!! show the context? */
copyContext(v, context);
doc.writeEmptyElement("string", singletonAttrs("value", v.string.s));
break;