reorg
authorJoey Hess <joeyh@joeyh.name>
Tue, 15 Dec 2015 19:34:28 +0000 (15:34 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 15 Dec 2015 19:34:28 +0000 (15:34 -0400)
Annex/Direct.hs
Annex/View.hs
Annex/WorkTree.hs [new file with mode: 0644]
Assistant/Threads/TransferScanner.hs
Assistant/Threads/Watcher.hs
Backend.hs
Command.hs
Command/Unused.hs
Command/Upgrade.hs
Limit.hs
Test.hs

index 8fced2d4440b16c9e2ef0942bd1ba39b83bfe5fd..8c3d5bb562124acd5d560bda0f5b909fa9aa7dd2 100644 (file)
@@ -399,7 +399,7 @@ changedDirect oldk f = do
        whenM (pure (null locs) <&&> not <$> inAnnex oldk) $
                logStatus oldk InfoMissing
 
-{- Enable/disable direct mode. -}
+{- Git config settings to enable/disable direct mode. -}
 setDirect :: Bool -> Annex ()
 setDirect wantdirect = do
        if wantdirect
index 567522a541e32dd9096bde08056680d5d1bd9e17..8ddbb9c638cf17b01453277cd84aac4e8a0d4da1 100644 (file)
@@ -22,7 +22,7 @@ import Git.Sha
 import Git.HashObject
 import Git.Types
 import Git.FilePath
-import qualified Backend
+import Annex.WorkTree
 import Annex.Index
 import Annex.Link
 import Annex.CatFile
@@ -342,7 +342,7 @@ applyView' mkviewedfile getfilemetadata view = do
                hasher <- inRepo hashObjectStart
                forM_ l $ \f -> do
                        relf <- getTopFilePath <$> inRepo (toTopFilePath f)
-                       go uh hasher relf =<< Backend.lookupFile f
+                       go uh hasher relf =<< lookupFile f
                liftIO $ do
                        hashObjectStop hasher
                        void $ stopUpdateIndex uh
diff --git a/Annex/WorkTree.hs b/Annex/WorkTree.hs
new file mode 100644 (file)
index 0000000..26144e7
--- /dev/null
@@ -0,0 +1,35 @@
+{- git-annex worktree files
+ -
+ - Copyright 2013-2015 Joey Hess <id@joeyh.name>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Annex.WorkTree where
+
+import Common.Annex
+import Annex.Link
+import Annex.CatFile
+
+{- Looks up the key corresponding to an annexed file,
+ - by examining what the file links to.
+ -
+ - An unlocked file will not have a link on disk, so fall back to
+ - looking for a pointer to a key in git.
+ -}
+lookupFile :: FilePath -> Annex (Maybe Key)
+lookupFile file = do
+       mkey <- isAnnexLink file
+       case mkey of
+               Just key -> makeret key
+               Nothing -> maybe (return Nothing) makeret =<< catKeyFile file
+  where
+       makeret = return . Just
+
+{- Modifies an action to only act on files that are already annexed,
+ - and passes the key on to it. -}
+whenAnnexed :: (FilePath -> Key -> Annex (Maybe a)) -> FilePath -> Annex (Maybe a)
+whenAnnexed a file = ifAnnexed file (a file) (return Nothing)
+
+ifAnnexed :: FilePath -> (Key -> Annex a) -> Annex a -> Annex a
+ifAnnexed file yes no = maybe no yes =<< lookupFile file
index f35c1f1f536e1c93a151279fcfe2d0a50f962800..7386d5528687a6e9572d874be102b1a98709f154 100644 (file)
@@ -25,7 +25,7 @@ import Utility.ThreadScheduler
 import Utility.NotificationBroadcaster
 import Utility.Batch
 import qualified Git.LsFiles as LsFiles
-import qualified Backend
+import Annex.WorkTree
 import Annex.Content
 import Annex.Wanted
 import CmdLine.Action
@@ -142,7 +142,7 @@ expensiveScan urlrenderer rs = batch <~> do
                (unwanted', ts) <- maybe
                        (return (unwanted, []))
                        (findtransfers f unwanted)
-                               =<< liftAnnex (Backend.lookupFile f)
+                               =<< liftAnnex (lookupFile f)
                mapM_ (enqueue f) ts
                scan unwanted' fs
 
index 8c6ff378dd49e856e1129a73b7f438acf72aed38..37e0154b45be12a6532485231b155cfcbb6dec17 100644 (file)
@@ -28,7 +28,7 @@ import qualified Annex.Queue
 import qualified Git
 import qualified Git.UpdateIndex
 import qualified Git.LsFiles as LsFiles
-import qualified Backend
+import Annex.WorkTree
 import Annex.Direct
 import Annex.Content.Direct
 import Annex.CatFile
@@ -270,7 +270,7 @@ onAddDirect symlinkssupported matcher file fs = do
 onAddSymlink :: Bool -> Handler
 onAddSymlink isdirect file filestatus = unlessIgnored file $ do
        linktarget <- liftIO (catchMaybeIO $ readSymbolicLink file)
-       kv <- liftAnnex (Backend.lookupFile file)
+       kv <- liftAnnex (lookupFile file)
        onAddSymlink' linktarget kv isdirect file filestatus
 
 onAddSymlink' :: Maybe String -> Maybe Key -> Bool -> Handler
index d37eed34afb7877061ec7695ddf1a94f8e02c5a0..c2f3d28d412a0934d441f973bfa40bc72de9253d 100644 (file)
@@ -9,7 +9,6 @@ module Backend (
        list,
        orderedList,
        genKey,
-       lookupFile,
        getBackend,
        chooseBackend,
        lookupBackendName,
@@ -20,8 +19,6 @@ module Backend (
 import Common.Annex
 import qualified Annex
 import Annex.CheckAttr
-import Annex.CatFile
-import Annex.Link
 import Types.Key
 import Types.KeySource
 import qualified Types.Backend as B
@@ -76,21 +73,6 @@ genKey' (b:bs) source = do
                | c == '\n' = '_'
                | otherwise = c
 
-{- Looks up the key corresponding to an annexed file,
- - by examining what the file links to.
- -
- - An unlocked file will not have a link on disk, so fall back to
- - looking for a pointer to a key in git.
- -}
-lookupFile :: FilePath -> Annex (Maybe Key)
-lookupFile file = do
-       mkey <- isAnnexLink file
-       case mkey of
-               Just key -> makeret key
-               Nothing -> maybe (return Nothing) makeret =<< catKeyFile file
-  where
-       makeret = return . Just
-
 getBackend :: FilePath -> Key -> Annex (Maybe Backend)
 getBackend file k = let bname = keyBackendName k in
        case maybeLookupBackendName bname of
index bee63bb741fa66ae533b0962e5c66560ab2676d0..387f7b8b562629395ce67dbfb8f4ba031d9cb37b 100644 (file)
@@ -18,12 +18,13 @@ module Command (
        stopUnless,
        whenAnnexed,
        ifAnnexed,
+       lookupFile,
        isBareRepo,
        module ReExported
 ) where
 
 import Common.Annex
-import qualified Backend
+import Annex.WorkTree
 import qualified Git
 import Types.Command as ReExported
 import Types.Option as ReExported
@@ -100,13 +101,5 @@ stop = return Nothing
 stopUnless :: Annex Bool -> Annex (Maybe a) -> Annex (Maybe a)
 stopUnless c a = ifM c ( a , stop )
 
-{- Modifies an action to only act on files that are already annexed,
- - and passes the key on to it. -}
-whenAnnexed :: (FilePath -> Key -> Annex (Maybe a)) -> FilePath -> Annex (Maybe a)
-whenAnnexed a file = ifAnnexed file (a file) (return Nothing)
-
-ifAnnexed :: FilePath -> (Key -> Annex a) -> Annex a -> Annex a
-ifAnnexed file yes no = maybe no yes =<< Backend.lookupFile file
-
 isBareRepo :: Annex Bool
 isBareRepo = fromRepo Git.repoIsLocalBare
index 4756cda5df54d44cfa8968166409b67ecbf10cbc..4353bd075e746ea354a548e331c62fff8549f274 100644 (file)
@@ -24,7 +24,6 @@ import qualified Git.Branch
 import qualified Git.RefLog
 import qualified Git.LsFiles as LsFiles
 import qualified Git.DiffTree as DiffTree
-import qualified Backend
 import qualified Remote
 import qualified Annex.Branch
 import Annex.CatFile
@@ -215,7 +214,7 @@ withKeysReferenced' mdir initial a = do
                Just dir -> inRepo $ LsFiles.inRepo [dir]
        go v [] = return v
        go v (f:fs) = do
-               x <- Backend.lookupFile f
+               x <- lookupFile f
                case x of
                        Nothing -> go v fs
                        Just k -> do
@@ -266,7 +265,7 @@ withKeysReferencedInGitRef a ref = do
        forM_ ts $ tKey lookAtWorkingTree >=> maybe noop a
        liftIO $ void clean
   where
-       tKey True = Backend.lookupFile . getTopFilePath . DiffTree.file
+       tKey True = lookupFile . getTopFilePath . DiffTree.file
        tKey False = fileKey . takeFileName . decodeBS <$$>
                catFile ref . getTopFilePath . DiffTree.file
 
index c02a6709f9c92654dc671c454e8083185a0b86cb..8a34022e3c82f3a7fabd4c41d4c29b6a071cc959 100644 (file)
@@ -13,6 +13,7 @@ import Upgrade
 
 cmd :: Command
 cmd = dontCheck repoExists $ -- because an old version may not seem to exist
+       noDaemonRunning $ -- avoid upgrading repo out from under daemon
        command "upgrade" SectionMaintenance "upgrade repository layout"
                paramNothing (withParams seek)
 
index 321c1122b3997a34c484615440eb49daf27097d6..437c65bc35deab320f079e283c73289bd535f8d8 100644 (file)
--- a/Limit.hs
+++ b/Limit.hs
@@ -11,8 +11,8 @@ import Common.Annex
 import qualified Annex
 import qualified Utility.Matcher
 import qualified Remote
-import qualified Backend
 import Annex.Content
+import Annex.WorkTree
 import Annex.Action
 import Annex.UUID
 import Logs.Trust
@@ -277,7 +277,7 @@ addTimeLimit s = do
                        else return True
 
 lookupFileKey :: FileInfo -> Annex (Maybe Key)
-lookupFileKey = Backend.lookupFile . currFile
+lookupFileKey = lookupFile . currFile
 
 checkKey :: (Key -> Annex Bool) -> MatchInfo -> Annex Bool
 checkKey a (MatchingFile fi) = lookupFileKey fi >>= maybe (return False) a
diff --git a/Test.hs b/Test.hs
index f4035f60517176b10013c419f50b331df503fc9d..1a0601b35cd68c49a700a68d5c3617d55a27f37b 100644 (file)
--- a/Test.hs
+++ b/Test.hs
@@ -65,6 +65,7 @@ import qualified Types.Messages
 import qualified Config
 import qualified Config.Cost
 import qualified Crypto
+import qualified Annex.WorkTree
 import qualified Annex.Init
 import qualified Annex.CatFile
 import qualified Annex.View
@@ -810,7 +811,7 @@ test_unused = intmpclonerepoInDirect $ do
                assertEqual ("unused keys differ " ++ desc)
                        (sort expectedkeys) (sort unusedkeys)
        findkey f = do
-               r <- Backend.lookupFile f
+               r <- Annex.WorkTree.lookupFile f
                return $ fromJust r
 
 test_describe :: Assertion
@@ -1380,7 +1381,7 @@ test_crypto = do
                        (c,k) <- annexeval $ do
                                uuid <- Remote.nameToUUID "foo"
                                rs <- Logs.Remote.readRemoteLog
-                               Just k <- Backend.lookupFile annexedfile
+                               Just k <- Annex.WorkTree.lookupFile annexedfile
                                return (fromJust $ M.lookup uuid rs, k)
                        let key = if scheme `elem` ["hybrid","pubkey"]
                                        then Just $ Utility.Gpg.KeyIds [Utility.Gpg.testKeyId]
@@ -1684,7 +1685,7 @@ checkdangling f = ifM (annexeval Config.crippledFileSystem)
 checklocationlog :: FilePath -> Bool -> Assertion
 checklocationlog f expected = do
        thisuuid <- annexeval Annex.UUID.getUUID
-       r <- annexeval $ Backend.lookupFile f
+       r <- annexeval $ Annex.WorkTree.lookupFile f
        case r of
                Just k -> do
                        uuids <- annexeval $ Remote.keyLocations k
@@ -1695,7 +1696,7 @@ checklocationlog f expected = do
 checkbackend :: FilePath -> Types.Backend -> Assertion
 checkbackend file expected = do
        b <- annexeval $ maybe (return Nothing) (Backend.getBackend file) 
-               =<< Backend.lookupFile file
+               =<< Annex.WorkTree.lookupFile file
        assertEqual ("backend for " ++ file) (Just expected) b
 
 inlocationlog :: FilePath -> Assertion