summaryrefslogtreecommitdiff
path: root/Logs/MetaData.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-12 22:36:16 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-12 22:50:41 -0400
commitbedf143ce587c823c7f168a869d16cce4153e46b (patch)
tree351e07f89e691b700ce43263ce5013b8321baef7 /Logs/MetaData.hs
parent406402220e50a6aea2e73c61693b0a93bfae9f38 (diff)
improve simplifier
Diffstat (limited to 'Logs/MetaData.hs')
-rw-r--r--Logs/MetaData.hs24
1 files changed, 9 insertions, 15 deletions
diff --git a/Logs/MetaData.hs b/Logs/MetaData.hs
index 153d8fa63..6d070125c 100644
--- a/Logs/MetaData.hs
+++ b/Logs/MetaData.hs
@@ -96,14 +96,16 @@ addMetaData k metadata = do
- from the remote became available, it would be older than the simplified
- line, and its change to bar would not take effect. That is wrong.
-
- - Instead, simplify it to: (this simpliciation is optional)
+ - Instead, simplify it to:
-
- - 100 bar +y (100 foo +x bar +y)
+ - 100 bar +y
- 200 foo -x
-
+ - TODO: The above simplification is not implemented yet.
+ -
- Now merging with the remote yields:
-
- - 100 bar +y (100 foo +x bar +y)
+ - 100 bar +y
- 150 bar +z baz +w
- 200 foo -x
-
@@ -111,15 +113,6 @@ addMetaData k metadata = do
-
- 150 bar +z baz +w
- 200 foo -x
- -
- - In practice, there is little benefit to making simplications to lines
- - that only remove some values, while leaving others on the line.
- - Since lines are kept in git, that likely increases the size of the
- - git repo (depending on compression), rather than saving any space.
- -
- - So, the only simplication that is actually done is to throw out an
- - old line when all the values in it have been overridden by lines that
- - came after.
-}
simplifyLog :: Log MetaData -> Log MetaData
simplifyLog s = case S.toDescList s of
@@ -128,8 +121,9 @@ simplifyLog s = case S.toDescList s of
where
go c _ [] = c
go c newer (l:ls)
- | hasUniqueMetaData newer older =
- go (l:c) (unionMetaData older newer) ls
- | otherwise = go c newer ls
+ | unique == newMetaData = go c newer ls
+ | otherwise = go (l { value = unique } : c)
+ (unionMetaData unique newer) ls
where
older = value l
+ unique = older `differenceMetaData` newer