about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/nix.cc6
-rw-r--r--src/normalise.cc51
-rw-r--r--src/normalise.hh6
-rw-r--r--src/store.cc3
-rw-r--r--src/test.cc3
5 files changed, 35 insertions, 34 deletions
diff --git a/src/nix.cc b/src/nix.cc
index 9e62fa3950ae..6dc5776e25db 100644
--- a/src/nix.cc
+++ b/src/nix.cc
@@ -44,7 +44,11 @@ static void opInstall(Strings opFlags, Strings opArgs)
 
     for (Strings::iterator it = opArgs.begin();
          it != opArgs.end(); it++)
-        realiseSlice(normaliseFState(argToId(*it)));
+    {
+        FSId id = normaliseFState(argToId(*it));
+        realiseSlice(id);
+        cout << format("%1%\n") % (string) id;
+    }
 }
 
 
diff --git a/src/normalise.cc b/src/normalise.cc
index a814a993becd..95d96351af54 100644
--- a/src/normalise.cc
+++ b/src/normalise.cc
@@ -24,7 +24,7 @@ static FSId storeSuccessor(const FSId & id1, ATerm sc)
 typedef set<FSId> FSIdSet;
 
 
-Slice normaliseFState(FSId id, FSIdSet pending)
+FSId normaliseFState(FSId id, FSIdSet pending)
 {
     Nest nest(lvlTalkative, format("normalising fstate %1%") % (string) id);
 
@@ -40,7 +40,7 @@ Slice normaliseFState(FSId id, FSIdSet pending)
     FState fs = parseFState(termFromId(id));
 
     /* It this is a normal form (i.e., a slice) we are done. */
-    if (fs.type == FState::fsSlice) return fs.slice;
+    if (fs.type == FState::fsSlice) return id;
     
     /* Otherwise, it's a derivation. */
 
@@ -56,11 +56,12 @@ Slice normaliseFState(FSId id, FSIdSet pending)
 
     for (FSIds::iterator i = fs.derive.inputs.begin();
          i != fs.derive.inputs.end(); i++) {
-        Slice slice = normaliseFState(*i, pending);
-        realiseSlice(slice, pending);
-
-        for (SliceElems::iterator j = slice.elems.begin();
-             j != slice.elems.end(); j++)
+        FSId nf = normaliseFState(*i, pending);
+        realiseSlice(nf, pending);
+        FState fs = parseFState(termFromId(nf));
+        if (fs.type != FState::fsSlice) abort();
+        for (SliceElems::iterator j = fs.slice.elems.begin();
+             j != fs.slice.elems.end(); j++)
             inMap[j->path] = *j;
     }
 
@@ -169,21 +170,24 @@ Slice normaliseFState(FSId id, FSIdSet pending)
     fs.type = FState::fsSlice;
     ATerm nf = unparseFState(fs);
     msg(lvlVomit, format("normal form: %1%") % printTerm(nf));
-    storeSuccessor(id, nf);
-
-    return fs.slice;
+    return storeSuccessor(id, nf);
 }
 
 
-void realiseSlice(const Slice & slice, FSIdSet pending)
+void realiseSlice(const FSId & id, FSIdSet pending)
 {
-    Nest nest(lvlDebug, format("realising slice"));
+    Nest nest(lvlDebug, 
+        format("realising slice %1%") % (string) id);
 
+    FState fs = parseFState(termFromId(id));
+    if (fs.type != FState::fsSlice)
+        throw Error(format("expected slice in %1%") % (string) id);
+    
     /* Perhaps all paths already contain the right id? */
 
     bool missing = false;
-    for (SliceElems::const_iterator i = slice.elems.begin();
-         i != slice.elems.end(); i++)
+    for (SliceElems::const_iterator i = fs.slice.elems.begin();
+         i != fs.slice.elems.end(); i++)
     {
         SliceElem elem = *i;
         string id;
@@ -203,8 +207,8 @@ void realiseSlice(const Slice & slice, FSIdSet pending)
     }
 
     /* For each element, expand its id at its path. */
-    for (SliceElems::const_iterator i = slice.elems.begin();
-         i != slice.elems.end(); i++)
+    for (SliceElems::const_iterator i = fs.slice.elems.begin();
+         i != fs.slice.elems.end(); i++)
     {
         SliceElem elem = *i;
         debug(format("expanding %1% in `%2%'") % (string) elem.id % elem.path);
@@ -217,13 +221,8 @@ Strings fstatePaths(const FSId & id, bool normalise)
 {
     Strings paths;
 
-    FState fs;
-
-    if (normalise) {
-        fs.slice = normaliseFState(id);
-        fs.type = FState::fsSlice;
-    } else
-        fs = parseFState(termFromId(id));
+    FState fs = parseFState(termFromId(
+        normalise ? normaliseFState(id) : id));
 
     if (fs.type == FState::fsSlice) {
         /* !!! fix complexity */
@@ -249,9 +248,9 @@ Strings fstatePaths(const FSId & id, bool normalise)
 Strings fstateRefs(const FSId & id)
 {
     Strings paths;
-    Slice slice = normaliseFState(id);
-    for (SliceElems::const_iterator i = slice.elems.begin();
-         i != slice.elems.end(); i++)
+    FState fs = parseFState(termFromId(normaliseFState(id)));
+    for (SliceElems::const_iterator i = fs.slice.elems.begin();
+         i != fs.slice.elems.end(); i++)
         paths.push_back(i->path);
     return paths;
 }
diff --git a/src/normalise.hh b/src/normalise.hh
index 72ee1d0897d6..619fef8bf623 100644
--- a/src/normalise.hh
+++ b/src/normalise.hh
@@ -5,11 +5,11 @@
 
 
 /* Normalise an fstate-expression, that is, return an equivalent
-   Slice.  (For the meaning of `pending', see expandId()). */
-Slice normaliseFState(FSId id, FSIdSet pending = FSIdSet());
+   slice.  (For the meaning of `pending', see expandId()). */
+FSId normaliseFState(FSId id, FSIdSet pending = FSIdSet());
 
 /* Realise a Slice in the file system. */
-void realiseSlice(const Slice & slice, FSIdSet pending = FSIdSet());
+void realiseSlice(const FSId & id, FSIdSet pending = FSIdSet());
 
 /* Get the list of root (output) paths of the given
    fstate-expression. */
diff --git a/src/store.cc b/src/store.cc
index fe7e1406f07b..3493ba384bb6 100644
--- a/src/store.cc
+++ b/src/store.cc
@@ -219,8 +219,7 @@ string expandId(const FSId & id, const string & target,
 
         debug(format("trying substitute %1%") % (string) subId);
 
-        Slice slice = normaliseFState(subId, pending);
-        realiseSlice(slice, pending);
+        realiseSlice(normaliseFState(subId, pending), pending);
 
         return expandId(id, target, prefix, pending);
     }
diff --git a/src/test.cc b/src/test.cc
index a2431273e71a..cff094e2f89d 100644
--- a/src/test.cc
+++ b/src/test.cc
@@ -13,8 +13,7 @@
 void realise(FSId id)
 {
     Nest nest(lvlDebug, format("TEST: realising %1%") % (string) id);
-    Slice slice = normaliseFState(id);
-    realiseSlice(slice);
+    realiseSlice(normaliseFState(id));
 }