From a7e7dda55a82cb5007c5eaa2f7752f5cefdcb1d2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 30 Sep 2011 02:23:24 -0400 Subject: [PATCH] Fix referring to remotes by uuid. I think that I broke this in some fairly recent refactoring. --- Remote.hs | 12 +++++++++--- debian/changelog | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Remote.hs b/Remote.hs index 0ce01872ac..05f70a5d7f 100644 --- a/Remote.hs +++ b/Remote.hs @@ -87,7 +87,8 @@ genList = do u <- getUUID r generate t r u (M.lookup u m) -{- Looks up a remote by name. (Or by UUID.) -} +{- Looks up a remote by name. (Or by UUID.) Only finds currently configured + - git remotes. -} byName :: String -> Annex (Remote Annex) byName n = do res <- byName' n @@ -106,7 +107,8 @@ byName' n = do matching r = n == name r || n == uuid r {- Looks up a remote by name (or by UUID, or even by description), - - and returns its UUID. -} + - and returns its UUID. Finds even remotes that are not configured in + - .git/config. -} nameToUUID :: String -> Annex UUID nameToUUID "." = getUUID =<< Annex.gitRepo -- special case for current repo nameToUUID n = do @@ -115,7 +117,11 @@ nameToUUID n = do Left e -> fromMaybe (error e) <$> byDescription Right r -> return $ uuid r where - byDescription = M.lookup n . invertMap <$> uuidMap + byDescription = do + m <- uuidMap + case M.lookup n $ invertMap m of + Just u -> return $ Just u + Nothing -> return $ M.lookup n m invertMap = M.fromList . map swap . M.toList swap (a, b) = (b, a) diff --git a/debian/changelog b/debian/changelog index 62b65333d1..5354e710db 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ git-annex (3.20110929) UNRELEASED; urgency=low * Various speed improvements gained by using ByteStrings. + * Fix referring to remotes by uuid. -- Joey Hess Thu, 29 Sep 2011 18:58:53 -0400