module Darcs.Patch.Rebase
( takeHeadRebase
, takeHeadRebaseFL
, takeAnyRebase
, takeAnyRebaseAndTrailingPatches
, dropAnyRebase
) where
import Prelude ()
import Darcs.Prelude
import Darcs.Patch.Named.Wrapped ( WrappedNamed(RebaseP) )
import Darcs.Patch.PatchInfoAnd ( PatchInfoAnd, hopefully )
import Darcs.Patch.Rebase.Container ( Suspended(..) )
import Darcs.Patch.RepoType
( RepoType(..)
, RebaseType(..)
, IsRepoType(..)
, SRepoType(..)
, SRebaseType(..)
)
import Darcs.Patch.Set ( PatchSet(..) )
import Darcs.Patch.Witnesses.Ordered
import Darcs.Patch.Witnesses.Sealed
takeAnyRebase :: PatchSet ('RepoType 'IsRebase) p wA wB
-> (Sealed2 (PatchInfoAnd ('RepoType 'IsRebase) p),
Sealed2 (Suspended p))
takeAnyRebase :: PatchSet ('RepoType 'IsRebase) p wA wB
-> (Sealed2 (PatchInfoAnd ('RepoType 'IsRebase) p),
Sealed2 (Suspended p))
takeAnyRebase (PatchSet _ NilRL) =
String
-> (Sealed2 (PatchInfoAnd ('RepoType 'IsRebase) p),
Sealed2 (Suspended p))
forall a. String -> a
bug "internal error: no suspended patch found"
takeAnyRebase (PatchSet pss :: RL (Tagged ('RepoType 'IsRebase) p) wA wX
pss (ps :: RL (PatchInfoAnd ('RepoType 'IsRebase) p) wX wY
ps :<: p :: PatchInfoAnd ('RepoType 'IsRebase) p wY wB
p))
| RebaseP _ rs :: Suspended p wY wY
rs <- PatchInfoAnd ('RepoType 'IsRebase) p wY wB
-> WrappedNamed ('RepoType 'IsRebase) p wY wB
forall (rt :: RepoType) (p :: * -> * -> *) wA wB.
PatchInfoAnd rt p wA wB -> WrappedNamed rt p wA wB
hopefully PatchInfoAnd ('RepoType 'IsRebase) p wY wB
p = (PatchInfoAnd ('RepoType 'IsRebase) p wY wB
-> Sealed2 (PatchInfoAnd ('RepoType 'IsRebase) p)
forall (a :: * -> * -> *) wX wY. a wX wY -> Sealed2 a
Sealed2 PatchInfoAnd ('RepoType 'IsRebase) p wY wB
p, Suspended p wY wY -> Sealed2 (Suspended p)
forall (a :: * -> * -> *) wX wY. a wX wY -> Sealed2 a
Sealed2 Suspended p wY wY
rs)
| Bool
otherwise = PatchSet ('RepoType 'IsRebase) p wA wY
-> (Sealed2 (PatchInfoAnd ('RepoType 'IsRebase) p),
Sealed2 (Suspended p))
forall (p :: * -> * -> *) wA wB.
PatchSet ('RepoType 'IsRebase) p wA wB
-> (Sealed2 (PatchInfoAnd ('RepoType 'IsRebase) p),
Sealed2 (Suspended p))
takeAnyRebase (RL (Tagged ('RepoType 'IsRebase) p) wA wX
-> RL (PatchInfoAnd ('RepoType 'IsRebase) p) wX wY
-> PatchSet ('RepoType 'IsRebase) p wA wY
forall (rt :: RepoType) (p :: * -> * -> *) wStart wX wY.
RL (Tagged rt p) wStart wX
-> RL (PatchInfoAnd rt p) wX wY -> PatchSet rt p wStart wY
PatchSet RL (Tagged ('RepoType 'IsRebase) p) wA wX
pss RL (PatchInfoAnd ('RepoType 'IsRebase) p) wX wY
ps)
takeAnyRebaseAndTrailingPatches
:: PatchSet ('RepoType 'IsRebase) p wA wB
-> FlippedSeal (PatchInfoAnd ('RepoType 'IsRebase) p :>
RL (PatchInfoAnd ('RepoType 'IsRebase) p)) wB
takeAnyRebaseAndTrailingPatches :: PatchSet ('RepoType 'IsRebase) p wA wB
-> FlippedSeal
(PatchInfoAnd ('RepoType 'IsRebase) p
:> RL (PatchInfoAnd ('RepoType 'IsRebase) p))
wB
takeAnyRebaseAndTrailingPatches (PatchSet _ NilRL) =
String
-> FlippedSeal
(PatchInfoAnd ('RepoType 'IsRebase) p
:> RL (PatchInfoAnd ('RepoType 'IsRebase) p))
wB
forall a. String -> a
bug "internal error: no suspended patch found"
takeAnyRebaseAndTrailingPatches (PatchSet pss :: RL (Tagged ('RepoType 'IsRebase) p) wA wX
pss (ps :: RL (PatchInfoAnd ('RepoType 'IsRebase) p) wX wY
ps :<: p :: PatchInfoAnd ('RepoType 'IsRebase) p wY wB
p))
| RebaseP _ _ <- PatchInfoAnd ('RepoType 'IsRebase) p wY wB
-> WrappedNamed ('RepoType 'IsRebase) p wY wB
forall (rt :: RepoType) (p :: * -> * -> *) wA wB.
PatchInfoAnd rt p wA wB -> WrappedNamed rt p wA wB
hopefully PatchInfoAnd ('RepoType 'IsRebase) p wY wB
p = (:>)
(PatchInfoAnd ('RepoType 'IsRebase) p)
(RL (PatchInfoAnd ('RepoType 'IsRebase) p))
wY
wB
-> FlippedSeal
(PatchInfoAnd ('RepoType 'IsRebase) p
:> RL (PatchInfoAnd ('RepoType 'IsRebase) p))
wB
forall (a :: * -> * -> *) wX wY. a wX wY -> FlippedSeal a wY
FlippedSeal (PatchInfoAnd ('RepoType 'IsRebase) p wY wB
p PatchInfoAnd ('RepoType 'IsRebase) p wY wB
-> RL (PatchInfoAnd ('RepoType 'IsRebase) p) wB wB
-> (:>)
(PatchInfoAnd ('RepoType 'IsRebase) p)
(RL (PatchInfoAnd ('RepoType 'IsRebase) p))
wY
wB
forall (a1 :: * -> * -> *) (a2 :: * -> * -> *) wX wY wZ.
a1 wX wZ -> a2 wZ wY -> (:>) a1 a2 wX wY
:> RL (PatchInfoAnd ('RepoType 'IsRebase) p) wB wB
forall (a :: * -> * -> *) wX. RL a wX wX
NilRL)
| Bool
otherwise = case PatchSet ('RepoType 'IsRebase) p wA wY
-> FlippedSeal
(PatchInfoAnd ('RepoType 'IsRebase) p
:> RL (PatchInfoAnd ('RepoType 'IsRebase) p))
wY
forall (p :: * -> * -> *) wA wB.
PatchSet ('RepoType 'IsRebase) p wA wB
-> FlippedSeal
(PatchInfoAnd ('RepoType 'IsRebase) p
:> RL (PatchInfoAnd ('RepoType 'IsRebase) p))
wB
takeAnyRebaseAndTrailingPatches (RL (Tagged ('RepoType 'IsRebase) p) wA wX
-> RL (PatchInfoAnd ('RepoType 'IsRebase) p) wX wY
-> PatchSet ('RepoType 'IsRebase) p wA wY
forall (rt :: RepoType) (p :: * -> * -> *) wStart wX wY.
RL (Tagged rt p) wStart wX
-> RL (PatchInfoAnd rt p) wX wY -> PatchSet rt p wStart wY
PatchSet RL (Tagged ('RepoType 'IsRebase) p) wA wX
pss RL (PatchInfoAnd ('RepoType 'IsRebase) p) wX wY
ps) of
FlippedSeal (r :: PatchInfoAnd ('RepoType 'IsRebase) p wX wZ
r :> ps' :: RL (PatchInfoAnd ('RepoType 'IsRebase) p) wZ wY
ps') -> (:>)
(PatchInfoAnd ('RepoType 'IsRebase) p)
(RL (PatchInfoAnd ('RepoType 'IsRebase) p))
wX
wB
-> FlippedSeal
(PatchInfoAnd ('RepoType 'IsRebase) p
:> RL (PatchInfoAnd ('RepoType 'IsRebase) p))
wB
forall (a :: * -> * -> *) wX wY. a wX wY -> FlippedSeal a wY
FlippedSeal (PatchInfoAnd ('RepoType 'IsRebase) p wX wZ
r PatchInfoAnd ('RepoType 'IsRebase) p wX wZ
-> RL (PatchInfoAnd ('RepoType 'IsRebase) p) wZ wB
-> (:>)
(PatchInfoAnd ('RepoType 'IsRebase) p)
(RL (PatchInfoAnd ('RepoType 'IsRebase) p))
wX
wB
forall (a1 :: * -> * -> *) (a2 :: * -> * -> *) wX wY wZ.
a1 wX wZ -> a2 wZ wY -> (:>) a1 a2 wX wY
:> (RL (PatchInfoAnd ('RepoType 'IsRebase) p) wZ wY
ps' RL (PatchInfoAnd ('RepoType 'IsRebase) p) wZ wY
-> PatchInfoAnd ('RepoType 'IsRebase) p wY wB
-> RL (PatchInfoAnd ('RepoType 'IsRebase) p) wZ wB
forall (a :: * -> * -> *) wX wY wZ.
RL a wX wY -> a wY wZ -> RL a wX wZ
:<: PatchInfoAnd ('RepoType 'IsRebase) p wY wB
p))
dropAnyRebase :: forall rt p wA wB. IsRepoType rt
=> PatchSet rt p wA wB -> PatchSet rt p wA wB
dropAnyRebase :: PatchSet rt p wA wB -> PatchSet rt p wA wB
dropAnyRebase ps :: PatchSet rt p wA wB
ps@(PatchSet tags :: RL (Tagged rt p) wA wX
tags patches :: RL (PatchInfoAnd rt p) wX wB
patches) =
case SRepoType rt
forall (rt :: RepoType). IsRepoType rt => SRepoType rt
singletonRepoType::SRepoType rt of
SRepoType SNoRebase -> PatchSet rt p wA wB
ps
SRepoType SIsRebase -> RL (Tagged rt p) wA wX
-> RL (PatchInfoAnd rt p) wX wB -> PatchSet rt p wA wB
forall (rt :: RepoType) (p :: * -> * -> *) wStart wX wY.
RL (Tagged rt p) wStart wX
-> RL (PatchInfoAnd rt p) wX wY -> PatchSet rt p wStart wY
PatchSet RL (Tagged rt p) wA wX
tags (RL (PatchInfoAnd ('RepoType 'IsRebase) p) wX wB
-> RL (PatchInfoAnd ('RepoType 'IsRebase) p) wX wB
forall (p :: * -> * -> *) wA wB.
RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
-> RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
dropRebaseRL RL (PatchInfoAnd rt p) wX wB
RL (PatchInfoAnd ('RepoType 'IsRebase) p) wX wB
patches)
dropRebaseRL :: RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
-> RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
dropRebaseRL :: RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
-> RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
dropRebaseRL NilRL = String -> RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
forall a. String -> a
bug "internal error: no suspended patch found"
dropRebaseRL (ps :: RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wY
ps :<: p :: PatchInfoAnd ('RepoType 'IsRebase) p wY wB
p)
| RebaseP _ _ <- PatchInfoAnd ('RepoType 'IsRebase) p wY wB
-> WrappedNamed ('RepoType 'IsRebase) p wY wB
forall (rt :: RepoType) (p :: * -> * -> *) wA wB.
PatchInfoAnd rt p wA wB -> WrappedNamed rt p wA wB
hopefully PatchInfoAnd ('RepoType 'IsRebase) p wY wB
p = RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wY
ps
| Bool
otherwise = RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wY
-> RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wY
forall (p :: * -> * -> *) wA wB.
RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
-> RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
dropRebaseRL RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wY
ps RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wY
-> PatchInfoAnd ('RepoType 'IsRebase) p wY wB
-> RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
forall (a :: * -> * -> *) wX wY wZ.
RL a wX wY -> a wY wZ -> RL a wX wZ
:<: PatchInfoAnd ('RepoType 'IsRebase) p wY wB
p
takeHeadRebase :: PatchSet ('RepoType 'IsRebase) p wA wB
-> (PatchInfoAnd ('RepoType 'IsRebase) p wB wB,
Suspended p wB wB,
PatchSet ('RepoType 'IsRebase) p wA wB)
takeHeadRebase :: PatchSet ('RepoType 'IsRebase) p wA wB
-> (PatchInfoAnd ('RepoType 'IsRebase) p wB wB, Suspended p wB wB,
PatchSet ('RepoType 'IsRebase) p wA wB)
takeHeadRebase (PatchSet pss :: RL (Tagged ('RepoType 'IsRebase) p) wA wX
pss (ps :: RL (PatchInfoAnd ('RepoType 'IsRebase) p) wX wY
ps :<: p :: PatchInfoAnd ('RepoType 'IsRebase) p wY wB
p))
| RebaseP _ rs :: Suspended p wY wY
rs <- PatchInfoAnd ('RepoType 'IsRebase) p wY wB
-> WrappedNamed ('RepoType 'IsRebase) p wY wB
forall (rt :: RepoType) (p :: * -> * -> *) wA wB.
PatchInfoAnd rt p wA wB -> WrappedNamed rt p wA wB
hopefully PatchInfoAnd ('RepoType 'IsRebase) p wY wB
p = (PatchInfoAnd ('RepoType 'IsRebase) p wB wB
PatchInfoAnd ('RepoType 'IsRebase) p wY wB
p, Suspended p wB wB
Suspended p wY wY
rs, RL (Tagged ('RepoType 'IsRebase) p) wA wX
-> RL (PatchInfoAnd ('RepoType 'IsRebase) p) wX wY
-> PatchSet ('RepoType 'IsRebase) p wA wY
forall (rt :: RepoType) (p :: * -> * -> *) wStart wX wY.
RL (Tagged rt p) wStart wX
-> RL (PatchInfoAnd rt p) wX wY -> PatchSet rt p wStart wY
PatchSet RL (Tagged ('RepoType 'IsRebase) p) wA wX
pss RL (PatchInfoAnd ('RepoType 'IsRebase) p) wX wY
ps)
takeHeadRebase _ =
String
-> (PatchInfoAnd ('RepoType 'IsRebase) p wB wB, Suspended p wB wB,
PatchSet ('RepoType 'IsRebase) p wA wB)
forall a. String -> a
bug "internal error: must have a rebase container patch at end of repository"
takeHeadRebaseRL :: RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
-> (PatchInfoAnd ('RepoType 'IsRebase) p wB wB,
Suspended p wB wB,
RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB)
takeHeadRebaseRL :: RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
-> (PatchInfoAnd ('RepoType 'IsRebase) p wB wB, Suspended p wB wB,
RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB)
takeHeadRebaseRL (ps :: RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wY
ps :<: p :: PatchInfoAnd ('RepoType 'IsRebase) p wY wB
p)
| RebaseP _ rs :: Suspended p wY wY
rs <- PatchInfoAnd ('RepoType 'IsRebase) p wY wB
-> WrappedNamed ('RepoType 'IsRebase) p wY wB
forall (rt :: RepoType) (p :: * -> * -> *) wA wB.
PatchInfoAnd rt p wA wB -> WrappedNamed rt p wA wB
hopefully PatchInfoAnd ('RepoType 'IsRebase) p wY wB
p = (PatchInfoAnd ('RepoType 'IsRebase) p wB wB
PatchInfoAnd ('RepoType 'IsRebase) p wY wB
p, Suspended p wB wB
Suspended p wY wY
rs, RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wY
ps)
takeHeadRebaseRL _ =
String
-> (PatchInfoAnd ('RepoType 'IsRebase) p wB wB, Suspended p wB wB,
RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB)
forall a. String -> a
bug "internal error: must have a suspended patch at end of repository"
takeHeadRebaseFL :: FL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
-> (PatchInfoAnd ('RepoType 'IsRebase) p wB wB,
Suspended p wB wB,
FL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB)
takeHeadRebaseFL :: FL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
-> (PatchInfoAnd ('RepoType 'IsRebase) p wB wB, Suspended p wB wB,
FL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB)
takeHeadRebaseFL ps :: FL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
ps =
let (a :: PatchInfoAnd ('RepoType 'IsRebase) p wB wB
a, b :: Suspended p wB wB
b, c :: RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
c) = RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
-> (PatchInfoAnd ('RepoType 'IsRebase) p wB wB, Suspended p wB wB,
RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB)
forall (p :: * -> * -> *) wA wB.
RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
-> (PatchInfoAnd ('RepoType 'IsRebase) p wB wB, Suspended p wB wB,
RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB)
takeHeadRebaseRL (FL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
-> RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
forall (a :: * -> * -> *) wX wZ. FL a wX wZ -> RL a wX wZ
reverseFL FL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
ps) in (PatchInfoAnd ('RepoType 'IsRebase) p wB wB
a, Suspended p wB wB
b, RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
-> FL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
forall (a :: * -> * -> *) wX wZ. RL a wX wZ -> FL a wX wZ
reverseRL RL (PatchInfoAnd ('RepoType 'IsRebase) p) wA wB
c)