aboutsummaryrefslogtreecommitdiff
path: root/Annex.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Annex.hs')
-rw-r--r--Annex.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/Annex.hs b/Annex.hs
index 2a17fffe1..117bd2862 100644
--- a/Annex.hs
+++ b/Annex.hs
@@ -31,6 +31,7 @@ module Annex (
getGitConfig,
changeGitConfig,
changeGitRepo,
+ withCurrentState,
) where
import "mtl" Control.Monad.State.Strict
@@ -216,3 +217,13 @@ changeGitRepo r = changeState $ \s -> s
{ repo = r
, gitconfig = extractGitConfig r
}
+
+{- Converts an Annex action into an IO action, that runs with a copy
+ - of the current Annex state.
+ -
+ - Use with caution; the action should not rely on changing the
+ - state, as it will be thrown away. -}
+withCurrentState :: Annex a -> Annex (IO a)
+withCurrentState a = do
+ s <- getState id
+ return $ eval s a