summaryrefslogtreecommitdiff
path: root/Remote.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-08-26 14:45:47 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-08-26 14:45:47 -0400
commitc58d5532651f78e8bf0266b818d5480d282b26e6 (patch)
treeda4f480d13b06aaf51416dc02128492705960741 /Remote.hs
parentf4ca592cd0ac4940645f2f17fadac5e0da45424d (diff)
refactor
Diffstat (limited to 'Remote.hs')
-rw-r--r--Remote.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/Remote.hs b/Remote.hs
index ae5a231ad..a5686dd44 100644
--- a/Remote.hs
+++ b/Remote.hs
@@ -24,6 +24,7 @@ module Remote (
remoteMap,
uuidDescriptions,
byName,
+ byCost,
prettyPrintUUIDs,
prettyListUUIDs,
remotesWithUUID,
@@ -224,3 +225,10 @@ forceTrust level remotename = do
- on the remote, but this cannot always be relied on. -}
logStatus :: Remote -> Key -> LogStatus -> Annex ()
logStatus remote key = logChange key (uuid remote)
+
+{- Orders remotes by cost, with ones with the lowest cost grouped together. -}
+byCost :: [Remote] -> [[Remote]]
+byCost = map snd . sort . M.toList . costmap
+ where
+ costmap = M.fromListWith (++) . map costpair
+ costpair r = (cost r, [r])