From 0d916443be47784173c86c25c8fb4ede764af1ba Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 18 Feb 2014 20:01:44 -0400 Subject: improve view filenames --- Annex/View.hs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'Annex/View.hs') diff --git a/Annex/View.hs b/Annex/View.hs index 0af46680b..b5d4ca227 100644 --- a/Annex/View.hs +++ b/Annex/View.hs @@ -116,7 +116,7 @@ nonEmptyList s - in some way. However, the branch's directory structure is not relevant - in the view. - - - So, from dir/subdir/file.foo, generate file{dir}{subdir}.foo + - So, from dir/subdir/file.foo, generate file_{dir;subdir}.foo - - (To avoid collisions with a filename that already contains {foo}, - that is doubled to {{foo}}.) @@ -124,7 +124,7 @@ nonEmptyList s fileViewFromReference :: MkFileView fileViewFromReference f = concat [ double base - , concatMap (\d -> "{" ++ double d ++ "}") dirs + , if null dirs then "" else "_{" ++ double (intercalate ";" dirs) ++ "}" , double $ concat extensions ] where @@ -134,6 +134,9 @@ fileViewFromReference f = concat double = replace "{" "{{" . replace "}" "}}" +fileViewReuse :: MkFileView +fileViewReuse = takeFileName + {- Generates views for a file from a branch, based on its metadata - and the filename used in the branch. - @@ -225,16 +228,14 @@ prop_view_roundtrips f metadata = null f || viewTooLarge view || - branch for the view. -} applyView :: View -> Annex Git.Branch -applyView view = do - liftIO . nukeFile =<< fromRepo gitAnnexViewIndex - applyView' fileViewFromReference view +applyView view = applyView' fileViewFromReference view {- Generates a new branch for a View, which must be a more narrow - version of the View originally used to generate the currently - checked out branch. -} narrowView :: View -> Annex Git.Branch -narrowView = applyView' id +narrowView = applyView' fileViewReuse {- Go through each file in the currently checked out branch. - If the file is not annexed, skip it, unless it's a dotfile in the top. @@ -247,6 +248,7 @@ applyView' :: MkFileView -> View -> Annex Git.Branch applyView' mkfileview view = do top <- fromRepo Git.repoPath (l, clean) <- inRepo $ Git.LsFiles.inRepo [top] + liftIO . nukeFile =<< fromRepo gitAnnexViewIndex genViewBranch view $ do uh <- inRepo Git.UpdateIndex.startUpdateIndex hasher <- inRepo hashObjectStart -- cgit v1.2.3