unused: Avoid checking view branches for unused files.

This avoids a potential slowdown when using lots of views.

I think that it makes sense for unused to ignore (local) view branches,
since these are by definition supposed to be views of an existing branch,
so looking at the branch should be sufficient (and if the view is out of
date and has files that have since been deleted from the branch, the user's
intent is not to preserve those from unused reaping).
This commit is contained in:
Joey Hess 2014-06-04 14:03:41 -04:00
parent fa13704369
commit c00b459f3a
3 changed files with 9 additions and 0 deletions

View file

@ -35,6 +35,7 @@ import qualified Annex.Branch
import Annex.CatFile import Annex.CatFile
import Types.Key import Types.Key
import Git.FilePath import Git.FilePath
import Logs.View (is_branchView)
def :: [Command] def :: [Command]
def = [withOptions [unusedFromOption] $ command "unused" paramNothing seek def = [withOptions [unusedFromOption] $ command "unused" paramNothing seek
@ -270,6 +271,7 @@ withKeysReferencedInGit a = do
ourbranchend = '/' : Git.fromRef Annex.Branch.name ourbranchend = '/' : Git.fromRef Annex.Branch.name
ourbranches (_, b) = not (ourbranchend `isSuffixOf` b) ourbranches (_, b) = not (ourbranchend `isSuffixOf` b)
&& not ("refs/synced/" `isPrefixOf` b) && not ("refs/synced/" `isPrefixOf` b)
&& not (is_branchView (Git.Ref b))
addHead headRef refs = case headRef of addHead headRef refs = case headRef of
-- if HEAD diverges from all branches (except the branch it -- if HEAD diverges from all branches (except the branch it
-- points to), run the actions on staged keys (and keys -- points to), run the actions on staged keys (and keys

View file

@ -15,6 +15,7 @@ module Logs.View (
removeView, removeView,
recentViews, recentViews,
branchView, branchView,
is_branchView,
prop_branchView_legal, prop_branchView_legal,
) where ) where
@ -87,5 +88,10 @@ branchView view
| Git.Ref.legal True s = s | Git.Ref.legal True s = s
| otherwise = map (\c -> if isAlphaNum c then c else '_') s | otherwise = map (\c -> if isAlphaNum c then c else '_') s
is_branchView :: Git.Branch -> Bool
is_branchView (Ref b)
| b == branchViewPrefix = True
| otherwise = (branchViewPrefix ++ "/") `isPrefixOf` b
prop_branchView_legal :: View -> Bool prop_branchView_legal :: View -> Bool
prop_branchView_legal = Git.Ref.legal False . fromRef . branchView prop_branchView_legal = Git.Ref.legal False . fromRef . branchView

1
debian/changelog vendored
View file

@ -7,6 +7,7 @@ git-annex (5.20140530) UNRELEASED; urgency=medium
preferred content settings when enabling or combining with preferred content settings when enabling or combining with
an already existing remote. an already existing remote.
* assistant: Make sanity checker tmp dir cleanup code more robust. * assistant: Make sanity checker tmp dir cleanup code more robust.
* unused: Avoid checking view branches for unused files.
-- Joey Hess <joeyh@debian.org> Thu, 29 May 2014 20:10:59 -0400 -- Joey Hess <joeyh@debian.org> Thu, 29 May 2014 20:10:59 -0400