about summary refs log tree commit diff
path: root/src/nix.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-07-10T18·48+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-07-10T18·48+0000
commite5fbf5804192fa62d0edab0f6b323cc0c8d890f9 (patch)
treeecc024478f0e30692cb12560b9a8b9ae79c30bcf /src/nix.cc
parent8511571f653fcfbb724061dac330c544b6048722 (diff)
* A command to register successor fstate expressions.
  Unifying substitutes and successors isn't very feasible for now,
  since substitutes are only used when no path with a certain is
  known.  Therefore, a normal form of some expression stored as a
  substitute would not be used unless the expression itself was
  missing.

Diffstat (limited to 'src/nix.cc')
-rw-r--r--src/nix.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/nix.cc b/src/nix.cc
index 53057328dd57..19c73165cdc8 100644
--- a/src/nix.cc
+++ b/src/nix.cc
@@ -26,6 +26,7 @@ static ArgType argType = atpUnknown;
      --add / -A: copy a path to the Nix store
      --query / -q: query information
 
+     --successor: register a successor expression
      --substitute: register a substitute expression
 
      --dump: dump a path as a Nix archive
@@ -183,6 +184,21 @@ static void opQuery(Strings opFlags, Strings opArgs)
 }
 
 
+static void opSuccessor(Strings opFlags, Strings opArgs)
+{
+    if (!opFlags.empty()) throw UsageError("unknown flag");
+    if (opArgs.size() % 2) throw UsageError("expecting even number of arguments");
+    
+    for (Strings::iterator i = opArgs.begin();
+         i != opArgs.end(); )
+    {
+        Hash fsHash = parseHash(*i++);
+        Hash scHash = parseHash(*i++);
+        registerSuccessor(fsHash, scHash);
+    }
+}
+
+
 static void opSubstitute(Strings opFlags, Strings opArgs)
 {
     if (!opFlags.empty()) throw UsageError("unknown flag");
@@ -288,6 +304,8 @@ void run(Strings args)
             op = opAdd;
         else if (arg == "--query" || arg == "-q")
             op = opQuery;
+        else if (arg == "--successor")
+            op = opSuccessor;
         else if (arg == "--substitute")
             op = opSubstitute;
         else if (arg == "--dump")