on master help sign in
fix head deletion- this should have never been implemented

even after a head is merged, it can continue to be used, duh

commit30b61889ceb704f8c4e313e016b8b407dd5d102c authorAgentM <agentm@themactionfaction.com> dateSun 26 Jun 2016, 11:51 (10 years ago) parentdcb8584
2 files changed+8−12
ProjectM36/TransactionGraph.hs+5−10 test/TransactionGraph/Merge.hs+3−2
ProjectM36/TransactionGraph.hs+5−10
@@ -16,8 +16,8 @@ import Control.Monad
1616import qualified Data.Text as T
1717import GHC.Generics
1818import Data.Binary
19−import Debug.Trace
2019import Data.Either (lefts, rights)
20+--import Debug.Trace
2121
2222--operators which manipulate a transaction graph
2323data TransactionGraphOperator = JumpToHead HeadName |
@@ -263,7 +263,9 @@ createMergeTransaction newUUID (SelectedBranchMergeStrategy selectedBranch) grap
263263 selectedTrans <- validateHeadName selectedBranch graph t2
264264 pure $ Transaction newUUID (MergeTransactionInfo (transactionUUID trans1) (transactionUUID trans2) S.empty) (transactionContext selectedTrans)
265265
266−--createMergeTransaction newUUID UnionMergeStrategy graph t2 = undefined
266+createMergeTransaction newUUID UnionMergeStrategy graph t2 = undefined
267+
268+createMergeTransaction newUUID (UnionPreferMergeStrategy preferHead) graph t2 = undefined
267269
268270-- | Returns the correct Transaction for the branch name in the graph and ensures that it is one of the two transaction arguments in the tuple.
269271validateHeadName :: HeadName -> TransactionGraph -> (Transaction, Transaction) -> Either MergeError Transaction
@@ -334,12 +336,6 @@ mergeTransactions newUUID parentUUID mergeStrategy (headNameA, headNameB) graph
334336 transB <- transactionForHeadErr headNameB
335337 let transAid = transactionUUID transA
336338 transBid = transactionUUID transB
337− headNameToDelete <- if parentUUID == transAid then
338− pure headNameB
339− else if parentUUID == transBid then
340− pure headNameA
341− else
342− Left (MergeTransactionError (DisconnectedTransactionNotAMergeHeadError parentUUID))
343339
344340 disconParent <- transactionForUUID parentUUID graph
345341 let subHeads = M.filterWithKey (\k _ -> elem k [headNameA, headNameB]) (transactionHeadsForGraph graph)
@@ -352,8 +348,7 @@ mergeTransactions newUUID parentUUID mergeStrategy (headNameA, headNameB) graph
352348 Just headName -> do
353349 -- why create a merge transaction and then only use the context?
354350 (newTrans, newGraph) <- addTransactionToGraph headName parentUUID newUUID (transactionContext mergedTrans) graph
355− let newGraph' = TransactionGraph newHeads (transactionsForGraph newGraph)
356− newHeads = M.delete headNameToDelete (transactionHeadsForGraph newGraph)
351+ let newGraph' = TransactionGraph (transactionHeadsForGraph newGraph) (transactionsForGraph newGraph)
357352 newDiscon = newDisconnectedTransaction newUUID (transactionContext newTrans)
358353 pure (newDiscon, newGraph')
359354
test/TransactionGraph/Merge.hs+3−2
@@ -130,7 +130,8 @@ testSelectedBranchMerge = TestCase $ do
130130 (DisconnectedTransaction _ mergedContext, graph'') <- assertEither eGraph'
131131
132132 assertGraph graph''
133− --validate that the branchB was removed
133+ --validate that the branchB remains
134134 rootTrans <- assertEither $ transactionForUUID (fakeUUID 1) graph''
135− assertEqual "head still available" (transactionForHead "branchB" graph'') Nothing
135+ branchBTrans <- assertMaybe (transactionForHead "branchB" graph'') "failed to find branchB head"
136+ assertEqual "head of merged transaction was removed" (transactionUUID branchBTrans) (fakeUUID 3)
136137 --assertEqual "bad merge" mergedContext (transactionContext rootTrans)