avoid churning in git to no benefit when optimising metadata log

I think this is now optimal.
This commit is contained in:
Joey Hess 2014-02-12 23:24:04 -04:00
parent d4236e4766
commit 361aee0470
Failed to extract signature

View file

@ -90,7 +90,7 @@ addMetaData k metadata = do
- -
- An unmerged remote has: - An unmerged remote has:
- -
- 150 bar +z baz +w - 150 bar -y baz +w
- -
- If what we have were simplified to "200 foo -x bar +y" then when the line - If what we have were simplified to "200 foo -x bar +y" then when the line
- from the remote became available, it would be older than the simplified - from the remote became available, it would be older than the simplified
@ -101,12 +101,15 @@ addMetaData k metadata = do
- 100 bar +y - 100 bar +y
- 200 foo -x - 200 foo -x
- -
- TODO: The above simplification is not implemented yet. - (Note that this ends up with the same number of lines as the
- unsimplified version, so there's really no point in updating
- the log to this version. Doing so would only add data to git,
- with little benefit.)
- -
- Now merging with the remote yields: - Now merging with the remote yields:
- -
- 100 bar +y - 100 bar +y
- 150 bar +z baz +w - 150 bar -y baz +w
- 200 foo -x - 200 foo -x
- -
- Simplifying again: - Simplifying again:
@ -115,10 +118,16 @@ addMetaData k metadata = do
- 200 foo -x - 200 foo -x
-} -}
simplifyLog :: Log MetaData -> Log MetaData simplifyLog :: Log MetaData -> Log MetaData
simplifyLog s = case S.toDescList s of simplifyLog s = case sl of
(newest:rest) -> S.fromList $ go [newest] (value newest) rest (newest:rest) ->
let sl' = go [newest] (value newest) rest
in if length sl' < length sl
then S.fromList sl'
else s
_ -> s _ -> s
where where
sl = S.toDescList s
go c _ [] = c go c _ [] = c
go c newer (l:ls) go c newer (l:ls)
| unique == newMetaData = go c newer ls | unique == newMetaData = go c newer ls