Improve startup time for commands that do not operate on remotes
And for tab completion, by not unnessessarily statting paths to remotes, which used to cause eg, spin-up of removable drives. Got rid of the remotes member of Git.Repo. This was a bit painful. Remote.Git modifies the list of remotes as it reads their configs, so still need a persistent list of remotes. So, put it in as Annex.gitremotes. It's only populated by getGitRemotes, so commands like examinekey that don't care about remotes won't do so. This commit was sponsored by Jake Vosloo on Patreon.
This commit is contained in:
parent
d0fe4d7308
commit
2b66492d6e
22 changed files with 148 additions and 70 deletions
16
Annex.hs
16
Annex.hs
|
@ -1,6 +1,6 @@
|
|||
{- git-annex monad
|
||||
-
|
||||
- Copyright 2010-2013 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2010-2018 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
@ -34,12 +34,14 @@ module Annex (
|
|||
getRemoteGitConfig,
|
||||
withCurrentState,
|
||||
changeDirectory,
|
||||
getGitRemotes,
|
||||
incError,
|
||||
) where
|
||||
|
||||
import Common
|
||||
import qualified Git
|
||||
import qualified Git.Config
|
||||
import qualified Git.Construct
|
||||
import Annex.Fixup
|
||||
import Git.CatFile
|
||||
import Git.HashObject
|
||||
|
@ -98,6 +100,7 @@ data AnnexState = AnnexState
|
|||
{ repo :: Git.Repo
|
||||
, repoadjustment :: (Git.Repo -> IO Git.Repo)
|
||||
, gitconfig :: GitConfig
|
||||
, gitremotes :: Maybe [Git.Repo]
|
||||
, backend :: Maybe (BackendA Annex)
|
||||
, remotes :: [Types.Remote.RemoteA Annex]
|
||||
, remoteannexstate :: M.Map UUID AnnexState
|
||||
|
@ -153,6 +156,7 @@ newState c r = do
|
|||
{ repo = r
|
||||
, repoadjustment = return
|
||||
, gitconfig = c
|
||||
, gitremotes = Nothing
|
||||
, backend = Nothing
|
||||
, remotes = []
|
||||
, remoteannexstate = M.empty
|
||||
|
@ -357,3 +361,13 @@ incError = changeState $ \s ->
|
|||
let ! c = errcounter s + 1
|
||||
! s' = s { errcounter = c }
|
||||
in s'
|
||||
|
||||
getGitRemotes :: Annex [Git.Repo]
|
||||
getGitRemotes = do
|
||||
s <- getState id
|
||||
case gitremotes s of
|
||||
Just rs -> return rs
|
||||
Nothing -> do
|
||||
rs <- liftIO $ Git.Construct.fromRemotes (repo s)
|
||||
changeState $ \s' -> s' { gitremotes = Just rs }
|
||||
return rs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue