diff options
author | Joey Hess <joey@kitenet.net> | 2014-02-12 21:48:25 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-02-12 21:48:25 -0400 |
commit | e0eef9979943e67226ca606e1aaa58c9a18a1d40 (patch) | |
tree | b6399a4c2c206625cb41f1ab72269a422706c895 | |
parent | cb0dad5172b743679d90c7fd6e490d4927ea5a76 (diff) |
don't bring forward old values in new log line
-rw-r--r-- | Command/MetaData.hs | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/Command/MetaData.hs b/Command/MetaData.hs index f2c4abcea..d4d3f880c 100644 --- a/Command/MetaData.hs +++ b/Command/MetaData.hs @@ -32,17 +32,16 @@ start (file:settings) = ifAnnexed file start _ = error "specify a file and the metadata to set" perform :: Key -> [Action] -> CommandPerform -perform k actions = do - m <- getCurrentMetaData k - if null actions - then next $ cleanup m - else do - let m' = foldr apply m actions - addMetaData k m' - next $ cleanup m' +perform k [] = next $ cleanup k +perform k as = do + oldm <- getCurrentMetaData k + let m = foldr (apply oldm) newMetaData as + addMetaData k m + next $ cleanup k -cleanup :: MetaData -> CommandCleanup -cleanup m = do +cleanup :: Key -> CommandCleanup +cleanup k = do + m <- getCurrentMetaData k showLongNote $ unlines $ concatMap showmeta $ fromMetaData $ currentMetaData m return True where @@ -65,9 +64,9 @@ parse p = case lastMaybe f of mkf fld = fromMaybe (badfield fld) (toMetaField fld) badfield fld = error $ "Illegal metadata field name, \"" ++ fld ++ "\"" -apply :: Action -> MetaData -> MetaData -apply (AddMeta f v) m = updateMetaData f v m -apply (DelMeta f oldv) m = updateMetaData f (unsetMetaValue oldv) m -apply (SetMeta f v) m = updateMetaData f v $ +apply :: MetaData -> Action -> MetaData -> MetaData +apply _ (AddMeta f v) m = updateMetaData f v m +apply _ (DelMeta f oldv) m = updateMetaData f (unsetMetaValue oldv) m +apply oldm (SetMeta f v) m = updateMetaData f v $ foldr (updateMetaData f) m $ - map unsetMetaValue $ S.toList $ currentMetaDataValues f m + map unsetMetaValue $ S.toList $ currentMetaDataValues f oldm |