improve view filenames
This commit is contained in:
parent
67fd06af76
commit
5790acc19f
1 changed files with 8 additions and 6 deletions
|
@ -116,7 +116,7 @@ nonEmptyList s
|
||||||
- in some way. However, the branch's directory structure is not relevant
|
- in some way. However, the branch's directory structure is not relevant
|
||||||
- in the view.
|
- 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},
|
- (To avoid collisions with a filename that already contains {foo},
|
||||||
- that is doubled to {{foo}}.)
|
- that is doubled to {{foo}}.)
|
||||||
|
@ -124,7 +124,7 @@ nonEmptyList s
|
||||||
fileViewFromReference :: MkFileView
|
fileViewFromReference :: MkFileView
|
||||||
fileViewFromReference f = concat
|
fileViewFromReference f = concat
|
||||||
[ double base
|
[ double base
|
||||||
, concatMap (\d -> "{" ++ double d ++ "}") dirs
|
, if null dirs then "" else "_{" ++ double (intercalate ";" dirs) ++ "}"
|
||||||
, double $ concat extensions
|
, double $ concat extensions
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
|
@ -134,6 +134,9 @@ fileViewFromReference f = concat
|
||||||
|
|
||||||
double = replace "{" "{{" . replace "}" "}}"
|
double = replace "{" "{{" . replace "}" "}}"
|
||||||
|
|
||||||
|
fileViewReuse :: MkFileView
|
||||||
|
fileViewReuse = takeFileName
|
||||||
|
|
||||||
{- Generates views for a file from a branch, based on its metadata
|
{- Generates views for a file from a branch, based on its metadata
|
||||||
- and the filename used in the branch.
|
- and the filename used in the branch.
|
||||||
-
|
-
|
||||||
|
@ -225,16 +228,14 @@ prop_view_roundtrips f metadata = null f || viewTooLarge view ||
|
||||||
- branch for the view.
|
- branch for the view.
|
||||||
-}
|
-}
|
||||||
applyView :: View -> Annex Git.Branch
|
applyView :: View -> Annex Git.Branch
|
||||||
applyView view = do
|
applyView view = applyView' fileViewFromReference view
|
||||||
liftIO . nukeFile =<< fromRepo gitAnnexViewIndex
|
|
||||||
applyView' fileViewFromReference view
|
|
||||||
|
|
||||||
{- Generates a new branch for a View, which must be a more narrow
|
{- Generates a new branch for a View, which must be a more narrow
|
||||||
- version of the View originally used to generate the currently
|
- version of the View originally used to generate the currently
|
||||||
- checked out branch.
|
- checked out branch.
|
||||||
-}
|
-}
|
||||||
narrowView :: View -> Annex Git.Branch
|
narrowView :: View -> Annex Git.Branch
|
||||||
narrowView = applyView' id
|
narrowView = applyView' fileViewReuse
|
||||||
|
|
||||||
{- Go through each file in the currently checked out branch.
|
{- 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.
|
- 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
|
applyView' mkfileview view = do
|
||||||
top <- fromRepo Git.repoPath
|
top <- fromRepo Git.repoPath
|
||||||
(l, clean) <- inRepo $ Git.LsFiles.inRepo [top]
|
(l, clean) <- inRepo $ Git.LsFiles.inRepo [top]
|
||||||
|
liftIO . nukeFile =<< fromRepo gitAnnexViewIndex
|
||||||
genViewBranch view $ do
|
genViewBranch view $ do
|
||||||
uh <- inRepo Git.UpdateIndex.startUpdateIndex
|
uh <- inRepo Git.UpdateIndex.startUpdateIndex
|
||||||
hasher <- inRepo hashObjectStart
|
hasher <- inRepo hashObjectStart
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue