diff options
author | 2014-02-13 01:57:43 -0400 | |
---|---|---|
committer | 2014-02-13 01:57:43 -0400 | |
commit | 36f34c21f3dc8aa448f129e2a727381ca61c4c85 (patch) | |
tree | 34fc155b8289f80cab3c6eafcf933e5ab4fd12bc /Logs | |
parent | 55de2b85f4e646e361d71e58f36d65b617c625e0 (diff) |
nice git ack space optimisation when setting the same metadata value for multiple files
Diffstat (limited to 'Logs')
-rw-r--r-- | Logs/MetaData.hs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Logs/MetaData.hs b/Logs/MetaData.hs index 0310ccc17..a959743df 100644 --- a/Logs/MetaData.hs +++ b/Logs/MetaData.hs @@ -31,6 +31,7 @@ module Logs.MetaData ( setMetaData, unsetMetaData, addMetaData, + addMetaData', currentMetaData, ) where @@ -70,12 +71,17 @@ setMetaData' isset k field s = addMetaData k $ {- Adds in some metadata, which can override existing values, or unset - them, but otherwise leaves any existing metadata as-is. -} addMetaData :: Key -> MetaData -> Annex () -addMetaData k metadata = do - now <- liftIO getPOSIXTime - Annex.Branch.change (metaDataLogFile k) $ - showLog . simplifyLog - . S.insert (LogEntry now metadata) - . parseLog +addMetaData k metadata = addMetaData' k metadata =<< liftIO getPOSIXTime + +{- Reusing the same timestamp when making changes to the metadata + - of multiple keys is a nice optimisation. The same metadata lines + - will tend to be generated across the different log files, and so + - git will be able to pack the data more efficiently. -} +addMetaData' :: Key -> MetaData -> POSIXTime -> Annex () +addMetaData' k metadata now = Annex.Branch.change (metaDataLogFile k) $ + showLog . simplifyLog + . S.insert (LogEntry now metadata) + . parseLog {- Simplify a log, removing historical values that are no longer - needed. |