aboutsummaryrefslogtreecommitdiff
path: root/Annex/View.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-18 20:01:44 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-18 20:01:44 -0400
commit0d916443be47784173c86c25c8fb4ede764af1ba (patch)
treef8ff9aa2674da0a7cea5ca6c715f017427ade156 /Annex/View.hs
parent2fb1cfc4ae0cfb3f012e074f2f855c592f866b05 (diff)
improve view filenames
Diffstat (limited to 'Annex/View.hs')
-rw-r--r--Annex/View.hs14
1 files changed, 8 insertions, 6 deletions
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