diff options
author | 2014-12-29 13:41:03 -0400 | |
---|---|---|
committer | 2014-12-29 13:42:58 -0400 | |
commit | 9315d96f700109da18f953534b0b5bab8d1440dd (patch) | |
tree | 62aa269152a1be8cab550fcff7732c29c9d6ad64 | |
parent | 17efa06748ddf67c0bc29359cedba381e7db4625 (diff) |
sync: Now supports remote groups, the same way git remote update does.
-rw-r--r-- | Command/Sync.hs | 19 | ||||
-rw-r--r-- | Remote.hs | 15 | ||||
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | doc/git-annex.mdwn | 5 | ||||
-rw-r--r-- | doc/todo/remote_groups_support_for_sync.mdwn | 2 |
5 files changed, 37 insertions, 5 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs index a89737647..28d7c69c5 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -6,7 +6,17 @@ - Licensed under the GNU GPL version 3 or higher. -} -module Command.Sync where +module Command.Sync ( + cmd, + prepMerge, + mergeLocal, + mergeRemote, + commitStaged, + pushBranch, + updateBranch, + syncBranch, + updateSyncBranch, +) where import Common.Annex import Command @@ -109,16 +119,21 @@ syncRemotes :: [String] -> Annex [Remote] syncRemotes rs = ifM (Annex.getState Annex.fast) ( nub <$> pickfast , wanted ) where pickfast = (++) <$> listed <*> (filterM good =<< fastest <$> available) + wanted | null rs = filterM good =<< concat . Remote.byCost <$> available | otherwise = listed - listed = catMaybes <$> mapM (Remote.byName . Just) rs + + listed = concat <$> mapM Remote.byNameOrGroup rs + available = filter (remoteAnnexSync . Remote.gitconfig) . filter (not . Remote.isXMPPRemote) <$> Remote.remoteList + good r | Remote.gitSyncableRemote r = Remote.Git.repoAvail $ Remote.repo r | otherwise = return True + fastest = fromMaybe [] . headMaybe . Remote.byCost commit :: CommandStart @@ -26,6 +26,7 @@ module Remote ( uuidDescriptions, byName, byName', + byNameOrGroup, byNameOnly, byNameWithUUID, byCost, @@ -94,7 +95,11 @@ addName desc n | otherwise = desc ++ " [" ++ n ++ "]" {- When a name is specified, looks up the remote matching that name. - - (Or it can be a UUID.) -} + - (Or it can be a UUID.) + - + - Throws an error if a name is specified and no matching remote can be + - found. + -} byName :: Maybe RemoteName -> Annex (Maybe Remote) byName Nothing = return Nothing byName (Just n) = either error Just <$> byName' n @@ -121,6 +126,14 @@ byName' n = go . filter matching <$> remoteList go (match:_) = Right match matching r = n == name r || toUUID n == uuid r +{- Finds the remote or remote group matching the name. -} +byNameOrGroup :: RemoteName -> Annex [Remote] +byNameOrGroup n = go =<< getConfigMaybe (ConfigKey ("remotes." ++ n)) + where + go (Just l) = concatMap maybeToList <$> + mapM (Remote.byName . Just) (split " " l) + go Nothing = maybeToList <$> Remote.byName (Just n) + {- Only matches remote name, not UUID -} byNameOnly :: RemoteName -> Annex (Maybe Remote) byNameOnly n = headMaybe . filter matching <$> remoteList diff --git a/debian/changelog b/debian/changelog index 6c1bad91b..c476ab86a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ git-annex (5.20141220) UNRELEASED; urgency=medium * vicfg: Avoid crashing on badly encoded config data. * Work around statfs() overflow on some XFS systems. + * sync: Now supports remote groups, the same way git remote update does. -- Joey Hess <id@joeyh.name> Mon, 22 Dec 2014 15:16:38 -0400 diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index dfd0b6b49..a6f638de2 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -143,8 +143,9 @@ subdirectories). * `sync [remote ...]` Use this command when you want to synchronize the local repository with - one or more of its remotes. You can specify the remotes to sync with by - name; the default is to sync with all remotes. + one or more of its remotes. You can specify the remotes (or remote + groups) to sync with by name; the default if none are specified is to + sync with all remotes. Or specify `--fast` to sync with the remotes with the lowest annex-cost value. diff --git a/doc/todo/remote_groups_support_for_sync.mdwn b/doc/todo/remote_groups_support_for_sync.mdwn index f963f0bd0..b49016427 100644 --- a/doc/todo/remote_groups_support_for_sync.mdwn +++ b/doc/todo/remote_groups_support_for_sync.mdwn @@ -1,3 +1,5 @@ `git remote update $group` looks at the $group.away git config and fetches from the listed remotes. It would be useful if `git annex sync $group` did the same. --[[Joey]] + +[[done]] |