From c00b459f3a401f02ea0bbc28cbe7a0def4126795 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 4 Jun 2014 14:03:41 -0400 Subject: [PATCH] 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). --- Command/Unused.hs | 2 ++ Logs/View.hs | 6 ++++++ debian/changelog | 1 + 3 files changed, 9 insertions(+) diff --git a/Command/Unused.hs b/Command/Unused.hs index 5815bbf298..6737109f6f 100644 --- a/Command/Unused.hs +++ b/Command/Unused.hs @@ -35,6 +35,7 @@ import qualified Annex.Branch import Annex.CatFile import Types.Key import Git.FilePath +import Logs.View (is_branchView) def :: [Command] def = [withOptions [unusedFromOption] $ command "unused" paramNothing seek @@ -270,6 +271,7 @@ withKeysReferencedInGit a = do ourbranchend = '/' : Git.fromRef Annex.Branch.name ourbranches (_, b) = not (ourbranchend `isSuffixOf` b) && not ("refs/synced/" `isPrefixOf` b) + && not (is_branchView (Git.Ref b)) addHead headRef refs = case headRef of -- if HEAD diverges from all branches (except the branch it -- points to), run the actions on staged keys (and keys diff --git a/Logs/View.hs b/Logs/View.hs index 79c2556b3b..b2a92c4057 100644 --- a/Logs/View.hs +++ b/Logs/View.hs @@ -15,6 +15,7 @@ module Logs.View ( removeView, recentViews, branchView, + is_branchView, prop_branchView_legal, ) where @@ -87,5 +88,10 @@ branchView view | Git.Ref.legal True s = 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 = Git.Ref.legal False . fromRef . branchView diff --git a/debian/changelog b/debian/changelog index 1829325a32..0de7c25f83 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,7 @@ git-annex (5.20140530) UNRELEASED; urgency=medium preferred content settings when enabling or combining with an already existing remote. * assistant: Make sanity checker tmp dir cleanup code more robust. + * unused: Avoid checking view branches for unused files. -- Joey Hess Thu, 29 May 2014 20:10:59 -0400