view: Avoid using cute unicode homomorphs for '/' and '\' and instead use ugly escaping, as the unicode method doesn't work on non-unicode supporting systems.
This commit is contained in:
parent
6b963426a0
commit
42619e2231
5 changed files with 39 additions and 20 deletions
|
@ -226,32 +226,22 @@ toViewPath :: MetaValue -> FilePath
|
|||
toViewPath = concatMap escapeslash . fromMetaValue
|
||||
where
|
||||
escapeslash c
|
||||
| c == '/' = [pseudoSlash]
|
||||
| c == '\\' = [pseudoBackslash]
|
||||
| c == pseudoSlash = [pseudoSlash, pseudoSlash]
|
||||
| c == pseudoBackslash = [pseudoBackslash, pseudoBackslash]
|
||||
| c == '/' = "%_"
|
||||
| c == '\\' = "%."
|
||||
| c == '%' = "%%"
|
||||
| otherwise = [c]
|
||||
|
||||
fromViewPath :: FilePath -> MetaValue
|
||||
fromViewPath = toMetaValue . deescapeslash []
|
||||
where
|
||||
deescapeslash s [] = reverse s
|
||||
deescapeslash s (c:cs)
|
||||
| c == pseudoSlash = case cs of
|
||||
(c':cs')
|
||||
| c' == pseudoSlash -> deescapeslash (pseudoSlash:s) cs'
|
||||
_ -> deescapeslash ('/':s) cs
|
||||
| c == pseudoBackslash = case cs of
|
||||
(c':cs')
|
||||
| c' == pseudoBackslash -> deescapeslash (pseudoBackslash:s) cs'
|
||||
_ -> deescapeslash ('/':s) cs
|
||||
| otherwise = deescapeslash (c:s) cs
|
||||
deescapeslash s ('%':'_':cs) = deescapeslash ('/':s) cs
|
||||
deescapeslash s ('%':'.':cs) = deescapeslash ('\\':s) cs
|
||||
deescapeslash s ('%':'%':cs) = deescapeslash ('%':s) cs
|
||||
deescapeslash s (c:cs) = deescapeslash (c:s) cs
|
||||
|
||||
pseudoSlash :: Char
|
||||
pseudoSlash = '\8725' -- '∕' /= '/'
|
||||
|
||||
pseudoBackslash :: Char
|
||||
pseudoBackslash = '\9586' -- '╲' /= '\'
|
||||
prop_viewPath_roundtrips :: MetaValue -> Bool
|
||||
prop_viewPath_roundtrips v = fromViewPath (toViewPath v) == v
|
||||
|
||||
pathProduct :: [[FilePath]] -> [FilePath]
|
||||
pathProduct [] = []
|
||||
|
|
1
Test.hs
1
Test.hs
|
@ -173,6 +173,7 @@ properties = localOption (QuickCheckTests 1000) $ testGroup "QuickCheck"
|
|||
, testProperty "prop_metadata_sane" Types.MetaData.prop_metadata_sane
|
||||
, testProperty "prop_metadata_serialize" Types.MetaData.prop_metadata_serialize
|
||||
, testProperty "prop_branchView_legal" Logs.View.prop_branchView_legal
|
||||
, testProperty "prop_viewPath_roundtrips" Annex.View.prop_viewPath_roundtrips
|
||||
, testProperty "prop_view_roundtrips" Annex.View.prop_view_roundtrips
|
||||
, testProperty "prop_viewedFile_rountrips" Annex.View.ViewedFile.prop_viewedFile_roundtrips
|
||||
, testProperty "prop_b64_roundtrips" Utility.Base64.prop_b64_roundtrips
|
||||
|
|
4
debian/changelog
vendored
4
debian/changelog
vendored
|
@ -25,6 +25,7 @@ git-annex (6.20151219) UNRELEASED; urgency=medium
|
|||
* fix: Adjusts unlocked files as configured by annex.thin.
|
||||
* persistent-sqlite is now a hard build dependency, since v6 repository
|
||||
mode needs it.
|
||||
|
||||
* status: On crippled filesystems, was displaying M for all annexed files
|
||||
that were present. Probably caused by a change to what git status
|
||||
displays in this situation. Fixed by treating files git thinks are
|
||||
|
@ -47,6 +48,9 @@ git-annex (6.20151219) UNRELEASED; urgency=medium
|
|||
* rekey: No longer copies over urls from the old to the new key.
|
||||
It makes sense for migrate to do that, but not for this low-level
|
||||
(and little used) plumbing command to.
|
||||
* view: Avoid using cute unicode homomorphs for '/' and '\' and instead
|
||||
use ugly escaping, as the unicode method doesn't work on non-unicode
|
||||
supporting systems.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Sat, 19 Dec 2015 13:31:17 -0400
|
||||
|
||||
|
|
|
@ -39,4 +39,4 @@ I was trying out the metadata extraction via libextractor and for the mimetype t
|
|||
Apart from this git-annex is working very well for me. I mostly use it as an archive, distributing numerous copies on various hard drives and cloud providers and keeping track of what is where.Its an amazing tool for that.
|
||||
|
||||
|
||||
|
||||
> [[done]] --[[Joey]]
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
[[!comment format=mdwn
|
||||
username="joey"
|
||||
subject="""comment 1"""
|
||||
date="2016-01-08T15:52:22Z"
|
||||
content="""
|
||||
I was able to reproduce this problem, but only with LANG=C. It works in a
|
||||
unicode locale.
|
||||
|
||||
What's torpedoing this is a hack that it uses to handle "/" in a view.
|
||||
|
||||
pseudoSlash :: Char
|
||||
pseudoSlash = '\8725' -- '∕' /= '/'
|
||||
|
||||
It's necessary that in a view, each viewed metadata component yield exactly one
|
||||
level of directory hierarchy. Otherwise, it would be impossible to reverse
|
||||
"a/b/c/file" when viewing on 2 metadata components --
|
||||
is that "a/b" and "c" or "a" and "b/c"?
|
||||
|
||||
Which is why I used this cutsey hack, but yeah, it requires working
|
||||
unicode support.
|
||||
|
||||
Sigh, 2016 and still can't have nice things.. Suppose it'll have to use an
|
||||
ugly encoding for them instead.
|
||||
"""]]
|
Loading…
Add table
Reference in a new issue