diff --git a/Data/FileStore/Darcs.hs b/Data/FileStore/Darcs.hs
--- a/Data/FileStore/Darcs.hs
+++ b/Data/FileStore/Darcs.hs
@@ -32,7 +32,7 @@
 import Codec.Binary.UTF8.String (encodeString)
 
 import Data.ByteString.Lazy.UTF8 (toString)
-import qualified Data.ByteString.Lazy as B (ByteString, writeFile)
+import qualified Data.ByteString.Lazy as B (ByteString, writeFile, null)
 
 -- | Return a filestore implemented using the Darcs distributed revision control system
 -- (<http://darcs.net/>).
@@ -170,21 +170,29 @@
             -> Maybe RevisionId    -- ^ @Just@ revision ID, or @Nothing@ for latest
             -> IO a
 darcsRetrieve repo name mbId = do
-  ensureFileExists repo name
   let opts = case mbId of
               Nothing    -> ["contents", name]
               Just revid -> ["contents", "--match=hash " ++ revid, name]
   (status, err, output) <- runDarcsCommand repo "query" opts
+  if B.null output
+     then do
+       (_, _, out) <- runDarcsCommand repo "query" (["files", "--no-directories"] ++ opts)
+       if B.null out || null (filter (== name) . getNames $ output)
+         then throwIO NotFound else return ()
+         else return ()
   if status == ExitSuccess
      then return $ fromByteString output
      else throwIO $ UnknownError $ "Error in darcs query contents:\n" ++ err
+          
+getNames :: B.ByteString -> [String]
+getNames = map (drop 2) . lines . toString
 
 -- | Get a list of all known files inside and managed by a repository.
 darcsIndex :: FilePath ->IO [FilePath]
 darcsIndex repo = withVerifyDir repo $ do
   (status, _errOutput, output) <- runDarcsCommand repo "query"  ["files","--no-directories"]
   if status == ExitSuccess
-     then return $ map (drop 2) . lines . toString $ output
+     then return . getNames $ output
      else return []   -- return empty list if invalid path (see gitIndex)
 
 -- | Get a list of all resources inside a directory in the repository.
diff --git a/Data/FileStore/Utils.hs b/Data/FileStore/Utils.hs
--- a/Data/FileStore/Utils.hs
+++ b/Data/FileStore/Utils.hs
@@ -38,6 +38,7 @@
 import System.IO (openTempFile, hClose)
 import System.Process (runProcess, waitForProcess)
 import qualified Data.ByteString.Lazy as B
+import qualified Data.ByteString as S
 
 import Data.FileStore.Types (SearchMatch(..), FileStoreError(IllegalResourceName, NotFound, UnknownError), SearchQuery(..))
 
@@ -54,11 +55,11 @@
   (errorPath, hErr) <- openTempFile tempPath "err"
   hProcess <- runProcess (encodeString command) (map encodeString optionList) (Just workingDir) environment Nothing (Just hOut) (Just hErr)
   status <- waitForProcess hProcess
-  errorOutput <- B.readFile errorPath
-  output <- B.readFile outputPath
+  errorOutput <- S.readFile errorPath
+  output <- S.readFile outputPath
   removeFile errorPath
   removeFile outputPath
-  return (status, errorOutput, output)
+  return (status, B.fromChunks [errorOutput], B.fromChunks [output])
 
 -- | Do a three way merge, using either git merge-file or RCS merge.  Assumes
 -- that either @git@ or @merge@ is in the system path.  Assumes UTF-8 locale.
diff --git a/Tests.lhs b/Tests.lhs
--- a/Tests.lhs
+++ b/Tests.lhs
@@ -46,6 +46,7 @@
 >     , ("retrieve subdirectory (should raise error)", retrieveTest4)
 >     , ("modify resource", modifyTest)
 >     , ("delete resource", deleteTest fsName)
+>     , ("retrieve deleted file", retrieveTest5)
 >     , ("rename resource", renameTest)
 >     , ("test for matching IDs", matchTest)
 >     , ("history and revision", historyTest)
@@ -261,6 +262,15 @@
 >   catch (delete fs special testAuthor "description of change" >>
 >          (assertFailure  $ "did not return error from delete " ++ special)) $
 >          \e -> assertEqual ("error from delete " ++ special) IllegalResourceName e 
+
+*** Retrieve earlier version of deleted file:
+
+> retrieveTest5 fs = TestCase $ do
+>   hist <- history fs ["Aaack!"] (TimeRange Nothing Nothing)
+>   assertBool "history is nonempty" (not (null hist))
+>   let deletedId = revId $ last hist
+>   contents <- retrieve fs "Aaack!" (Just deletedId) :: IO String
+>   assertEqual "contents returned by retrieve" testContents contents
 
 *** Rename a resource:
 
diff --git a/filestore.cabal b/filestore.cabal
--- a/filestore.cabal
+++ b/filestore.cabal
@@ -1,5 +1,5 @@
 Name:                filestore
-Version:             0.4.0.3
+Version:             0.4.0.4
 Cabal-version:       >= 1.2
 Build-type:          Custom
 Tested-with:         GHC==6.10.1
