diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index 66cf29835..2a53f7c48 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -178,7 +178,7 @@ static void initAndRun(int argc, char * * argv) buildVerbosity = lvlVomit; //we need to push back since arguments need to be passed on in the state wrapper script - else if (arg == "--help") { + else if (arg == "--help" && programId != "nix-state") { printHelp(); remaining.push_back(arg); } diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 75cd72db1..ec95f729d 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -1837,6 +1837,11 @@ Path toNonSharedPathTxn(const Transaction & txn, const Path & statePath) return returnedPath; } +bool LocalStore::getSharedWith(const Path & statePath1, Path & statePath2) +{ + return querySharedStateTxn(noTxn, statePath1, statePath2); +} + PathSet toNonSharedPathSetTxn(const Transaction & txn, const PathSet & statePaths) { PathSet real_statePaths; diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh index eb300e942..33f1aecf3 100644 --- a/src/libstore/local-store.hh +++ b/src/libstore/local-store.hh @@ -110,6 +110,8 @@ public: void scanAndUpdateAllReferences(const Path & statePath, const bool recursive); + bool getSharedWith(const Path & statePath1, Path & statePath2); + PathSet toNonSharedPathSet(const PathSet & statePaths); void revertToRevision(const Path & statePath, const unsigned int revision_arg, const bool recursive); diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 6d6e24953..dc2cd14f3 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -286,7 +286,6 @@ Path RemoteStore::addTextToStore(const string & suffix, const string & s, writeString(suffix, to); writeString(s, to); writeStringSet(references, to); - processStderr(); return readStorePath(from); } @@ -310,7 +309,6 @@ Path RemoteStore::importPath(bool requireSignature, Source & source) anyway. */ processStderr(0, &source); - //Path path = readStorePath(from); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! remove return readStorePath(from); } @@ -504,6 +502,15 @@ void RemoteStore::scanAndUpdateAllReferences(const Path & statePath, const bool readInt(from); } +bool RemoteStore::getSharedWith(const Path & statePath1, Path & statePath2) +{ + writeInt(wopGetSharedWith, to); + writeString(statePath1, to); + processStderr(); + statePath2 = readString(from); + unsigned int reply = readInt(from); + return reply != 0; +} PathSet RemoteStore::toNonSharedPathSet(const PathSet & statePaths) { diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh index a259f4fa0..d67b843a6 100644 --- a/src/libstore/remote-store.hh +++ b/src/libstore/remote-store.hh @@ -96,6 +96,8 @@ public: void scanAndUpdateAllReferences(const Path & statePath, const bool recursive); + bool getSharedWith(const Path & statePath1, Path & statePath2); + PathSet toNonSharedPathSet(const PathSet & statePaths); void revertToRevision(const Path & statePath, const unsigned int revision_arg, const bool recursive); diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index fdf7bb39e..f699988d7 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -237,6 +237,9 @@ public: /* TODO */ virtual void scanAndUpdateAllReferences(const Path & statePath, const bool recursive) = 0; + /* TODO */ + virtual bool getSharedWith(const Path & statePath1, Path & statePath2) = 0; + /* TODO */ virtual PathSet toNonSharedPathSet(const PathSet & statePaths) = 0; diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh index 8775e9604..f2bfd134f 100644 --- a/src/libstore/worker-protocol.hh +++ b/src/libstore/worker-protocol.hh @@ -44,6 +44,7 @@ typedef enum { wopQueryAvailableStateRevisions, wopCommitStatePath, wopScanAndUpdateAllReferences, + wopGetSharedWith, wopToNonSharedPathSet, wopRevertToRevision, wopShareState, diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index ce7909dbd..820a5a01e 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -566,7 +566,7 @@ static void installDerivations(Globals & globals, //&& the identifiers are equal //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - //TODO && (the users are equal || OR SHARED BETWEEN USERS) + //TODO && (the users are equal || OR SHARED BETWEEN USERS) isnt this already user specific? //TODO if( newSharedState == "" && @@ -621,7 +621,6 @@ static void installDerivations(Globals & globals, store->shareState(i->second, i->first, false); } - //********************** //Let the stateDirs in /nix/state point to the solidStateDependencies diff --git a/src/nix-state/help.txt b/src/nix-state/help.txt index a217ec83c..6ebac0386 100644 --- a/src/nix-state/help.txt +++ b/src/nix-state/help.txt @@ -2,8 +2,41 @@ Usage: nix-state [OPTIONS...] [ARGUMENTS...] `nix-state' is a tool to manipulate the Nix state-store and to run programs. -Operations: +Run Operations: + --run / -r: run and commit state + --commit-only: commit state + --run-only: run + --scan-only: scan for references + +Run Options: + + --scanreferences: set scan for references + --comment=...: Add a comment for commiting + +Information: + + --showstatepath: print the state path + --showderivations: print all derivations of this path + --showrevisions: show all revisions of the state path + --showsharedpaths: show where this path points to --version: output version information --help: display help +Share state Operations: + + --unshare: unshare this path + --share-with a b: make the path a point to the path b + +Share state Options: + + --unshare-branch-state: + --unshare-restore-old-state: + +Revert state Operations: + + --revert-to-revision=x: revert to revision x + +Revert state Options: + + --revert-to-revision-recursively: revert recursively diff --git a/src/nix-state/help.txt.hh b/src/nix-state/help.txt.hh index f1bfd717b..29e347057 100644 --- a/src/nix-state/help.txt.hh +++ b/src/nix-state/help.txt.hh @@ -1 +1 @@ -static unsigned char helpText[] = {0x55, 0x73, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x6e, 0x69, 0x78, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x5b, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x2e, 0x2e, 0x2e, 0x5d, 0x20, 0x5b, 0x41, 0x52, 0x47, 0x55, 0x4d, 0x45, 0x4e, 0x54, 0x53, 0x2e, 0x2e, 0x2e, 0x5d, 0x0a, 0x0a, 0x60, 0x6e, 0x69, 0x78, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x27, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x74, 0x6f, 0x6f, 0x6c, 0x20, 0x74, 0x6f, 0x20, 0x6d, 0x61, 0x6e, 0x69, 0x70, 0x75, 0x6c, 0x61, 0x74, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x4e, 0x69, 0x78, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2d, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x74, 0x6f, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x0a, 0x0a, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x68, 0x65, 0x6c, 0x70, 0x3a, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x68, 0x65, 0x6c, 0x70, 0x0a, 0x0a, }; +static unsigned char helpText[] = {0x55, 0x73, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x6e, 0x69, 0x78, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x5b, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x2e, 0x2e, 0x2e, 0x5d, 0x20, 0x5b, 0x41, 0x52, 0x47, 0x55, 0x4d, 0x45, 0x4e, 0x54, 0x53, 0x2e, 0x2e, 0x2e, 0x5d, 0x0a, 0x0a, 0x60, 0x6e, 0x69, 0x78, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x27, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x74, 0x6f, 0x6f, 0x6c, 0x20, 0x74, 0x6f, 0x20, 0x6d, 0x61, 0x6e, 0x69, 0x70, 0x75, 0x6c, 0x61, 0x74, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x4e, 0x69, 0x78, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2d, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x74, 0x6f, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x0a, 0x0a, 0x52, 0x75, 0x6e, 0x20, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x75, 0x6e, 0x20, 0x2f, 0x20, 0x2d, 0x72, 0x3a, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x2d, 0x6f, 0x6e, 0x6c, 0x79, 0x3a, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x75, 0x6e, 0x2d, 0x6f, 0x6e, 0x6c, 0x79, 0x3a, 0x20, 0x72, 0x75, 0x6e, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x63, 0x61, 0x6e, 0x2d, 0x6f, 0x6e, 0x6c, 0x79, 0x3a, 0x20, 0x73, 0x63, 0x61, 0x6e, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x0a, 0x0a, 0x52, 0x75, 0x6e, 0x20, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x09, 0x09, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x63, 0x61, 0x6e, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x3a, 0x20, 0x73, 0x65, 0x74, 0x20, 0x73, 0x63, 0x61, 0x6e, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x3d, 0x2e, 0x2e, 0x2e, 0x3a, 0x20, 0x41, 0x64, 0x64, 0x20, 0x61, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x20, 0x0a, 0x0a, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x68, 0x6f, 0x77, 0x73, 0x74, 0x61, 0x74, 0x65, 0x70, 0x61, 0x74, 0x68, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x68, 0x6f, 0x77, 0x64, 0x65, 0x72, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x64, 0x65, 0x72, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x68, 0x6f, 0x77, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x20, 0x73, 0x68, 0x6f, 0x77, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x68, 0x6f, 0x77, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x70, 0x61, 0x74, 0x68, 0x73, 0x3a, 0x20, 0x73, 0x68, 0x6f, 0x77, 0x20, 0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x20, 0x74, 0x6f, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x68, 0x65, 0x6c, 0x70, 0x3a, 0x20, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x68, 0x65, 0x6c, 0x70, 0x0a, 0x0a, 0x53, 0x68, 0x61, 0x72, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x75, 0x6e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x3a, 0x20, 0x75, 0x6e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x70, 0x61, 0x74, 0x68, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x73, 0x68, 0x61, 0x72, 0x65, 0x2d, 0x77, 0x69, 0x74, 0x68, 0x20, 0x61, 0x20, 0x62, 0x3a, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x61, 0x20, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x62, 0x0a, 0x0a, 0x53, 0x68, 0x61, 0x72, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x75, 0x6e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x2d, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x3a, 0x20, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x75, 0x6e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x2d, 0x72, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2d, 0x6f, 0x6c, 0x64, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x3a, 0x20, 0x0a, 0x20, 0x0a, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x2d, 0x74, 0x6f, 0x2d, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x78, 0x3a, 0x20, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x78, 0x0a, 0x0a, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x20, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x0a, 0x0a, 0x20, 0x20, 0x2d, 0x2d, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x2d, 0x74, 0x6f, 0x2d, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x2d, 0x72, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x6c, 0x79, 0x3a, 0x20, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x20, 0x72, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x6c, 0x79, 0x0a, }; diff --git a/src/nix-state/nix-state.cc b/src/nix-state/nix-state.cc index 1432eb034..00befb756 100644 --- a/src/nix-state/nix-state.cc +++ b/src/nix-state/nix-state.cc @@ -32,6 +32,8 @@ bool r_scanforReferences = false; bool r_commit = true; bool r_run = true; bool revert_recursively = false; +bool unshare_branch = false; +bool unshare_restore_old = false; /************************* Build time Functions ******************************/ @@ -243,6 +245,36 @@ static void queryAvailableStateRevisions(Strings opFlags, Strings opArgs) } +static void opShowSharedPaths(Strings opFlags, Strings opArgs) +{ + Path statePath = *(opArgs.begin()); + if(!store->isValidStatePath(statePath)) + throw UsageError(format("Path '%1%' is not a valid state path.") % statePath); + + Path statePath1 = statePath; + Path statePath2; + bool isShared = false; + while(store->getSharedWith(statePath1, statePath2)) + { + isShared = true; + printMsg(lvlError, format("Path '%1%' ---is shared with---> '%2%'") % statePath1 % statePath2); + statePath1 = statePath2; + } + + if(!isShared) + printMsg(lvlError, format("Path '%1%' is not shared with another path") % statePath1); +} + +static void opUnshare(Strings opFlags, Strings opArgs) +{ + +} + +static void opShareWith(Strings opFlags, Strings opArgs) +{ + +} + static void opRunComponent(Strings opFlags, Strings opArgs) { @@ -272,8 +304,15 @@ static void opRunComponent(Strings opFlags, Strings opArgs) string root_args = ""; for (Strings::iterator i = root_program_args.begin(); i != root_program_args.end(); ++i){ - if(*i == "--help" || *i == "--version") + if(*i == "--help" || *i == "--version"){ + printMsg(lvlError, format("Usage: try --statehelp for extended state help options")); + printMsg(lvlError, format("%1%") % padd("", '-', 54)); + } + else if(*i == "--statehelp"){ printMsg(lvlError, format("%1%") % padd("", '-', 100)); + printHelp(); + } + //printMsg(lvlError, format("ARG %1%") % *i); root_args += " \"" + *i + "\""; @@ -522,7 +561,6 @@ void run(Strings args) Operation oldOp = op; //Run options - if (arg == "--run" || arg == "-r") //run and commit op = opRunComponent; else if (arg == "--commit-only"){ @@ -551,7 +589,6 @@ void run(Strings args) //Info options - else if (arg == "--showstatepath") op = opShowStatePath; else if (arg == "--showderivations") @@ -560,17 +597,28 @@ void run(Strings args) op = queryAvailableStateRevisions; - //State options - + //Revering State options else if (arg.substr(0,21) == "--revert-to-revision="){ op = revertToRevision; bool succeed = string2UnsignedInt(arg.substr(21,arg.length()), revision_arg); if(!succeed) throw UsageError("The given revision is not a valid number"); } - else if (arg.substr(0,10) == "--revert-to-revision-recursively") + else if (arg == "--revert-to-revision-recursively") revert_recursively = true; + //Shared state options + else if (arg == "--showsharedpaths") + op = opShowSharedPaths; + else if (arg == "--unshare") + op = opUnshare; + else if (arg == "--unshare-branch-state") + unshare_branch = true; + else if (arg == "--unshare-restore-old-state") + unshare_restore_old = true; + else if (arg == "--share-with") + op = opShareWith; + /* --share-from diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index 1482f9967..e7955534c 100644 --- a/src/nix-store/nix-store.cc +++ b/src/nix-store/nix-store.cc @@ -431,7 +431,7 @@ static void opRegisterSubstitutes(Strings opFlags, Strings opArgs) Substitute sub; PathSet references; - //TODO TODO TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1 + //TODO TODO TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PathSet stateReferences; getline(cin, srcPath); diff --git a/src/nix-worker/nix-worker.cc b/src/nix-worker/nix-worker.cc index 335a911d5..a0d51c052 100644 --- a/src/nix-worker/nix-worker.cc +++ b/src/nix-worker/nix-worker.cc @@ -571,6 +571,17 @@ static void performOp(Source & from, Sink & to, unsigned int op) break; } + case wopGetSharedWith: { + Path statePath1 = readString(from); + Path statePath2; + startWork(); + bool result = store->getSharedWith(statePath1, statePath2); + stopWork(); + writeString(statePath2, to); + writeInt(result, to); + break; + } + case wopToNonSharedPathSet: { PathSet statePaths = readStringSet(from); startWork();