aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2012-01-19 23:08:47 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2012-01-19 23:08:47 +0000
commit330df4b4dbb363b69e10fa96d1e22f62088bfc96 (patch)
treecae6b697da62afc0254904383e18f5742962410a /src
parent18047d4625b46ae001abc649096ab9ecd4c54560 (diff)
* Allow comparisons between derivations by comparing the outPath
attributes.
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/eval.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 1e3f42edc..9ebf6293b 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -1245,11 +1245,23 @@ bool EvalState::eqValues(Value & v1, Value & v2)
return true;
case tAttrs: {
+ /* If both attribute sets denote a derivation (type =
+ "derivation"), then compare their outPaths. */
+ if (isDerivation(v1) && isDerivation(v2)) {
+ Bindings::iterator i = v1.attrs->find(sOutPath);
+ Bindings::iterator j = v2.attrs->find(sOutPath);
+ if (i != v1.attrs->end() && j != v2.attrs->end())
+ return eqValues(*i->value, *j->value);
+ }
+
if (v1.attrs->size() != v2.attrs->size()) return false;
- Bindings::iterator i = v1.attrs->begin(), j = v2.attrs->begin();
- for ( ; i != v1.attrs->end(); ++i, ++j)
+
+ /* Otherwise, compare the attributes one by one. */
+ Bindings::iterator i, j;
+ for (i = v1.attrs->begin(), j = v2.attrs->begin(); i != v1.attrs->end(); ++i, ++j)
if (i->name != j->name || !eqValues(*i->value, *j->value))
return false;
+
return true;
}