diff options
author | Joey Hess <joeyh@debian.org> | 2014-04-02 21:42:53 +0100 |
---|---|---|
committer | Joey Hess <joeyh@debian.org> | 2014-04-02 21:42:53 +0100 |
commit | 6da7cdf0fbf26f1faf7d5710e6ed488f1a4e9589 (patch) | |
tree | 7a903e2eca579335b7ce73d0220854e7a25c3bb9 /Logs/View.hs |
git-annex (5.20140402) unstable; urgency=medium
* unannex, uninit: Avoid committing after every file is unannexed,
for massive speedup.
* --notify-finish switch will cause desktop notifications after each
file upload/download/drop completes
(using the dbus Desktop Notifications Specification)
* --notify-start switch will show desktop notifications when each
file upload/download starts.
* webapp: Automatically install Nautilus integration scripts
to get and drop files.
* tahoe: Pass -d parameter before subcommand; putting it after
the subcommand no longer works with tahoe-lafs version 1.10.
(Thanks, Alberto Berti)
* forget --drop-dead: Avoid removing the dead remote from the trust.log,
so that if git remotes for it still exist anywhere, git annex info
will still know it's dead and not show it.
* git-annex-shell: Make configlist automatically initialize
a remote git repository, as long as a git-annex branch has
been pushed to it, to simplify setup of remote git repositories,
including via gitolite.
* add --include-dotfiles: New option, perhaps useful for backups.
* Version 5.20140227 broke creation of glacier repositories,
not including the datacenter and vault in their configuration.
This bug is fixed, but glacier repositories set up with the broken
version of git-annex need to have the datacenter and vault set
in order to be usable. This can be done using git annex enableremote
to add the missing settings. For details, see
http://git-annex.branchable.com/bugs/problems_with_glacier/
* Added required content configuration.
* assistant: Improve ssh authorized keys line generated in local pairing
or for a remote ssh server to set environment variables in an
alternative way that works with the non-POSIX fish shell, as well
as POSIX shells.
# imported from the archive
Diffstat (limited to 'Logs/View.hs')
-rw-r--r-- | Logs/View.hs | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/Logs/View.hs b/Logs/View.hs new file mode 100644 index 000000000..79c2556b3 --- /dev/null +++ b/Logs/View.hs @@ -0,0 +1,91 @@ +{- git-annex recent views log + - + - The most recently accessed view comes first. + - + - This file is stored locally in .git/annex/, not in the git-annex branch. + - + - Copyright 2014 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Logs.View ( + currentView, + setView, + removeView, + recentViews, + branchView, + prop_branchView_legal, +) where + +import Common.Annex +import Types.View +import Types.MetaData +import qualified Git +import qualified Git.Branch +import qualified Git.Ref +import Git.Types +import Utility.Tmp + +import qualified Data.Set as S +import Data.Char + +setView :: View -> Annex () +setView v = do + old <- take 99 . filter (/= v) <$> recentViews + writeViews (v : old) + +writeViews :: [View] -> Annex () +writeViews l = do + f <- fromRepo gitAnnexViewLog + liftIO $ viaTmp writeFile f $ unlines $ map show l + +removeView :: View -> Annex () +removeView v = writeViews =<< filter (/= v) <$> recentViews + +recentViews :: Annex [View] +recentViews = do + f <- fromRepo gitAnnexViewLog + liftIO $ mapMaybe readish . lines <$> catchDefaultIO [] (readFile f) + +{- Gets the currently checked out view, if there is one. -} +currentView :: Annex (Maybe View) +currentView = go =<< inRepo Git.Branch.current + where + go (Just b) | branchViewPrefix `isPrefixOf` fromRef b = + headMaybe . filter (\v -> branchView v == b) <$> recentViews + go _ = return Nothing + +branchViewPrefix :: String +branchViewPrefix = "refs/heads/views" + +{- Generates a git branch name for a View. + - + - There is no guarantee that each view gets a unique branch name, + - but the branch name is used to express the view as well as possible. + -} +branchView :: View -> Git.Branch +branchView view + | null name = Git.Ref branchViewPrefix + | otherwise = Git.Ref $ branchViewPrefix ++ "/" ++ name + where + name = intercalate ";" $ map branchcomp (viewComponents view) + branchcomp c + | viewVisible c = branchcomp' c + | otherwise = "(" ++ branchcomp' c ++ ")" + branchcomp' (ViewComponent metafield viewfilter _) =concat + [ forcelegal (fromMetaField metafield) + , branchvals viewfilter + ] + branchvals (FilterValues set) = '=' : branchset set + branchvals (FilterGlob glob) = '=' : forcelegal glob + branchvals (ExcludeValues set) = "!=" ++ branchset set + branchset = intercalate "," + . map (forcelegal . fromMetaValue) + . S.toList + forcelegal s + | Git.Ref.legal True s = s + | otherwise = map (\c -> if isAlphaNum c then c else '_') s + +prop_branchView_legal :: View -> Bool +prop_branchView_legal = Git.Ref.legal False . fromRef . branchView |