toplevel lastchanged field
This commit is contained in:
parent
3d48de183d
commit
f64c2d6138
4 changed files with 29 additions and 11 deletions
|
@ -10,6 +10,7 @@ module Annex.MetaData.StandardFields (
|
||||||
yearMetaField,
|
yearMetaField,
|
||||||
monthMetaField,
|
monthMetaField,
|
||||||
lastChangedField,
|
lastChangedField,
|
||||||
|
mkLastChangedField,
|
||||||
isLastChangedField
|
isLastChangedField
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
@ -26,13 +27,21 @@ yearMetaField = mkMetaFieldUnchecked "year"
|
||||||
monthMetaField :: MetaField
|
monthMetaField :: MetaField
|
||||||
monthMetaField = mkMetaFieldUnchecked "month"
|
monthMetaField = mkMetaFieldUnchecked "month"
|
||||||
|
|
||||||
lastChangedField :: MetaField -> MetaField
|
lastChangedField :: MetaField
|
||||||
lastChangedField f = mkMetaFieldUnchecked (fromMetaField f ++ lastchanged)
|
lastChangedField = mkMetaFieldUnchecked lastchanged
|
||||||
|
|
||||||
|
mkLastChangedField :: MetaField -> MetaField
|
||||||
|
mkLastChangedField f = mkMetaFieldUnchecked (fromMetaField f ++ lastchangedSuffix)
|
||||||
|
|
||||||
isLastChangedField :: MetaField -> Bool
|
isLastChangedField :: MetaField -> Bool
|
||||||
isLastChangedField f = lastchanged `isSuffixOf` s && s /= lastchanged
|
isLastChangedField f
|
||||||
|
| f == lastChangedField = True
|
||||||
|
| otherwise = lastchanged `isSuffixOf` s && s /= lastchangedSuffix
|
||||||
where
|
where
|
||||||
s = fromMetaField f
|
s = fromMetaField f
|
||||||
|
|
||||||
lastchanged :: String
|
lastchanged :: String
|
||||||
lastchanged = "-lastchanged"
|
lastchanged = "lastchanged"
|
||||||
|
|
||||||
|
lastchangedSuffix :: String
|
||||||
|
lastchangedSuffix = "-lastchanged"
|
||||||
|
|
|
@ -67,16 +67,22 @@ getCurrentMetaData k = do
|
||||||
return $ currentMetaData $ unionMetaData loggedmeta
|
return $ currentMetaData $ unionMetaData loggedmeta
|
||||||
(lastchanged ls loggedmeta)
|
(lastchanged ls loggedmeta)
|
||||||
where
|
where
|
||||||
lastchanged ls (MetaData wanted) =
|
lastchanged [] _ = emptyMetaData
|
||||||
|
lastchanged ls (MetaData currentlyset) =
|
||||||
let m = foldl' (flip M.union) M.empty (map genlastchanged ls)
|
let m = foldl' (flip M.union) M.empty (map genlastchanged ls)
|
||||||
in MetaData $ M.mapKeys lastChangedField $
|
in MetaData $
|
||||||
|
-- Add a overall lastchanged using the oldest log
|
||||||
|
-- item (log is in ascending order).
|
||||||
|
M.insert lastChangedField (lastchangedval $ Prelude.last ls) $
|
||||||
|
M.mapKeys mkLastChangedField $
|
||||||
-- Only include fields that are currently set.
|
-- Only include fields that are currently set.
|
||||||
m `M.intersection` wanted
|
m `M.intersection` currentlyset
|
||||||
-- Makes each field have the timestamp as its value.
|
-- Makes each field have the timestamp as its value.
|
||||||
genlastchanged l =
|
genlastchanged l =
|
||||||
let MetaData m = value l
|
let MetaData m = value l
|
||||||
ts = S.singleton $ toMetaValue $ showts $ changed l
|
ts = lastchangedval l
|
||||||
in M.map (const ts) m
|
in M.map (const ts) m
|
||||||
|
lastchangedval l = S.singleton $ toMetaValue $ showts $ changed l
|
||||||
showts = formatTime defaultTimeLocale "%F@%H-%M-%S" . posixSecondsToUTCTime
|
showts = formatTime defaultTimeLocale "%F@%H-%M-%S" . posixSecondsToUTCTime
|
||||||
|
|
||||||
{- Adds in some metadata, which can override existing values, or unset
|
{- Adds in some metadata, which can override existing values, or unset
|
||||||
|
|
7
debian/changelog
vendored
7
debian/changelog
vendored
|
@ -27,9 +27,10 @@ git-annex (5.20140307) UNRELEASED; urgency=medium
|
||||||
* map: Fix crash when one of the remotes of a repo is a local directory
|
* map: Fix crash when one of the remotes of a repo is a local directory
|
||||||
that does not exist, or is not a git repo.
|
that does not exist, or is not a git repo.
|
||||||
* rsync special remote: Fix slashes when used on Windows.
|
* rsync special remote: Fix slashes when used on Windows.
|
||||||
* Each for each metadata field, there's now an automatically maintained
|
* For each metadata field, there's now an automatically maintained
|
||||||
"$field-lastchanged" that gives the timestamp of the last change to that
|
"$field-lastchanged" that gives the date of the last change to that
|
||||||
field.
|
field. Also the "lastchanged" field for the date of the last change
|
||||||
|
to any of a file's metadata.
|
||||||
* Windows: Fix some filename encoding bugs.
|
* Windows: Fix some filename encoding bugs.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Thu, 06 Mar 2014 16:17:01 -0400
|
-- Joey Hess <joeyh@debian.org> Thu, 06 Mar 2014 16:17:01 -0400
|
||||||
|
|
|
@ -31,6 +31,8 @@ Here are some metadata fields that git-annex has special support for:
|
||||||
* `$field-lastchanged` - This is automatically maintained for each
|
* `$field-lastchanged` - This is automatically maintained for each
|
||||||
field that's set, and gives the date and time of the most recent
|
field that's set, and gives the date and time of the most recent
|
||||||
change to the field. It cannot be modified directly.
|
change to the field. It cannot be modified directly.
|
||||||
|
* `lastchanged` - This is automatically maintained, giving the data and time
|
||||||
|
of the last change to any of the metadata of a file.
|
||||||
|
|
||||||
To make git-annex automatically set the year and month when adding files,
|
To make git-annex automatically set the year and month when adding files,
|
||||||
run `git config annex.genmetadata true`. Also, see
|
run `git config annex.genmetadata true`. Also, see
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue