summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-09-19 21:33:44 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-09-19 21:42:03 -0400
commit0df935bcb77efaaabaad09ff775608f8bfd6ec2e (patch)
tree87d87fd41a1ed6615dc8dba73d0068ada6db6638
parent962713122b0076222e1f61ce4989efe4eef2f12e (diff)
list --allrepos
-rw-r--r--Command/List.hs41
-rw-r--r--doc/git-annex.mdwn8
2 files changed, 36 insertions, 13 deletions
diff --git a/Command/List.hs b/Command/List.hs
index ae764ecf0..1c424cddc 100644
--- a/Command/List.hs
+++ b/Command/List.hs
@@ -9,30 +9,53 @@
module Command.List where
import qualified Data.Set as S
+import qualified Data.Map as M
+import Data.Function
+import Data.Tuple.Utils
+import Data.Ord
import Common.Annex
import Command
import Remote
import Logs.Trust
+import Logs.UUID
import Annex.UUID
+import qualified Option
+import qualified Annex
def :: [Command]
-def = [noCommit $ command "list" paramPaths seek
+def = [noCommit $ withOptions [allrepos] $ command "list" paramPaths seek
SectionQuery "show which remotes contain files"]
+allrepos :: Option
+allrepos = Option.flag [] "allrepos" "show all repositories, not only remotes"
+
seek :: [CommandSeek]
seek =
- [ withValue getList $ \l -> withNothing $ startHeader l
- , withValue getList $ \l -> withFilesInGit $ whenAnnexed $ start l
+ [ withValue getList $ withNothing . startHeader
+ , withValue getList $ withFilesInGit . whenAnnexed . start
]
getList :: Annex [(UUID, RemoteName, TrustLevel)]
-getList = do
- rs <- remoteList
- ts <- mapM (lookupTrust . uuid) rs
- hereu <- getUUID
- heretrust <- lookupTrust hereu
- return $ (hereu, "here", heretrust) : zip3 (map uuid rs) (map name rs) ts
+getList = ifM (Annex.getFlag $ Option.name allrepos)
+ ( nubBy ((==) `on` fst3) <$> ((++) <$> getRemotes <*> getAll)
+ , getRemotes
+ )
+ where
+ getRemotes = do
+ rs <- remoteList
+ ts <- mapM (lookupTrust . uuid) rs
+ hereu <- getUUID
+ heretrust <- lookupTrust hereu
+ return $ (hereu, "here", heretrust) : zip3 (map uuid rs) (map name rs) ts
+ getAll = do
+ rs <- M.toList <$> uuidMap
+ rs3 <- forM rs $ \(u, n) -> (,,)
+ <$> pure u
+ <*> pure n
+ <*> lookupTrust u
+ return $ sortBy (comparing snd3) $
+ filter (\t -> thd3 t /= DeadTrusted) rs3
startHeader :: [(UUID, RemoteName, TrustLevel)] -> CommandStart
startHeader l = do
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index da6f2c1bf..ad74e3441 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -549,14 +549,14 @@ subdirectories).
* `whereis [path ...]`
- Displays a list of repositories known to contain the contents of the
- specified file or files.
+ Displays a information about where the contents of files are located.
* `list [path ...]`
Displays a table of remotes that contain the contents of the specified
- files. Unlike whereis, this only shows configured remotes, not other
- repositories. However it is a more compact display.
+ files. This is similar to whereis but a more compact display. Only
+ configured remotes are shown by default; specify --allrepos to list
+ all repositories.
* `log [path ...]`