darcs-2.18.2: a distributed, interactive, smart revision control system

Safe Haskell | None
Language | Haskell2010

Darcs.UI.SelectChanges

Contents

- Working with changes
- Interactive selection utils
  - Navigating the patchset
  - Decisions
  - Prompts and queries

Synopsis

- data WhichChanges
  - = Last
  - | LastReversed
  - | First
  - | FirstReversed
- viewChanges :: forall (p :: Type -> Type -> Type). (ShowPatch p, ShowContextPatch p, ApplyState p ~ Tree) => PatchSelectionOptions -> [Sealed2 p] -> IO ()
- withSelectedPatchFromList :: forall (p :: Type -> Type -> Type) wX wY. (Commute p, Matchable p, ShowPatch p, ShowContextPatch p, ApplyState p ~ Tree) => String -> RL p wX wY -> PatchSelectionOptions -> ((RL p :> p) wX wY -> IO ()) -> IO ()
- runSelection :: forall (p :: Type -> Type -> Type) wX wY. (MatchableRP p, ShowPatch p, ShowContextPatch p, ApplyState p ~ Tree, ApplyState p ~ ApplyState (PrimOf p)) => FL p wX wY -> SelectionConfig p -> IO ((FL p :> FL p) wX wY)
- runInvertibleSelection :: forall (p :: Type -> Type -> Type) wX wY. (Invert p, MatchableRP p, ShowPatch p, ShowContextPatch p, ApplyState p ~ Tree) => FL p wX wY -> SelectionConfig p -> IO ((FL p :> FL p) wX wY)
- selectionConfigPrim :: forall (prim :: Type -> Type -> Type). WhichChanges -> String -> PatchSelectionOptions -> Maybe (Splitter prim) -> Maybe [AnchoredPath] -> SelectionConfig prim
- selectionConfigGeneric :: forall (p :: Type -> Type -> Type) q. Matchable p => (forall wX wY. q wX wY -> Sealed2 p) -> WhichChanges -> String -> PatchSelectionOptions -> Maybe [AnchoredPath] -> SelectionConfig q
- selectionConfig :: forall (p :: Type -> Type -> Type). Matchable p => WhichChanges -> String -> PatchSelectionOptions -> Maybe (Splitter p) -> Maybe [AnchoredPath] -> SelectionConfig p
- data SelectionConfig (p :: Type -> Type -> Type)
- data PatchSelectionOptions = PatchSelectionOptions {
  - verbosity :: Verbosity
  - matchFlags :: [MatchFlag]
  - interactive :: Bool
  - selectDeps :: SelectDeps
  - withSummary :: WithSummary
  }
- type InteractiveSelectionM (p :: Type -> Type -> Type) wX wY a = StateT (InteractiveSelectionState p wX wY) (PatchSelectionM p IO) a
- data InteractiveSelectionState (p :: Type -> Type -> Type) wX wY = ISC {
  - total :: Int
  - current :: Int
  - lps :: FZipper (LabelledPatch p) wX wY
  - choices :: PatchChoices p wX wY
  }
- initialSelectionState :: forall (p :: Type -> Type -> Type) wX wY. FL (LabelledPatch p) wX wY -> PatchChoices p wX wY -> InteractiveSelectionState p wX wY
- currentPatch :: forall (p :: Type -> Type -> Type) wX wY. InteractiveSelectionM p wX wY (Maybe (Sealed2 (LabelledPatch p)))
- skipMundane :: forall (p :: Type -> Type -> Type) wX wY. (Commute p, ShowPatch p) => InteractiveSelectionM p wX wY ()
- skipOne :: forall (p :: Type -> Type -> Type) wX wY. InteractiveSelectionM p wX wY ()
- backOne :: forall (p :: Type -> Type -> Type) wX wY. InteractiveSelectionM p wX wY ()
- backAll :: forall (p :: Type -> Type -> Type) wX wY. InteractiveSelectionM p wX wY ()
- decide :: forall (p :: Type -> Type -> Type) wA wB wX wY. Commute p => Bool -> LabelledPatch p wA wB -> InteractiveSelectionM p wX wY ()
- decideWholeFile :: forall (p :: Type -> Type -> Type) wX wY. (Commute p, PatchInspect p) => AnchoredPath -> Bool -> InteractiveSelectionM p wX wY ()
- isSingleFile :: PatchInspect p => p wX wY -> Bool
- currentFile :: forall (p :: Type -> Type -> Type) wX wY. PatchInspect p => InteractiveSelectionM p wX wY (Maybe AnchoredPath)
- promptUser :: forall (p :: Type -> Type -> Type) wX wY. ShowPatch p => Bool -> Char -> InteractiveSelectionM p wX wY Char
- prompt :: forall (p :: Type -> Type -> Type) wX wY. ShowPatch p => InteractiveSelectionM p wX wY String
- data KeyPress = KeyPress {
  - kp :: Char
  - kpHelp :: String
  }
- keysFor :: [[KeyPress]] -> [Char]
- helpFor :: String -> [[KeyPress]] -> [[KeyPress]] -> String
- askAboutDepends :: forall (p :: Type -> Type -> Type) wX wR wT. (RepoPatch p, ApplyState p ~ Tree) => RL (PatchInfoAnd p) wX wR -> FL (PrimOf p) wR wT -> PatchSelectionOptions -> [PatchInfo] -> IO [PatchInfo]

# Working with changes

data WhichChanges #

When asking about patches, we either ask about them in oldest-first or newest first (with respect to the current ordering of the repository), and we either want an initial segment or a final segment of the poset of patches.

`First`: ask for an initial segment, first patches first (default for all pull-like commands)

`FirstReversed`: ask for an initial segment, last patches first (used to ask about dependencies in record, and for pull-like commands with the `--reverse` flag).

`LastReversed`: ask for a final segment, last patches first. (default for unpull-like commands, except for selecting *primitive* patches in rollback)

`Last`: ask for a final segment, first patches first. (used for selecting primitive patches in rollback, and for unpull-like commands with the `--reverse` flag

IOW: First = initial segment Last = final segment Reversed = start with the newest patch instead of oldest As usual, terminology is not, ahem, very intuitive.

Constructors

Last |
LastReversed |
First |
FirstReversed |

#### Instances

Instances details

Show WhichChanges # |
Instance details Defined in Darcs.UI.SelectChanges Methods showsPrec :: Int -> WhichChanges -> ShowS # show :: WhichChanges -> String # showList :: [WhichChanges] -> ShowS #
Eq WhichChanges # |
Instance details Defined in Darcs.UI.SelectChanges Methods (==) :: WhichChanges -> WhichChanges -> Bool # (/=) :: WhichChanges -> WhichChanges -> Bool #

viewChanges :: forall (p :: Type -> Type -> Type). (ShowPatch p, ShowContextPatch p, ApplyState p ~ Tree) => PatchSelectionOptions -> [Sealed2 p] -> IO () #

The equivalent of `runSelection` for the `darcs log` command

withSelectedPatchFromList :: forall (p :: Type -> Type -> Type) wX wY. (Commute p, Matchable p, ShowPatch p, ShowContextPatch p, ApplyState p ~ Tree) => String -> RL p wX wY -> PatchSelectionOptions -> ((RL p :> p) wX wY -> IO ()) -> IO () #

The function for selecting a patch to amend record. Read at your own risks.

runSelection :: forall (p :: Type -> Type -> Type) wX wY. (MatchableRP p, ShowPatch p, ShowContextPatch p, ApplyState p ~ Tree, ApplyState p ~ ApplyState (PrimOf p)) => FL p wX wY -> SelectionConfig p -> IO ((FL p :> FL p) wX wY) #

Run a `PatchSelection` action in the given `SelectionConfig`, without assuming that patches are invertible.

runInvertibleSelection :: forall (p :: Type -> Type -> Type) wX wY. (Invert p, MatchableRP p, ShowPatch p, ShowContextPatch p, ApplyState p ~ Tree) => FL p wX wY -> SelectionConfig p -> IO ((FL p :> FL p) wX wY) #

Run a `PatchSelection` action in the given `SelectionConfig`, assuming patches are invertible.

selectionConfigPrim :: forall (prim :: Type -> Type -> Type). WhichChanges -> String -> PatchSelectionOptions -> Maybe (Splitter prim) -> Maybe [AnchoredPath] -> SelectionConfig prim #

A `SelectionConfig` for selecting `Prim` patches.

selectionConfigGeneric :: forall (p :: Type -> Type -> Type) q. Matchable p => (forall wX wY. q wX wY -> Sealed2 p) -> WhichChanges -> String -> PatchSelectionOptions -> Maybe [AnchoredPath] -> SelectionConfig q #

A generic `SelectionConfig`.

selectionConfig :: forall (p :: Type -> Type -> Type). Matchable p => WhichChanges -> String -> PatchSelectionOptions -> Maybe (Splitter p) -> Maybe [AnchoredPath] -> SelectionConfig p #

A `SelectionConfig` for selecting full (`Matchable`) patches

data SelectionConfig (p :: Type -> Type -> Type) #

All the static settings for selecting patches.

# Interactive selection utils

data PatchSelectionOptions #

Constructors

PatchSelectionOptions |

Fields

- verbosity :: Verbosity
- matchFlags :: [MatchFlag]
- interactive :: Bool
- selectDeps :: SelectDeps
- withSummary :: WithSummary

type InteractiveSelectionM (p :: Type -> Type -> Type) wX wY a = StateT (InteractiveSelectionState p wX wY) (PatchSelectionM p IO) a #

data InteractiveSelectionState (p :: Type -> Type -> Type) wX wY #

The dynamic parameters for interactive selection of patches.

Constructors

ISC |

Fields

- total :: Int

  total number of patches

- current :: Int

  number of already-seen patches

- lps :: FZipper (LabelledPatch p) wX wY

  the patches we offer

- choices :: PatchChoices p wX wY

  the user's choices

initialSelectionState :: forall (p :: Type -> Type -> Type) wX wY. FL (LabelledPatch p) wX wY -> PatchChoices p wX wY -> InteractiveSelectionState p wX wY #

## Navigating the patchset

currentPatch :: forall (p :: Type -> Type -> Type) wX wY. InteractiveSelectionM p wX wY (Maybe (Sealed2 (LabelledPatch p))) #

Returns a `Sealed2` version of the patch we are asking the user about.

skipMundane :: forall (p :: Type -> Type -> Type) wX wY. (Commute p, ShowPatch p) => InteractiveSelectionM p wX wY () #

Skips patches we should not ask the user about

skipOne :: forall (p :: Type -> Type -> Type) wX wY. InteractiveSelectionM p wX wY () #

Focus the next patch.

backOne :: forall (p :: Type -> Type -> Type) wX wY. InteractiveSelectionM p wX wY () #

Focus the previous patch.

backAll :: forall (p :: Type -> Type -> Type) wX wY. InteractiveSelectionM p wX wY () #

## Decisions

decide :: forall (p :: Type -> Type -> Type) wA wB wX wY. Commute p => Bool -> LabelledPatch p wA wB -> InteractiveSelectionM p wX wY () #

`decide True` selects the current patch, and `decide False` deselects it.

decideWholeFile :: forall (p :: Type -> Type -> Type) wX wY. (Commute p, PatchInspect p) => AnchoredPath -> Bool -> InteractiveSelectionM p wX wY () #

like `decide`, but for all patches touching `file`

## Prompts and queries

isSingleFile :: PatchInspect p => p wX wY -> Bool #

currentFile :: forall (p :: Type -> Type -> Type) wX wY. PatchInspect p => InteractiveSelectionM p wX wY (Maybe AnchoredPath) #

returns `Just f` if the `currentPatch` only modifies `f`, `Nothing` otherwise.

promptUser :: forall (p :: Type -> Type -> Type) wX wY. ShowPatch p => Bool -> Char -> InteractiveSelectionM p wX wY Char #

Asks the user about one patch, returns their answer.

prompt :: forall (p :: Type -> Type -> Type) wX wY. ShowPatch p => InteractiveSelectionM p wX wY String #

The question to ask about one patch.

data KeyPress #

The type of the answers to a "shall I [wiggle] that [foo]?" question They are found in a [[KeyPress]] bunch, each list representing a set of answers which belong together

Constructors

KeyPress |

Fields

- kp :: Char
- kpHelp :: String

keysFor :: [[KeyPress]] -> [Char] #

The keys used by a list of `keyPress` groups.

helpFor :: String -> [[KeyPress]] -> [[KeyPress]] -> String #

Generates the help for a set of basic and advanced `KeyPress` groups.

askAboutDepends #

Arguments

:: forall (p :: Type -> Type -> Type) wX wR wT. (RepoPatch p, ApplyState p ~ Tree) |
=> RL (PatchInfoAnd p) wX wR | patches to choose from
-> FL (PrimOf p) wR wT | tentative content of new patch
-> PatchSelectionOptions |
-> [PatchInfo] | old explicit dependencies
-> IO [PatchInfo] |

For a given sequence of preceding patches to choose from, and a sequence of prims which will become a new named patch, let the user select a subset such that the new patch will explicitly depend on them. The patches offered include only those that the new patch does not already depend on. To support amend, we pass in the old dependencies, too.