--  Copyright (C) 2002-2004 David Roundy
--
--  This program is free software; you can redistribute it and/or modify
--  it under the terms of the GNU General Public License as published by
--  the Free Software Foundation; either version 2, or (at your option)
--  any later version.
--
--  This program is distributed in the hope that it will be useful,
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--  GNU General Public License for more details.
--
--  You should have received a copy of the GNU General Public License
--  along with this program; see the file COPYING.  If not, write to
--  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
--  Boston, MA 02110-1301, USA.

module Darcs.UI.Commands.WhatsNew
    (
      whatsnew
    , status
    ) where

import Prelude ()
import Darcs.Prelude

import Control.Monad ( void, when )
import Control.Monad.Reader ( runReaderT )
import Control.Monad.State ( evalStateT, liftIO )
import Darcs.Util.Tree ( Tree )
import System.Exit ( ExitCode (..), exitSuccess, exitWith )
import Data.List.Ordered ( nubSort )

import Darcs.Patch
    ( PrimOf, PrimPatch, RepoPatch
    , applyToTree, plainSummaryPrims, primIsHunk
    )
import Darcs.Patch.Apply ( Apply, ApplyState )
import Darcs.Patch.Choices ( mkPatchChoices, labelPatches, unLabel )
import Darcs.Patch.Commute ( Commute )
import Darcs.Patch.FileHunk ( IsHunk (..) )
import Darcs.Patch.Format ( PatchListFormat )
import Darcs.Patch.Inspect ( PatchInspect (..) )
import Darcs.Patch.Permutations ( partitionRL )
import Darcs.Patch.Prim.Class ( PrimDetails (..) )
import Darcs.Patch.Show ( ShowPatch, ShowContextPatch )
import Darcs.Patch.Split ( primSplitter )
import Darcs.Patch.TouchesFiles ( choosePreTouching )
import Darcs.Patch.Witnesses.Ordered
    ( (:>) (..), FL (..), RL (..)
    , lengthFL, reverseFL, reverseRL
    )
import Darcs.Patch.Witnesses.Sealed
    ( Sealed (..), Sealed2 (..)
    , unFreeLeft
    )
import Darcs.Patch.Witnesses.WZipper ( FZipper (..) )
import Darcs.Repository
    ( RepoJob (..), Repository
    , readRecorded
    , unrecordedChanges, withRepository
    )
import Darcs.Repository.Diff ( treeDiff )
import Darcs.Repository.Prefs ( filetypeFunction )
import Darcs.UI.Commands
    ( DarcsCommand(..), withStdOpts, amInRepository
    , commandAlias, nodefaults
    )
import Darcs.UI.Completion ( modifiedFileArgs )
import Darcs.UI.Commands.Util ( announceFiles, filterExistingPaths )
import Darcs.UI.Flags
    ( DarcsFlag, diffAlgorithm
    , withContext, useCache, fixSubPaths
    , verbosity, isInteractive
    , lookForAdds, lookForMoves, lookForReplaces
    , scanKnown, useIndex, diffingOpts
    )
import Darcs.UI.Options
    ( DarcsOption, (^), odesc, ocheck, onormalise, defaultFlags, parseFlags, (?) )
import qualified Darcs.UI.Options.All as O
import Darcs.UI.PrintPatch
    ( contextualPrintPatch, printPatch
    , printPatchPager
    )
import Darcs.UI.SelectChanges
    ( InteractiveSelectionContext (..)
    , InteractiveSelectionM, KeyPress (..)
    , WhichChanges (..), backAll
    , backOne, currentFile
    , currentPatch, decide
    , decideWholeFile, helpFor
    , keysFor, prompt
    , selectionContextPrim, skipMundane
    , skipOne, printSummary
    )
import qualified Darcs.UI.SelectChanges as S ( PatchSelectionOptions (..) )
import Darcs.Util.Path ( AbsolutePath, SubPath, toFilePath )
import Darcs.Util.Printer
    ( putDocLn, renderString
    , text, vcat
    )
import Darcs.Util.Prompt ( PromptConfig (..), promptChar )

commonAdvancedOpts :: DarcsOption a (O.UseIndex -> O.IncludeBoring -> a)
commonAdvancedOpts :: DarcsOption a (UseIndex -> IncludeBoring -> a)
commonAdvancedOpts = PrimOptSpec DarcsOptDescr Flag (IncludeBoring -> a) UseIndex
PrimDarcsOption UseIndex
O.useIndex PrimOptSpec DarcsOptDescr Flag (IncludeBoring -> a) UseIndex
-> OptSpec DarcsOptDescr Flag a (IncludeBoring -> a)
-> DarcsOption a (UseIndex -> IncludeBoring -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr Flag a (IncludeBoring -> a)
PrimDarcsOption IncludeBoring
O.includeBoring

patchSelOpts :: [DarcsFlag] -> S.PatchSelectionOptions
patchSelOpts :: [Flag] -> PatchSelectionOptions
patchSelOpts flags :: [Flag]
flags = PatchSelectionOptions :: Verbosity
-> [MatchFlag]
-> Bool
-> SelectDeps
-> Summary
-> WithContext
-> PatchSelectionOptions
S.PatchSelectionOptions
    { verbosity :: Verbosity
S.verbosity = PrimDarcsOption Verbosity
verbosity PrimDarcsOption Verbosity -> [Flag] -> Verbosity
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [Flag]
flags
    , matchFlags :: [MatchFlag]
S.matchFlags = []
    , interactive :: Bool
S.interactive = Bool -> [Flag] -> Bool
isInteractive Bool
True [Flag]
flags
    , selectDeps :: SelectDeps
S.selectDeps = SelectDeps
O.PromptDeps -- option not supported, use default
    , summary :: Summary
S.summary = [Flag] -> Summary
getSummary [Flag]
flags
    , withContext :: WithContext
S.withContext = PrimDarcsOption WithContext
withContext PrimDarcsOption WithContext -> [Flag] -> WithContext
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [Flag]
flags
    }

-- lookForAdds and machineReadable set YesSummary
-- unless NoSummary was given expressly
-- (or by default e.g. status)
getSummary :: [DarcsFlag] -> O.Summary
getSummary :: [Flag] -> Summary
getSummary flags :: [Flag]
flags = case Maybe Summary
-> forall a. PrimOptSpec DarcsOptDescr Flag a (Maybe Summary)
O.maybeSummary Maybe Summary
forall a. Maybe a
Nothing (forall a. PrimOptSpec DarcsOptDescr Flag a (Maybe Summary))
-> [Flag] -> Maybe Summary
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [Flag]
flags of
  Just O.NoSummary -> Summary
O.NoSummary
  Just O.YesSummary -> Summary
O.YesSummary
  Nothing
    | LookForAdds -> Bool
forall a. YesNo a => a -> Bool
O.yes ([Flag] -> LookForAdds
lookForAdds [Flag]
flags) -> Summary
O.YesSummary
    | PrimDarcsOption Bool
O.machineReadable PrimDarcsOption Bool -> [Flag] -> Bool
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [Flag]
flags -> Summary
O.YesSummary
    | Bool
otherwise -> Summary
O.NoSummary

whatsnew :: DarcsCommand [DarcsFlag]
whatsnew :: DarcsCommand [Flag]
whatsnew = DarcsCommand :: forall parsedFlags.
String
-> String
-> String
-> String
-> Int
-> [String]
-> ((AbsolutePath, AbsolutePath)
    -> parsedFlags -> [String] -> IO ())
-> ([Flag] -> IO (Either String ()))
-> ((AbsolutePath, AbsolutePath)
    -> [Flag] -> [String] -> IO [String])
-> ([Flag] -> AbsolutePath -> [String] -> IO [String])
-> [DarcsOptDescr Flag]
-> [DarcsOptDescr Flag]
-> [Flag]
-> ([Flag] -> [String])
-> ([Flag] -> parsedFlags)
-> DarcsCommand parsedFlags
DarcsCommand
    { commandProgramName :: String
commandProgramName = "darcs"
    , commandName :: String
commandName = "whatsnew"
    , commandHelp :: String
commandHelp = String
whatsnewHelp
    , commandDescription :: String
commandDescription = String
whatsnewDescription
    , commandExtraArgs :: Int
commandExtraArgs = -1
    , commandExtraArgHelp :: [String]
commandExtraArgHelp = ["[FILE or DIRECTORY]..."]
    , commandCommand :: (AbsolutePath, AbsolutePath) -> [Flag] -> [String] -> IO ()
commandCommand = (AbsolutePath, AbsolutePath) -> [Flag] -> [String] -> IO ()
whatsnewCmd
    , commandPrereq :: [Flag] -> IO (Either String ())
commandPrereq = [Flag] -> IO (Either String ())
amInRepository
    , commandCompleteArgs :: (AbsolutePath, AbsolutePath) -> [Flag] -> [String] -> IO [String]
commandCompleteArgs = (AbsolutePath, AbsolutePath) -> [Flag] -> [String] -> IO [String]
modifiedFileArgs
    , commandArgdefaults :: [Flag] -> AbsolutePath -> [String] -> IO [String]
commandArgdefaults = [Flag] -> AbsolutePath -> [String] -> IO [String]
nodefaults
    , commandAdvancedOptions :: [DarcsOptDescr Flag]
commandAdvancedOptions = OptSpec DarcsOptDescr Flag Any (UseIndex -> IncludeBoring -> Any)
-> [DarcsOptDescr Flag]
forall (d :: * -> *) f a b. OptSpec d f a b -> [d f]
odesc OptSpec DarcsOptDescr Flag Any (UseIndex -> IncludeBoring -> Any)
forall a. DarcsOption a (UseIndex -> IncludeBoring -> a)
commonAdvancedOpts
    , commandBasicOptions :: [DarcsOptDescr Flag]
commandBasicOptions = OptSpec
  DarcsOptDescr
  Flag
  Any
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Any)
-> [DarcsOptDescr Flag]
forall (d :: * -> *) f a b. OptSpec d f a b -> [d f]
odesc OptSpec
  DarcsOptDescr
  Flag
  Any
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Any)
forall a.
OptSpec
  DarcsOptDescr
  Flag
  a
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
whatsnewBasicOpts
    , commandDefaults :: [Flag]
commandDefaults = OptSpec
  DarcsOptDescr
  Flag
  [Flag]
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> [Flag])
-> [Flag]
forall (d :: * -> *) f b. OptSpec d f [f] b -> [f]
defaultFlags OptSpec
  DarcsOptDescr
  Flag
  [Flag]
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> [Flag])
forall a.
DarcsOption
  a
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> a)
whatsnewOpts
    , commandCheckOptions :: [Flag] -> [String]
commandCheckOptions = OptSpec
  DarcsOptDescr
  Flag
  Any
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> Any)
-> [Flag] -> [String]
forall (d :: * -> *) f a b. OptSpec d f a b -> [f] -> [String]
ocheck OptSpec
  DarcsOptDescr
  Flag
  Any
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> Any)
forall a.
DarcsOption
  a
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> a)
whatsnewOpts
    , commandParseOptions :: [Flag] -> [Flag]
commandParseOptions = OptSpec
  DarcsOptDescr
  Flag
  [Flag]
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> [Flag])
-> [Flag] -> [Flag]
forall (d :: * -> *) f b. OptSpec d f [f] b -> [f] -> [f]
onormalise OptSpec
  DarcsOptDescr
  Flag
  [Flag]
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> [Flag])
forall a.
DarcsOption
  a
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> a)
whatsnewOpts
    }
  where
    whatsnewBasicOpts :: OptSpec
  DarcsOptDescr
  Flag
  a
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
whatsnewBasicOpts
      = Maybe Summary
-> forall a. PrimOptSpec DarcsOptDescr Flag a (Maybe Summary)
O.maybeSummary Maybe Summary
forall a. Maybe a
Nothing
      PrimOptSpec
  DarcsOptDescr
  Flag
  (WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
  (Maybe Summary)
-> OptSpec
     DarcsOptDescr
     Flag
     (Bool
      -> LookFor -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
     (WithContext
      -> Bool
      -> LookFor
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (Bool
      -> LookFor -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
     (Maybe Summary
      -> WithContext
      -> Bool
      -> LookFor
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
  DarcsOptDescr
  Flag
  (Bool
   -> LookFor -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
  (WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
PrimDarcsOption WithContext
O.withContext
      OptSpec
  DarcsOptDescr
  Flag
  (Bool
   -> LookFor -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (LookFor -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
     (Bool
      -> LookFor -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (LookFor -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
     (Maybe Summary
      -> WithContext
      -> Bool
      -> LookFor
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
  DarcsOptDescr
  Flag
  (LookFor -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
  (Bool
   -> LookFor -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
PrimDarcsOption Bool
O.machineReadable
      OptSpec
  DarcsOptDescr
  Flag
  (LookFor -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
     (LookFor -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
     (Maybe Summary
      -> WithContext
      -> Bool
      -> LookFor
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
  DarcsOptDescr
  Flag
  (DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
  (LookFor -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
PrimDarcsOption LookFor
O.lookfor
      OptSpec
  DarcsOptDescr
  Flag
  (DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (Maybe String -> Maybe Bool -> a)
     (DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (Maybe String -> Maybe Bool -> a)
     (Maybe Summary
      -> WithContext
      -> Bool
      -> LookFor
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
  DarcsOptDescr
  Flag
  (Maybe String -> Maybe Bool -> a)
  (DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
PrimDarcsOption DiffAlgorithm
O.diffAlgorithm
      OptSpec
  DarcsOptDescr
  Flag
  (Maybe String -> Maybe Bool -> a)
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (Maybe Bool -> a)
     (Maybe String -> Maybe Bool -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (Maybe Bool -> a)
     (Maybe Summary
      -> WithContext
      -> Bool
      -> LookFor
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
  DarcsOptDescr
  Flag
  (Maybe Bool -> a)
  (Maybe String -> Maybe Bool -> a)
PrimDarcsOption (Maybe String)
O.repoDir
      OptSpec
  DarcsOptDescr
  Flag
  (Maybe Bool -> a)
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe Bool -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     a
     (Maybe Summary
      -> WithContext
      -> Bool
      -> LookFor
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr Flag a (Maybe Bool -> a)
PrimDarcsOption (Maybe Bool)
O.interactive -- False
    whatsnewOpts :: DarcsOption
  a
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> a)
whatsnewOpts = OptSpec
  DarcsOptDescr
  Flag
  (Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> a)
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> a)
forall a.
OptSpec
  DarcsOptDescr
  Flag
  a
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
whatsnewBasicOpts OptSpec
  DarcsOptDescr
  Flag
  (Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> a)
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookFor
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> a)
-> DarcsOption
     (UseCache -> HooksConfig -> a)
     (UseIndex -> IncludeBoring -> UseCache -> HooksConfig -> a)
-> DarcsOption
     a
     (Maybe Summary
      -> WithContext
      -> Bool
      -> LookFor
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> Maybe StdCmdAction
      -> Bool
      -> Bool
      -> Verbosity
      -> Bool
      -> UseIndex
      -> IncludeBoring
      -> UseCache
      -> HooksConfig
      -> a)
forall b c a.
DarcsOption
  (Maybe StdCmdAction -> Bool -> Bool -> Verbosity -> Bool -> b) c
-> DarcsOption (UseCache -> HooksConfig -> a) b -> DarcsOption a c
`withStdOpts` DarcsOption
  (UseCache -> HooksConfig -> a)
  (UseIndex -> IncludeBoring -> UseCache -> HooksConfig -> a)
forall a. DarcsOption a (UseIndex -> IncludeBoring -> a)
commonAdvancedOpts

whatsnewDescription :: String
whatsnewDescription :: String
whatsnewDescription = "List unrecorded changes in the working tree."

whatsnewHelp :: String
whatsnewHelp :: String
whatsnewHelp =
 "The `darcs whatsnew` command lists unrecorded changes to the working\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "tree.  If you specify a set of files and directories, only unrecorded\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "changes to those files and directories are listed.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "With the `--summary` option, the changes are condensed to one line per\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "file, with mnemonics to indicate the nature and extent of the change.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "The `--look-for-adds` option causes candidates for `darcs add` to be\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "included in the summary output.  Summary mnemonics are as follows:\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "* `A f` and `A d/` respectively mean an added file or directory.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "* `R f` and `R d/` respectively mean a removed file or directory.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "* `M f -N +M rP` means a modified file, with `N` lines deleted, `M`\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "  lines added, and `P` lexical replacements.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "* `f -> g` means a moved file or directory.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "* `a f` and `a d/` respectively mean a new, but unadded, file or\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "  directory, when using `--look-for-adds`.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "  An exclamation mark (!) as in `R! foo.c`, means the change is known to\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "  conflict with a change in another patch.  The phrase `duplicated`\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "  means the change is known to be identical to a change in another patch.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "The `--machine-readable` option implies `--summary` while making it more\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "parsable. Modified files are only shown as `M f`, and moves are shown in\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "two lines: `F f` and `T g` (as in 'From f To g').\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "By default, `darcs whatsnew` uses Darcs' internal format for changes.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "To see some context (unchanged lines) around each change, use the\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "`--unified` option.  To view changes in conventional `diff` format, use\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "the `darcs diff` command; but note that `darcs whatsnew` is faster.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "This command exits unsuccessfully (returns a non-zero exit status) if\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
 "there are no unrecorded changes.\n"

whatsnewCmd :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO ()
whatsnewCmd :: (AbsolutePath, AbsolutePath) -> [Flag] -> [String] -> IO ()
whatsnewCmd fps :: (AbsolutePath, AbsolutePath)
fps opts :: [Flag]
opts args :: [String]
args =
   UseCache -> RepoJob () -> IO ()
forall a. UseCache -> RepoJob a -> IO a
withRepository (PrimDarcsOption UseCache
useCache PrimDarcsOption UseCache -> [Flag] -> UseCache
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [Flag]
opts) (RepoJob () -> IO ()) -> RepoJob () -> IO ()
forall a b. (a -> b) -> a -> b
$ (forall (rt :: RepoType) (p :: * -> * -> *) wR wU.
 (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) =>
 Repository rt p wR wU wR -> IO ())
-> RepoJob ()
forall a.
(forall (rt :: RepoType) (p :: * -> * -> *) wR wU.
 (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) =>
 Repository rt p wR wU wR -> IO a)
-> RepoJob a
RepoJob ((forall (rt :: RepoType) (p :: * -> * -> *) wR wU.
  (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) =>
  Repository rt p wR wU wR -> IO ())
 -> RepoJob ())
-> (forall (rt :: RepoType) (p :: * -> * -> *) wR wU.
    (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) =>
    Repository rt p wR wU wR -> IO ())
-> RepoJob ()
forall a b. (a -> b) -> a -> b
$ \(Repository rt p wR wU wR
repo :: Repository rt p wR wU wR) -> do
    let scan :: ScanKnown
scan = LookForAdds -> IncludeBoring -> ScanKnown
scanKnown ([Flag] -> LookForAdds
lookForAdds [Flag]
opts) (PrimDarcsOption IncludeBoring
O.includeBoring PrimDarcsOption IncludeBoring -> [Flag] -> IncludeBoring
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [Flag]
opts)
    Maybe [SubPath]
existing_files <- do
      Maybe [SubPath]
files <- if [String] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [String]
args then Maybe [SubPath] -> IO (Maybe [SubPath])
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [SubPath]
forall a. Maybe a
Nothing
               else [SubPath] -> Maybe [SubPath]
forall a. a -> Maybe a
Just ([SubPath] -> Maybe [SubPath])
-> ([SubPath] -> [SubPath]) -> [SubPath] -> Maybe [SubPath]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [SubPath] -> [SubPath]
forall a. Ord a => [a] -> [a]
nubSort ([SubPath] -> Maybe [SubPath])
-> IO [SubPath] -> IO (Maybe [SubPath])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (AbsolutePath, AbsolutePath) -> [String] -> IO [SubPath]
fixSubPaths (AbsolutePath, AbsolutePath)
fps [String]
args
      Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Maybe [SubPath]
files Maybe [SubPath] -> Maybe [SubPath] -> Bool
forall a. Eq a => a -> a -> Bool
== [SubPath] -> Maybe [SubPath]
forall a. a -> Maybe a
Just []) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "No valid arguments were given."
      Maybe ([SubPath], [SubPath])
files' <- ([SubPath] -> IO ([SubPath], [SubPath]))
-> Maybe [SubPath] -> IO (Maybe ([SubPath], [SubPath]))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse
        (Repository rt p wR wU wR
-> Verbosity
-> UseIndex
-> ScanKnown
-> LookForMoves
-> [SubPath]
-> IO ([SubPath], [SubPath])
forall (p :: * -> * -> *) (rt :: RepoType) wR wU wT.
(RepoPatch p, ApplyState p ~ Tree) =>
Repository rt p wR wU wT
-> Verbosity
-> UseIndex
-> ScanKnown
-> LookForMoves
-> [SubPath]
-> IO ([SubPath], [SubPath])
filterExistingPaths
          Repository rt p wR wU wR
repo (PrimDarcsOption Verbosity
verbosity PrimDarcsOption Verbosity -> [Flag] -> Verbosity
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [Flag]
opts) (PrimDarcsOption UseIndex
useIndex PrimDarcsOption UseIndex -> [Flag] -> UseIndex
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [Flag]
opts) ScanKnown
scan ([Flag] -> LookForMoves
lookForMoves [Flag]
opts))
        Maybe [SubPath]
files
      let files'' :: Maybe [SubPath]
files'' = (([SubPath], [SubPath]) -> [SubPath])
-> Maybe ([SubPath], [SubPath]) -> Maybe [SubPath]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ([SubPath], [SubPath]) -> [SubPath]
forall a b. (a, b) -> b
snd Maybe ([SubPath], [SubPath])
files'
      Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Maybe [SubPath]
files'' Maybe [SubPath] -> Maybe [SubPath] -> Bool
forall a. Eq a => a -> a -> Bool
== [SubPath] -> Maybe [SubPath]
forall a. a -> Maybe a
Just []) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
        String -> IO ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail "None of the files you specified exist."
      Maybe [SubPath] -> IO (Maybe [SubPath])
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [SubPath]
files''

    -- get all unrecorded changes, possibly including unadded or even boring
    -- files if the appropriate options were supplied
    Sealed allInterestingChanges :: FL (PrimOf p) wR wX
allInterestingChanges <-
      (UseIndex, ScanKnown, DiffAlgorithm)
-> LookForMoves
-> LookForReplaces
-> Repository rt p wR wU wR
-> Maybe [SubPath]
-> IO (Sealed (FL (PrimOf p) wR))
forall (rt :: RepoType) (p :: * -> * -> *) wR wU wT.
(RepoPatch p, ApplyState p ~ Tree) =>
(UseIndex, ScanKnown, DiffAlgorithm)
-> LookForMoves
-> LookForReplaces
-> Repository rt p wR wU wT
-> Maybe [SubPath]
-> IO (Sealed (FL (PrimOf p) wT))
filteredUnrecordedChanges ([Flag] -> (UseIndex, ScanKnown, DiffAlgorithm)
diffingOpts [Flag]
opts)
        ([Flag] -> LookForMoves
lookForMoves [Flag]
opts) ([Flag] -> LookForReplaces
lookForReplaces [Flag]
opts)
        Repository rt p wR wU wR
repo Maybe [SubPath]
existing_files

    -- get the recorded state
    Tree IO
pristine <- Repository rt p wR wU wR -> IO (Tree IO)
forall (rt :: RepoType) (p :: * -> * -> *) wR wU wT.
Repository rt p wR wU wT -> IO (Tree IO)
readRecorded Repository rt p wR wU wR
repo

    -- the case --look-for-adds and --summary must be handled specially
    -- in order to distinguish added and unadded files

    -- TODO: it would be nice if we could return the pair
    -- (noLookChanges,unaddedNewPathsPs) in one go and also
    -- with proper witnesses (e.g. as noLookChanges +>+ unaddedNewPathsPs)
    -- This would also obviate the need for samePatchType.
    Sealed noLookChanges :: FL (PrimOf p) wR wX
noLookChanges <-
      if Bool
haveLookForAddsAndSummary
        then
          -- do *not* look for adds here:
          (UseIndex, ScanKnown, DiffAlgorithm)
-> LookForMoves
-> LookForReplaces
-> Repository rt p wR wU wR
-> Maybe [SubPath]
-> IO (Sealed (FL (PrimOf p) wR))
forall (rt :: RepoType) (p :: * -> * -> *) wR wU wT.
(RepoPatch p, ApplyState p ~ Tree) =>
(UseIndex, ScanKnown, DiffAlgorithm)
-> LookForMoves
-> LookForReplaces
-> Repository rt p wR wU wT
-> Maybe [SubPath]
-> IO (Sealed (FL (PrimOf p) wT))
filteredUnrecordedChanges (PrimDarcsOption UseIndex
O.useIndex PrimDarcsOption UseIndex -> [Flag] -> UseIndex
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [Flag]
opts, ScanKnown
O.ScanKnown, PrimDarcsOption DiffAlgorithm
O.diffAlgorithm PrimDarcsOption DiffAlgorithm -> [Flag] -> DiffAlgorithm
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [Flag]
opts)
            ([Flag] -> LookForMoves
lookForMoves [Flag]
opts) ([Flag] -> LookForReplaces
lookForReplaces [Flag]
opts)
            Repository rt p wR wU wR
repo Maybe [SubPath]
existing_files
        else Sealed (FL (PrimOf p) wR) -> IO (Sealed (FL (PrimOf p) wR))
forall (m :: * -> *) a. Monad m => a -> m a
return (FL (PrimOf p) wR wR -> Sealed (FL (PrimOf p) wR)
forall (a :: * -> *) wX. a wX -> Sealed a
Sealed FL (PrimOf p) wR wR
forall (a :: * -> * -> *) wX. FL a wX wX
NilFL)
    Sealed unaddedNewPathsPs :: FL (PrimOf p) Any wX
unaddedNewPathsPs <-
      if Bool
haveLookForAddsAndSummary
        then do
          Tree IO
noLookAddsTree <- FL (PrimOf p) wR wX -> Tree IO -> IO (Tree IO)
forall (m :: * -> *) (p :: * -> * -> *) wX wY.
(Commute p, PrimClassify p, Apply p, Monad m,
 ApplyState p ~ Tree) =>
FL p wX wY -> Tree m -> m (Tree m)
applyAddPatchesToPristine FL (PrimOf p) wR wX
noLookChanges Tree IO
pristine
          Tree IO
lookAddsTree <- FL (PrimOf p) wR wX -> Tree IO -> IO (Tree IO)
forall (m :: * -> *) (p :: * -> * -> *) wX wY.
(Commute p, PrimClassify p, Apply p, Monad m,
 ApplyState p ~ Tree) =>
FL p wX wY -> Tree m -> m (Tree m)
applyAddPatchesToPristine FL (PrimOf p) wR wX
allInterestingChanges Tree IO
pristine
          String -> FileType
ftf <- IO (String -> FileType)
filetypeFunction
          -- Return the patches that create files/dirs that aren't yet added.
          FreeLeft (FL (PrimOf p)) -> Sealed (FL (PrimOf p) Any)
forall (p :: * -> * -> *) wX. FreeLeft p -> Sealed (p wX)
unFreeLeft (FreeLeft (FL (PrimOf p)) -> Sealed (FL (PrimOf p) Any))
-> IO (FreeLeft (FL (PrimOf p))) -> IO (Sealed (FL (PrimOf p) Any))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DiffAlgorithm
-> (String -> FileType)
-> Tree IO
-> Tree IO
-> IO (FreeLeft (FL (PrimOf p)))
forall (m :: * -> *) (w :: (* -> * -> *) -> *)
       (prim :: * -> * -> *).
(Monad m, Gap w, PrimPatch prim) =>
DiffAlgorithm
-> (String -> FileType) -> Tree m -> Tree m -> m (w (FL prim))
treeDiff (PrimDarcsOption DiffAlgorithm
diffAlgorithm PrimDarcsOption DiffAlgorithm -> [Flag] -> DiffAlgorithm
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [Flag]
opts) String -> FileType
ftf Tree IO
noLookAddsTree Tree IO
lookAddsTree
        else Sealed (FL (PrimOf p) Any) -> IO (Sealed (FL (PrimOf p) Any))
forall (m :: * -> *) a. Monad m => a -> m a
return (FL (PrimOf p) Any Any -> Sealed (FL (PrimOf p) Any)
forall (a :: * -> *) wX. a wX -> Sealed a
Sealed FL (PrimOf p) Any Any
forall (a :: * -> * -> *) wX. FL a wX wX
NilFL)
    -- avoid ambiguous typing for unaddedNewPathsPs:
    FL (PrimOf p) wR wX -> FL (PrimOf p) Any wX -> IO ()
forall (p :: * -> * -> *) wX wY wU wV.
FL p wX wY -> FL p wU wV -> IO ()
samePatchType FL (PrimOf p) wR wX
noLookChanges FL (PrimOf p) Any wX
unaddedNewPathsPs

    FL (PrimOf p) wR wX -> IO ()
forall (p :: * -> * -> *) wX wY. FL p wX wY -> IO ()
exitOnNoChanges FL (PrimOf p) wR wX
allInterestingChanges
    Verbosity -> Maybe [SubPath] -> String -> IO ()
announceFiles (PrimDarcsOption Verbosity
verbosity PrimDarcsOption Verbosity -> [Flag] -> Verbosity
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [Flag]
opts) Maybe [SubPath]
existing_files "What's new in"
    if [Flag] -> Bool
maybeIsInteractive [Flag]
opts
      then
        InteractiveSelectionM (PrimOf p) wR wX ()
-> PatchSelectionOptions
-> DiffAlgorithm
-> Tree IO
-> FL (PrimOf p) wR wX
-> IO ()
forall (p :: * -> * -> *) wX wY.
PrimPatch p =>
InteractiveSelectionM p wX wY ()
-> PatchSelectionOptions
-> DiffAlgorithm
-> Tree IO
-> FL p wX wY
-> IO ()
runInteractive (Tree IO -> InteractiveSelectionM (PrimOf p) wR wX ()
forall (p :: * -> * -> *) wX wY.
(IsHunk p, ShowPatch p, ShowContextPatch p, Commute p,
 PatchInspect p, PrimDetails p, ApplyState p ~ Tree) =>
Tree IO -> InteractiveSelectionM p wX wY ()
interactiveHunks Tree IO
pristine) ([Flag] -> PatchSelectionOptions
patchSelOpts [Flag]
opts)
          (PrimDarcsOption DiffAlgorithm
diffAlgorithm PrimDarcsOption DiffAlgorithm -> [Flag] -> DiffAlgorithm
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [Flag]
opts) Tree IO
pristine FL (PrimOf p) wR wX
allInterestingChanges
      else
        if Bool
haveLookForAddsAndSummary
          then do
            Tree IO -> FL (PrimOf p) wR wX -> IO ()
forall (p :: * -> * -> *) wX wY.
(IsHunk p, ShowPatch p, ShowContextPatch p, PatchListFormat p,
 Apply p, PrimDetails p, ApplyState p ~ Tree) =>
Tree IO -> FL p wX wY -> IO ()
printChanges Tree IO
pristine FL (PrimOf p) wR wX
noLookChanges
            FL (PrimOf p) Any wX -> IO ()
forall (p :: * -> * -> *) wX wY. PrimPatch p => FL p wX wY -> IO ()
printUnaddedPaths FL (PrimOf p) Any wX
unaddedNewPathsPs
          else do
            Tree IO -> FL (PrimOf p) wR wX -> IO ()
forall (p :: * -> * -> *) wX wY.
(IsHunk p, ShowPatch p, ShowContextPatch p, PatchListFormat p,
 Apply p, PrimDetails p, ApplyState p ~ Tree) =>
Tree IO -> FL p wX wY -> IO ()
printChanges Tree IO
pristine FL (PrimOf p) wR wX
allInterestingChanges
  where
    haveSummary :: Bool
haveSummary = Summary -> Bool
forall a. YesNo a => a -> Bool
O.yes ([Flag] -> Summary
getSummary [Flag]
opts)
    haveLookForAddsAndSummary :: Bool
haveLookForAddsAndSummary = Bool
haveSummary Bool -> Bool -> Bool
&& LookForAdds -> Bool
forall a. YesNo a => a -> Bool
O.yes ([Flag] -> LookForAdds
lookForAdds [Flag]
opts)

    -- Filter out hunk patches (leaving add patches) and return the tree
    -- resulting from applying the filtered patches to the pristine tree.
    applyAddPatchesToPristine :: FL p wX wY -> Tree m -> m (Tree m)
applyAddPatchesToPristine ps :: FL p wX wY
ps pristine :: Tree m
pristine = do
        adds :: RL p wX wZ
adds :> _ <- (:>) (RL p) (RL p) wX wY -> m ((:>) (RL p) (RL p) wX wY)
forall (m :: * -> *) a. Monad m => a -> m a
return ((:>) (RL p) (RL p) wX wY -> m ((:>) (RL p) (RL p) wX wY))
-> (:>) (RL p) (RL p) wX wY -> m ((:>) (RL p) (RL p) wX wY)
forall a b. (a -> b) -> a -> b
$ (forall wU wV. p wU wV -> Bool)
-> RL p wX wY -> (:>) (RL p) (RL p) wX wY
forall (p :: * -> * -> *) wX wY.
Commute p =>
(forall wU wV. p wU wV -> Bool)
-> RL p wX wY -> (:>) (RL p) (RL p) wX wY
partitionRL forall wU wV. p wU wV -> Bool
forall (prim :: * -> * -> *) wX wY.
PrimClassify prim =>
prim wX wY -> Bool
primIsHunk (RL p wX wY -> (:>) (RL p) (RL p) wX wY)
-> RL p wX wY -> (:>) (RL p) (RL p) wX wY
forall a b. (a -> b) -> a -> b
$ FL p wX wY -> RL p wX wY
forall (a :: * -> * -> *) wX wZ. FL a wX wZ -> RL a wX wZ
reverseFL FL p wX wY
ps
        FL p wX wZ -> Tree m -> m (Tree m)
forall (p :: * -> * -> *) (m :: * -> *) wX wY.
(Apply p, Monad m, ApplyState p ~ Tree) =>
p wX wY -> Tree m -> m (Tree m)
applyToTree (RL p wX wZ -> FL p wX wZ
forall (a :: * -> * -> *) wX wZ. RL a wX wZ -> FL a wX wZ
reverseRL RL p wX wZ
adds) Tree m
pristine

    exitOnNoChanges :: FL p wX wY -> IO ()
    exitOnNoChanges :: FL p wX wY -> IO ()
exitOnNoChanges NilFL = do String -> IO ()
putStrLn "No changes!"
                               ExitCode -> IO ()
forall a. ExitCode -> IO a
exitWith (ExitCode -> IO ()) -> ExitCode -> IO ()
forall a b. (a -> b) -> a -> b
$ Int -> ExitCode
ExitFailure 1
    exitOnNoChanges _ = () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

    -- This function does nothing. Its purpose is to enforce the
    -- same patch type for the two passed FLs. This is necessary
    -- in order to avoid ambiguous typing for unaddedNewPathsPs.
    samePatchType :: FL p wX wY -> FL p wU wV -> IO ()
    samePatchType :: FL p wX wY -> FL p wU wV -> IO ()
samePatchType _ _ = () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

    printUnaddedPaths :: PrimPatch p => FL p wX wY -> IO ()
    printUnaddedPaths :: FL p wX wY -> IO ()
printUnaddedPaths NilFL = () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
    printUnaddedPaths ps :: FL p wX wY
ps =
        Doc -> IO ()
putDocLn (Doc -> IO ()) -> (FL p wX wY -> Doc) -> FL p wX wY -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Doc
lowercaseAs (String -> Doc) -> (FL p wX wY -> String) -> FL p wX wY -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> String
renderString (Doc -> String) -> (FL p wX wY -> Doc) -> FL p wX wY -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> FL p wX wY -> Doc
forall (prim :: * -> * -> *) wX wY.
PrimDetails prim =>
Bool -> FL prim wX wY -> Doc
plainSummaryPrims Bool
False) (FL p wX wY -> IO ()) -> FL p wX wY -> IO ()
forall a b. (a -> b) -> a -> b
$ FL p wX wY
ps

    -- Make any add markers lowercase, to distinguish new-but-unadded files
    -- from those that are unrecorded, but added.
    lowercaseAs :: String -> Doc
lowercaseAs x :: String
x = [Doc] -> Doc
vcat ([Doc] -> Doc) -> [Doc] -> Doc
forall a b. (a -> b) -> a -> b
$ (String -> Doc) -> [String] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map (String -> Doc
text (String -> Doc) -> (String -> String) -> String -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
lowercaseA) ([String] -> [Doc]) -> [String] -> [Doc]
forall a b. (a -> b) -> a -> b
$ String -> [String]
lines String
x
    lowercaseA :: String -> String
lowercaseA ('A' : x :: String
x) = 'a' Char -> String -> String
forall a. a -> [a] -> [a]
: String
x
    lowercaseA x :: String
x = String
x

    -- Appropriately print changes, according to the passed flags.
    -- Note this cannot make distinction between unadded and added files.
    printChanges :: ( IsHunk p, ShowPatch p, ShowContextPatch p
                    , PatchListFormat p, Apply p
                    , PrimDetails p, ApplyState p ~ Tree)
                 => Tree IO -> FL p wX wY
                 -> IO ()
    printChanges :: Tree IO -> FL p wX wY -> IO ()
printChanges pristine :: Tree IO
pristine changes :: FL p wX wY
changes
        | Bool
haveSummary = Doc -> IO ()
putDocLn (Doc -> IO ()) -> Doc -> IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> FL p wX wY -> Doc
forall (prim :: * -> * -> *) wX wY.
PrimDetails prim =>
Bool -> FL prim wX wY -> Doc
plainSummaryPrims Bool
machineReadable FL p wX wY
changes
        | WithContext -> Bool
forall a. YesNo a => a -> Bool
O.yes (PrimDarcsOption WithContext
withContext PrimDarcsOption WithContext -> [Flag] -> WithContext
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [Flag]
opts) = Tree IO -> FL p wX wY -> IO ()
forall (p :: * -> * -> *) wX wY.
(ShowContextPatch p, ApplyState p ~ Tree) =>
Tree IO -> p wX wY -> IO ()
contextualPrintPatch Tree IO
pristine FL p wX wY
changes
        | Bool
otherwise = FL p wX wY -> IO ()
forall (p :: * -> * -> *) wX wY. ShowPatch p => p wX wY -> IO ()
printPatch FL p wX wY
changes
     where machineReadable :: Bool
machineReadable = PrimDarcsOption Bool -> [Flag] -> Bool
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
parseFlags PrimDarcsOption Bool
O.machineReadable [Flag]
opts

    -- return the unrecorded changes that affect an optional list of paths.
    filteredUnrecordedChanges :: forall rt p wR wU wT. (RepoPatch p, ApplyState p ~ Tree)
                              => (O.UseIndex, O.ScanKnown, O.DiffAlgorithm)
                              -> O.LookForMoves
                              -> O.LookForReplaces
                              -> Repository rt p wR wU wT -> Maybe [SubPath]
                              -> IO (Sealed (FL (PrimOf p) wT))
    filteredUnrecordedChanges :: (UseIndex, ScanKnown, DiffAlgorithm)
-> LookForMoves
-> LookForReplaces
-> Repository rt p wR wU wT
-> Maybe [SubPath]
-> IO (Sealed (FL (PrimOf p) wT))
filteredUnrecordedChanges diffing :: (UseIndex, ScanKnown, DiffAlgorithm)
diffing lfm :: LookForMoves
lfm lfr :: LookForReplaces
lfr repo :: Repository rt p wR wU wT
repo files :: Maybe [SubPath]
files =
        let filePaths :: Maybe [String]
filePaths = (SubPath -> String) -> [SubPath] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map SubPath -> String
forall a. FilePathLike a => a -> String
toFilePath ([SubPath] -> [String]) -> Maybe [SubPath] -> Maybe [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe [SubPath]
files in
        Maybe [String] -> FL (PrimOf p) wT wU -> Sealed (FL (PrimOf p) wT)
forall (p :: * -> * -> *) wX wY.
(Apply p, Commute p, Invert p, PatchInspect p,
 ApplyState p ~ Tree) =>
Maybe [String] -> FL p wX wY -> Sealed (FL p wX)
choosePreTouching Maybe [String]
filePaths (FL (PrimOf p) wT wU -> Sealed (FL (PrimOf p) wT))
-> IO (FL (PrimOf p) wT wU) -> IO (Sealed (FL (PrimOf p) wT))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
          (UseIndex, ScanKnown, DiffAlgorithm)
-> LookForMoves
-> LookForReplaces
-> Repository rt p wR wU wT
-> Maybe [SubPath]
-> IO (FL (PrimOf p) wT wU)
forall (p :: * -> * -> *) (rt :: RepoType) wR wU wT.
(RepoPatch p, ApplyState p ~ Tree) =>
(UseIndex, ScanKnown, DiffAlgorithm)
-> LookForMoves
-> LookForReplaces
-> Repository rt p wR wU wT
-> Maybe [SubPath]
-> IO (FL (PrimOf p) wT wU)
unrecordedChanges (UseIndex, ScanKnown, DiffAlgorithm)
diffing LookForMoves
lfm LookForReplaces
lfr Repository rt p wR wU wT
repo Maybe [SubPath]
files

-- | Runs the 'InteractiveSelectionM' code
runInteractive :: PrimPatch p
               => InteractiveSelectionM p wX wY () -- Selection to run
               -> S.PatchSelectionOptions
               -> O.DiffAlgorithm
               -> Tree IO         -- Pristine
               -> FL p wX wY      -- A list of patches
               -> IO ()
runInteractive :: InteractiveSelectionM p wX wY ()
-> PatchSelectionOptions
-> DiffAlgorithm
-> Tree IO
-> FL p wX wY
-> IO ()
runInteractive i :: InteractiveSelectionM p wX wY ()
i patchsel :: PatchSelectionOptions
patchsel diffalg :: DiffAlgorithm
diffalg pristine :: Tree IO
pristine ps' :: FL p wX wY
ps' = do
    let lps' :: FL (LabelledPatch p) wX wY
lps' = Maybe Label -> FL p wX wY -> FL (LabelledPatch p) wX wY
forall (p :: * -> * -> *) wX wY.
Maybe Label -> FL p wX wY -> FL (LabelledPatch p) wX wY
labelPatches Maybe Label
forall a. Maybe a
Nothing FL p wX wY
ps'
        choices' :: PatchChoices p wX wY
choices' = FL (LabelledPatch p) wX wY -> PatchChoices p wX wY
forall (p :: * -> * -> *) wX wY.
FL (LabelledPatch p) wX wY -> PatchChoices p wX wY
mkPatchChoices FL (LabelledPatch p) wX wY
lps'
        ps :: PatchSelectionM p IO ()
ps = InteractiveSelectionM p wX wY ()
-> InteractiveSelectionContext p wX wY -> PatchSelectionM p IO ()
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT InteractiveSelectionM p wX wY ()
i (InteractiveSelectionContext p wX wY -> PatchSelectionM p IO ())
-> InteractiveSelectionContext p wX wY -> PatchSelectionM p IO ()
forall a b. (a -> b) -> a -> b
$
             ISC :: forall (p :: * -> * -> *) wX wY.
Int
-> Int
-> FZipper (LabelledPatch p) wX wY
-> PatchChoices p wX wY
-> InteractiveSelectionContext p wX wY
ISC { total :: Int
total   = FL (LabelledPatch p) wX wY -> Int
forall (a :: * -> * -> *) wX wZ. FL a wX wZ -> Int
lengthFL FL (LabelledPatch p) wX wY
lps'
                 , current :: Int
current = 0
                 , lps :: FZipper (LabelledPatch p) wX wY
lps     = RL (LabelledPatch p) wX wX
-> FL (LabelledPatch p) wX wY -> FZipper (LabelledPatch p) wX wY
forall (a :: * -> * -> *) wX wY wZ.
RL a wX wY -> FL a wY wZ -> FZipper a wX wZ
FZipper RL (LabelledPatch p) wX wX
forall (a :: * -> * -> *) wX. RL a wX wX
NilRL FL (LabelledPatch p) wX wY
lps'
                 , choices :: PatchChoices p wX wY
choices = PatchChoices p wX wY
choices'
                 }
    IO () -> IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ PatchSelectionM p IO () -> PatchSelectionContext p -> IO ()
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT PatchSelectionM p IO ()
ps (PatchSelectionContext p -> IO ())
-> PatchSelectionContext p -> IO ()
forall a b. (a -> b) -> a -> b
$
           WhichChanges
-> String
-> PatchSelectionOptions
-> Maybe (Splitter p)
-> Maybe [String]
-> Maybe (Tree IO)
-> PatchSelectionContext p
forall (prim :: * -> * -> *).
WhichChanges
-> String
-> PatchSelectionOptions
-> Maybe (Splitter prim)
-> Maybe [String]
-> Maybe (Tree IO)
-> PatchSelectionContext prim
selectionContextPrim WhichChanges
First "view" PatchSelectionOptions
patchsel
             (Splitter p -> Maybe (Splitter p)
forall a. a -> Maybe a
Just (DiffAlgorithm -> Splitter p
forall (p :: * -> * -> *).
PrimPatch p =>
DiffAlgorithm -> Splitter p
primSplitter DiffAlgorithm
diffalg))
             Maybe [String]
forall a. Maybe a
Nothing (Tree IO -> Maybe (Tree IO)
forall a. a -> Maybe a
Just Tree IO
pristine)

-- | The interactive part of @darcs whatsnew@
interactiveHunks :: (IsHunk p, ShowPatch p, ShowContextPatch p, Commute p,
                     PatchInspect p, PrimDetails p, ApplyState p ~ Tree)
                 => Tree IO -> InteractiveSelectionM p wX wY ()
interactiveHunks :: Tree IO -> InteractiveSelectionM p wX wY ()
interactiveHunks pristine :: Tree IO
pristine = do
    Maybe (Sealed2 (LabelledPatch p))
c <- InteractiveSelectionM p wX wY (Maybe (Sealed2 (LabelledPatch p)))
forall (p :: * -> * -> *) wX wY.
InteractiveSelectionM p wX wY (Maybe (Sealed2 (LabelledPatch p)))
currentPatch
    case Maybe (Sealed2 (LabelledPatch p))
c of
        Nothing -> IO () -> InteractiveSelectionM p wX wY ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> InteractiveSelectionM p wX wY ())
-> IO () -> InteractiveSelectionM p wX wY ()
forall a b. (a -> b) -> a -> b
$ String -> IO ()
putStrLn "No more changes!"
        Just (Sealed2 lp :: LabelledPatch p wX wY
lp) -> do
            IO () -> InteractiveSelectionM p wX wY ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> InteractiveSelectionM p wX wY ())
-> IO () -> InteractiveSelectionM p wX wY ()
forall a b. (a -> b) -> a -> b
$ p wX wY -> IO ()
forall (p :: * -> * -> *) wX wY. ShowPatch p => p wX wY -> IO ()
printPatch (LabelledPatch p wX wY -> p wX wY
forall (p :: * -> * -> *) wX wY. LabelledPatch p wX wY -> p wX wY
unLabel LabelledPatch p wX wY
lp)
            LabelledPatch p wX wY -> InteractiveSelectionM p wX wY ()
forall wX wY wX wY.
LabelledPatch p wX wY
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
repeatThis LabelledPatch p wX wY
lp
  where
    repeatThis :: LabelledPatch p wX wY
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
repeatThis lp :: LabelledPatch p wX wY
lp = do
        String
thePrompt <- InteractiveSelectionM p wX wY String
forall (p :: * -> * -> *) wX wY.
ShowPatch p =>
InteractiveSelectionM p wX wY String
prompt -- "Shall I view this change? (n/m)"
        Char
yorn <- IO Char
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) Char
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Char
 -> StateT
      (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) Char)
-> IO Char
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) Char
forall a b. (a -> b) -> a -> b
$ PromptConfig -> IO Char
promptChar
                (String -> String -> String -> Maybe Char -> String -> PromptConfig
PromptConfig String
thePrompt ([[KeyPress]] -> String
keysFor [[KeyPress]]
basic_options) ([[KeyPress]] -> String
keysFor [[KeyPress]]
adv_options)
                 (Char -> Maybe Char
forall a. a -> Maybe a
Just 'n') "?h")
        case Char
yorn of
            -- View change in context
            'v' -> IO ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Tree IO -> p wX wY -> IO ()
forall (p :: * -> * -> *) wX wY.
(ShowContextPatch p, ApplyState p ~ Tree) =>
Tree IO -> p wX wY -> IO ()
contextualPrintPatch Tree IO
pristine (LabelledPatch p wX wY -> p wX wY
forall (p :: * -> * -> *) wX wY. LabelledPatch p wX wY -> p wX wY
unLabel LabelledPatch p wX wY
lp))
                   StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LabelledPatch p wX wY
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
repeatThis LabelledPatch p wX wY
lp
            -- View summary of the change
            'x' -> IO ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (p wX wY -> IO ()
forall (p :: * -> * -> *) wX wY. ShowPatch p => p wX wY -> IO ()
printSummary (LabelledPatch p wX wY -> p wX wY
forall (p :: * -> * -> *) wX wY. LabelledPatch p wX wY -> p wX wY
unLabel LabelledPatch p wX wY
lp))
                   StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LabelledPatch p wX wY
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
repeatThis LabelledPatch p wX wY
lp
            -- View change and move on
            'y' -> IO ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Tree IO -> p wX wY -> IO ()
forall (p :: * -> * -> *) wX wY.
(ShowContextPatch p, ApplyState p ~ Tree) =>
Tree IO -> p wX wY -> IO ()
contextualPrintPatch Tree IO
pristine (LabelledPatch p wX wY -> p wX wY
forall (p :: * -> * -> *) wX wY. LabelledPatch p wX wY -> p wX wY
unLabel LabelledPatch p wX wY
lp))
                   StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Bool
-> LabelledPatch p wX wY
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (p :: * -> * -> *) wT wU wX wY.
Commute p =>
Bool -> LabelledPatch p wT wU -> InteractiveSelectionM p wX wY ()
decide Bool
True LabelledPatch p wX wY
lp StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall wX wY.
StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
next_hunk
            -- Go to the next patch
            'n' -> Bool
-> LabelledPatch p wX wY
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (p :: * -> * -> *) wT wU wX wY.
Commute p =>
Bool -> LabelledPatch p wT wU -> InteractiveSelectionM p wX wY ()
decide Bool
False LabelledPatch p wX wY
lp StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall wX wY.
StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
next_hunk
            -- Skip the whole file
            's' -> do
                InteractiveSelectionM p wX wY (Maybe String)
forall (p :: * -> * -> *) wX wY.
PatchInspect p =>
InteractiveSelectionM p wX wY (Maybe String)
currentFile InteractiveSelectionM p wX wY (Maybe String)
-> (Maybe String
    -> StateT
         (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ())
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> (String
    -> StateT
         (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ())
-> Maybe String
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe
                    (()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
                    (\f :: String
f -> String
-> Bool
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (p :: * -> * -> *) wX wY.
(Commute p, PatchInspect p) =>
String -> Bool -> InteractiveSelectionM p wX wY ()
decideWholeFile String
f Bool
False)
                StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall wX wY.
StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
next_hunk
            -- View change in a pager
            'p' -> IO ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (p wX wY -> IO ()
forall (p :: * -> * -> *) wX wY. ShowPatch p => p wX wY -> IO ()
printPatchPager (p wX wY -> IO ()) -> p wX wY -> IO ()
forall a b. (a -> b) -> a -> b
$ LabelledPatch p wX wY -> p wX wY
forall (p :: * -> * -> *) wX wY. LabelledPatch p wX wY -> p wX wY
unLabel LabelledPatch p wX wY
lp)
                   StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LabelledPatch p wX wY
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
repeatThis LabelledPatch p wX wY
lp
            -- Next change
            'j' -> StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall wX wY.
StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
next_hunk
            -- Previous change
            'k' -> StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall wX wY.
StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
prev_hunk
            -- Start from the first change
            'g' -> StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall wX wY.
StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
start_over
            -- Quit whatsnew
            'q' -> IO ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ()
 -> StateT
      (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ())
-> IO ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall a b. (a -> b) -> a -> b
$ IO ()
forall a. IO a
exitSuccess
            _ -> do IO ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ()
 -> StateT
      (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ())
-> (String -> IO ())
-> String
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO ()
putStrLn (String
 -> StateT
      (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ())
-> String
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall a b. (a -> b) -> a -> b
$
                        String -> [[KeyPress]] -> [[KeyPress]] -> String
helpFor "whatsnew" [[KeyPress]]
basic_options [[KeyPress]]
adv_options
                    LabelledPatch p wX wY
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
repeatThis LabelledPatch p wX wY
lp
    start_over :: StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
start_over = StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (p :: * -> * -> *) wX wY. InteractiveSelectionM p wX wY ()
backAll StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Tree IO
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (p :: * -> * -> *) wX wY.
(IsHunk p, ShowPatch p, ShowContextPatch p, Commute p,
 PatchInspect p, PrimDetails p, ApplyState p ~ Tree) =>
Tree IO -> InteractiveSelectionM p wX wY ()
interactiveHunks Tree IO
pristine
    next_hunk :: StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
next_hunk  = StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (p :: * -> * -> *) wX wY. InteractiveSelectionM p wX wY ()
skipOne StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (p :: * -> * -> *) wX wY.
(Commute p, ShowPatch p) =>
InteractiveSelectionM p wX wY ()
skipMundane StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Tree IO
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (p :: * -> * -> *) wX wY.
(IsHunk p, ShowPatch p, ShowContextPatch p, Commute p,
 PatchInspect p, PrimDetails p, ApplyState p ~ Tree) =>
Tree IO -> InteractiveSelectionM p wX wY ()
interactiveHunks Tree IO
pristine
    prev_hunk :: StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
prev_hunk  = StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (p :: * -> * -> *) wX wY. InteractiveSelectionM p wX wY ()
backOne StateT
  (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Tree IO
-> StateT
     (InteractiveSelectionContext p wX wY) (PatchSelectionM p IO) ()
forall (p :: * -> * -> *) wX wY.
(IsHunk p, ShowPatch p, ShowContextPatch p, Commute p,
 PatchInspect p, PrimDetails p, ApplyState p ~ Tree) =>
Tree IO -> InteractiveSelectionM p wX wY ()
interactiveHunks Tree IO
pristine
    options_yn :: [KeyPress]
options_yn =
        [ Char -> String -> KeyPress
KeyPress 'v' "view this change in a context"
        , Char -> String -> KeyPress
KeyPress 'y' "view this change in a context and go to the next one"
        , Char -> String -> KeyPress
KeyPress 'n' "skip this change and its dependencies" ]
    optionsView :: [KeyPress]
optionsView =
        [ Char -> String -> KeyPress
KeyPress 'p' "view this change in context wih pager "
        , Char -> String -> KeyPress
KeyPress 'x' "view a summary of this change"
        ]
    optionsNav :: [KeyPress]
optionsNav =
        [ Char -> String -> KeyPress
KeyPress 'q' "quit whatsnew"
        , Char -> String -> KeyPress
KeyPress 's' "skip the rest of the changes to this file"
        , Char -> String -> KeyPress
KeyPress 'j' "go to the next change"
        , Char -> String -> KeyPress
KeyPress 'k' "back up to previous change"
        , Char -> String -> KeyPress
KeyPress 'g' "start over from the first change"
        ]
    basic_options :: [[KeyPress]]
basic_options = [ [KeyPress]
options_yn ]
    adv_options :: [[KeyPress]]
adv_options = [ [KeyPress]
optionsView, [KeyPress]
optionsNav ]


-- | status is an alias for whatsnew, with implicit Summary and LookForAdds
-- flags. We override the default description, to include the implicit flags.
status :: DarcsCommand [DarcsFlag]
status :: DarcsCommand [Flag]
status = DarcsCommand [Flag]
statusAlias
    { commandDescription :: String
commandDescription = String
statusDesc
    , commandAdvancedOptions :: [DarcsOptDescr Flag]
commandAdvancedOptions = OptSpec DarcsOptDescr Flag Any (UseIndex -> IncludeBoring -> Any)
-> [DarcsOptDescr Flag]
forall (d :: * -> *) f a b. OptSpec d f a b -> [d f]
odesc OptSpec DarcsOptDescr Flag Any (UseIndex -> IncludeBoring -> Any)
forall a. DarcsOption a (UseIndex -> IncludeBoring -> a)
commonAdvancedOpts
    , commandBasicOptions :: [DarcsOptDescr Flag]
commandBasicOptions = OptSpec
  DarcsOptDescr
  Flag
  Any
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Any)
-> [DarcsOptDescr Flag]
forall (d :: * -> *) f a b. OptSpec d f a b -> [d f]
odesc OptSpec
  DarcsOptDescr
  Flag
  Any
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Any)
forall a.
OptSpec
  DarcsOptDescr
  Flag
  a
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
statusBasicOpts
    , commandDefaults :: [Flag]
commandDefaults = OptSpec
  DarcsOptDescr
  Flag
  [Flag]
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> [Flag])
-> [Flag]
forall (d :: * -> *) f b. OptSpec d f [f] b -> [f]
defaultFlags OptSpec
  DarcsOptDescr
  Flag
  [Flag]
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> [Flag])
forall a.
DarcsOption
  a
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> a)
statusOpts
    , commandCheckOptions :: [Flag] -> [String]
commandCheckOptions = OptSpec
  DarcsOptDescr
  Flag
  Any
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> Any)
-> [Flag] -> [String]
forall (d :: * -> *) f a b. OptSpec d f a b -> [f] -> [String]
ocheck OptSpec
  DarcsOptDescr
  Flag
  Any
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> Any)
forall a.
DarcsOption
  a
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> a)
statusOpts
    , commandParseOptions :: [Flag] -> [Flag]
commandParseOptions = OptSpec
  DarcsOptDescr
  Flag
  [Flag]
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> [Flag])
-> [Flag] -> [Flag]
forall (d :: * -> *) f b. OptSpec d f [f] b -> [f] -> [f]
onormalise OptSpec
  DarcsOptDescr
  Flag
  [Flag]
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> [Flag])
forall a.
DarcsOption
  a
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> a)
statusOpts
    }
  where
    statusAlias :: DarcsCommand [Flag]
statusAlias = String
-> Maybe (DarcsCommand [Flag])
-> DarcsCommand [Flag]
-> DarcsCommand [Flag]
forall pf.
String
-> Maybe (DarcsCommand pf) -> DarcsCommand pf -> DarcsCommand pf
commandAlias "status" Maybe (DarcsCommand [Flag])
forall a. Maybe a
Nothing DarcsCommand [Flag]
whatsnew
    statusDesc :: String
statusDesc = "Alias for `darcs " String -> String -> String
forall a. [a] -> [a] -> [a]
++ DarcsCommand [Flag] -> String
forall parsedFlags. DarcsCommand parsedFlags -> String
commandName DarcsCommand [Flag]
whatsnew String -> String -> String
forall a. [a] -> [a] -> [a]
++ " -ls '."
    statusBasicOpts :: OptSpec
  DarcsOptDescr
  Flag
  a
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
statusBasicOpts
      = Maybe Summary
-> forall a. PrimOptSpec DarcsOptDescr Flag a (Maybe Summary)
O.maybeSummary (Summary -> Maybe Summary
forall a. a -> Maybe a
Just Summary
O.YesSummary)
      PrimOptSpec
  DarcsOptDescr
  Flag
  (WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
  (Maybe Summary)
-> OptSpec
     DarcsOptDescr
     Flag
     (Bool
      -> LookForAdds
      -> LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
     (WithContext
      -> Bool
      -> LookForAdds
      -> LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (Bool
      -> LookForAdds
      -> LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
     (Maybe Summary
      -> WithContext
      -> Bool
      -> LookForAdds
      -> LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
  DarcsOptDescr
  Flag
  (Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
  (WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
PrimDarcsOption WithContext
O.withContext
      OptSpec
  DarcsOptDescr
  Flag
  (Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (LookForAdds
      -> LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
     (Bool
      -> LookForAdds
      -> LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (LookForAdds
      -> LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
     (Maybe Summary
      -> WithContext
      -> Bool
      -> LookForAdds
      -> LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
  DarcsOptDescr
  Flag
  (LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
  (Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
PrimDarcsOption Bool
O.machineReadable
      OptSpec
  DarcsOptDescr
  Flag
  (LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
     (LookForAdds
      -> LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
     (Maybe Summary
      -> WithContext
      -> Bool
      -> LookForAdds
      -> LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ LookForAdds -> PrimDarcsOption LookForAdds
O.lookforadds LookForAdds
O.YesLookForAdds
      OptSpec
  DarcsOptDescr
  Flag
  (LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (LookForMoves -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
     (LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (LookForMoves -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
     (Maybe Summary
      -> WithContext
      -> Bool
      -> LookForAdds
      -> LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
  DarcsOptDescr
  Flag
  (LookForMoves -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
  (LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
PrimDarcsOption LookForReplaces
O.lookforreplaces
      OptSpec
  DarcsOptDescr
  Flag
  (LookForMoves -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
     (LookForMoves -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
     (Maybe Summary
      -> WithContext
      -> Bool
      -> LookForAdds
      -> LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
  DarcsOptDescr
  Flag
  (DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
  (LookForMoves -> DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
PrimDarcsOption LookForMoves
O.lookformoves
      OptSpec
  DarcsOptDescr
  Flag
  (DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (Maybe String -> Maybe Bool -> a)
     (DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (Maybe String -> Maybe Bool -> a)
     (Maybe Summary
      -> WithContext
      -> Bool
      -> LookForAdds
      -> LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
  DarcsOptDescr
  Flag
  (Maybe String -> Maybe Bool -> a)
  (DiffAlgorithm -> Maybe String -> Maybe Bool -> a)
PrimDarcsOption DiffAlgorithm
O.diffAlgorithm
      OptSpec
  DarcsOptDescr
  Flag
  (Maybe String -> Maybe Bool -> a)
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (Maybe Bool -> a)
     (Maybe String -> Maybe Bool -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     (Maybe Bool -> a)
     (Maybe Summary
      -> WithContext
      -> Bool
      -> LookForAdds
      -> LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
  DarcsOptDescr
  Flag
  (Maybe Bool -> a)
  (Maybe String -> Maybe Bool -> a)
PrimDarcsOption (Maybe String)
O.repoDir
      OptSpec
  DarcsOptDescr
  Flag
  (Maybe Bool -> a)
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
-> OptSpec DarcsOptDescr Flag a (Maybe Bool -> a)
-> OptSpec
     DarcsOptDescr
     Flag
     a
     (Maybe Summary
      -> WithContext
      -> Bool
      -> LookForAdds
      -> LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr Flag a (Maybe Bool -> a)
PrimDarcsOption (Maybe Bool)
O.interactive
    statusOpts :: DarcsOption
  a
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> a)
statusOpts = OptSpec
  DarcsOptDescr
  Flag
  (Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> a)
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> a)
forall a.
OptSpec
  DarcsOptDescr
  Flag
  a
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> a)
statusBasicOpts OptSpec
  DarcsOptDescr
  Flag
  (Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> a)
  (Maybe Summary
   -> WithContext
   -> Bool
   -> LookForAdds
   -> LookForReplaces
   -> LookForMoves
   -> DiffAlgorithm
   -> Maybe String
   -> Maybe Bool
   -> Maybe StdCmdAction
   -> Bool
   -> Bool
   -> Verbosity
   -> Bool
   -> UseIndex
   -> IncludeBoring
   -> UseCache
   -> HooksConfig
   -> a)
-> DarcsOption
     (UseCache -> HooksConfig -> a)
     (UseIndex -> IncludeBoring -> UseCache -> HooksConfig -> a)
-> DarcsOption
     a
     (Maybe Summary
      -> WithContext
      -> Bool
      -> LookForAdds
      -> LookForReplaces
      -> LookForMoves
      -> DiffAlgorithm
      -> Maybe String
      -> Maybe Bool
      -> Maybe StdCmdAction
      -> Bool
      -> Bool
      -> Verbosity
      -> Bool
      -> UseIndex
      -> IncludeBoring
      -> UseCache
      -> HooksConfig
      -> a)
forall b c a.
DarcsOption
  (Maybe StdCmdAction -> Bool -> Bool -> Verbosity -> Bool -> b) c
-> DarcsOption (UseCache -> HooksConfig -> a) b -> DarcsOption a c
`withStdOpts` DarcsOption
  (UseCache -> HooksConfig -> a)
  (UseIndex -> IncludeBoring -> UseCache -> HooksConfig -> a)
forall a. DarcsOption a (UseIndex -> IncludeBoring -> a)
commonAdvancedOpts

maybeIsInteractive :: [DarcsFlag] -> Bool
maybeIsInteractive :: [Flag] -> Bool
maybeIsInteractive = Bool -> (Bool -> Bool) -> Maybe Bool -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False Bool -> Bool
forall a. a -> a
id (Maybe Bool -> Bool) -> ([Flag] -> Maybe Bool) -> [Flag] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrimDarcsOption (Maybe Bool) -> [Flag] -> Maybe Bool
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
parseFlags PrimDarcsOption (Maybe Bool)
O.interactive