getOnePatchset :: (RepoPatch p, ApplyState p ~ Tree)
               => Repository p wR wU wT
               -> [MatchFlag]
               -> IO (SealedPatchSet p Origin)
getOnePatchset repository fs =
    case nonrangeMatcher fs of
        Just m -> do ps <- readRepo repository
                     if nonrangeMatcherIsTag fs
                        then return $ getMatchingTag m ps
                        else return $ matchAPatchset m ps
        Nothing -> seal `fmap` (scanContextFile . toFilePath . context_f $ fs)
    where context_f [] = bug "Couldn't match_nonrange_patchset"
          context_f (Context f:_) = f
          context_f (_:xs) = context_f xs
getOnePatchset :: (RepoPatch p, ApplyState p ~ Tree)
               => Repository p wR wU wT
               -> [MatchFlag]
               -> IO (SealedPatchSet p Origin)
getOnePatchset repository fs =
    case nonrangeMatcher fs of
        Just m -> do ps <- readRepo repository
                     if nonrangeMatcherIsTag fs
                        then return $ getMatchingTag m ps
                        else return $ matchAPatchset m ps
        Nothing -> seal `fmap` (scanContextFile . toFilePath . context_f $ fs)
    where context_f [] = bug "Couldn't match_nonrange_patchset"
          context_f (Context f:_) = f
          context_f (_:xs) = context_f xs
getOnePatchset repository fs =
    case nonrangeMatcher fs of
        Just m -> do ps <- readRepo repository
                     if nonrangeMatcherIsTag fs
                        then return $ getMatchingTag m ps
                        else return $ matchAPatchset m ps
        Nothing -> seal `fmap` (scanContextFile . toFilePath . context_f $ fs)
    where context_f [] = bug "Couldn't match_nonrange_patchset"
          context_f (Context f:_) = f
          context_f (_:xs) = context_f xs