module Darcs.UI.Commands.Tag ( tag ) where
import Darcs.Prelude
import Control.Monad ( when )
import System.IO ( hPutStr, stderr )
import Darcs.Patch.Apply ( ApplyState )
import Darcs.Patch.Info ( patchinfo )
import Darcs.Patch.Depends ( getUncovered )
import Darcs.Patch
( PrimPatch, PrimOf
, RepoPatch
)
import Darcs.Patch.PatchInfoAnd ( PatchInfoAnd, n2pia )
import Darcs.Patch.Named ( infopatch, adddeps )
import Darcs.Patch.Set
( emptyPatchSet, appendPSFL, patchSet2FL, patchSetTags )
import Darcs.Patch.Witnesses.Ordered ( FL(..), (:>)(..) )
import Darcs.Patch.Witnesses.Sealed ( Sealed(..), mapSeal )
import Darcs.Repository
( withRepoLock, Repository, RepoJob(..), readRepo
, tentativelyAddPatch, finalizeRepositoryChanges,
)
import Darcs.Repository.Flags ( UpdatePending(..), DryRun(NoDryRun) )
import Darcs.UI.Commands
( DarcsCommand(..), withStdOpts, nodefaults, amInHashedRepository, putFinished )
import Darcs.UI.Completion ( noArgs )
import Darcs.UI.Flags
( DarcsFlag, getDate, compress, verbosity, useCache, umask, getAuthor, author )
import Darcs.UI.Options
( (^), odesc, ocheck, defaultFlags, parseFlags, (?) )
import qualified Darcs.UI.Options.All as O
import Darcs.UI.PatchHeader ( getLog )
import Darcs.UI.SelectChanges
( WhichChanges(..)
, selectionConfig
, runSelection
, SelectionConfig(allowSkipAll)
)
import qualified Darcs.UI.SelectChanges as S
import Darcs.Util.Path ( AbsolutePath )
import Darcs.Util.Printer ( Doc, text )
import Darcs.Util.Tree( Tree )
tagDescription :: String
tagDescription :: String
tagDescription = String
"Name the current repository state for future reference."
tagHelp :: Doc
tagHelp :: Doc
tagHelp = String -> Doc
text (String -> Doc) -> String -> Doc
forall a b. (a -> b) -> a -> b
$
String
"The `darcs tag` command names the current repository state, so that it\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"can easily be referred to later. Every *important* state should be\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"tagged; in particular it is good practice to tag each stable release\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"with a number or codename. Advice on release numbering can be found\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"at <http://producingoss.com/en/development-cycle.html>.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"To reproduce the state of a repository `R` as at tag `t`, use the\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"command `darcs clone --tag t R`. The command `darcs show tags` lists\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"all tags in the current repository.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"Tagging also provides significant performance benefits: when Darcs\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"reaches a shared tag that depends on all antecedent patches, it can\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"simply stop processing.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"Like normal patches, a tag has a name, an author, a timestamp and an\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"optional long description, but it does not change the working tree.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"A tag can have any name, but it is generally best to pick a naming\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"scheme and stick to it.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"By default a tag names the entire repository state at the time the tag\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"is created. If the --ask-deps option is used, the patches to include\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"as part of the tag can be explicitly selected.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"The `darcs tag` command accepts the `--pipe` option, which behaves as\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"described in `darcs record`.\n"
tag :: DarcsCommand
tag :: DarcsCommand
tag = DarcsCommand :: String
-> String
-> Doc
-> String
-> Int
-> [String]
-> ((AbsolutePath, AbsolutePath)
-> [DarcsFlag] -> [String] -> IO ())
-> ([DarcsFlag] -> IO (Either String ()))
-> ((AbsolutePath, AbsolutePath)
-> [DarcsFlag] -> [String] -> IO [String])
-> ([DarcsFlag] -> AbsolutePath -> [String] -> IO [String])
-> [DarcsOptDescr DarcsFlag]
-> [DarcsOptDescr DarcsFlag]
-> [DarcsFlag]
-> ([DarcsFlag] -> [String])
-> DarcsCommand
DarcsCommand
{ commandProgramName :: String
commandProgramName = String
"darcs"
, commandName :: String
commandName = String
"tag"
, commandHelp :: Doc
commandHelp = Doc
tagHelp
, commandDescription :: String
commandDescription = String
tagDescription
, commandExtraArgs :: Int
commandExtraArgs = -Int
1
, commandExtraArgHelp :: [String]
commandExtraArgHelp = [String
"[TAGNAME]"]
, commandCommand :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO ()
commandCommand = (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO ()
tagCmd
, commandPrereq :: [DarcsFlag] -> IO (Either String ())
commandPrereq = [DarcsFlag] -> IO (Either String ())
amInHashedRepository
, commandCompleteArgs :: (AbsolutePath, AbsolutePath)
-> [DarcsFlag] -> [String] -> IO [String]
commandCompleteArgs = (AbsolutePath, AbsolutePath)
-> [DarcsFlag] -> [String] -> IO [String]
noArgs
, commandArgdefaults :: [DarcsFlag] -> AbsolutePath -> [String] -> IO [String]
commandArgdefaults = [DarcsFlag] -> AbsolutePath -> [String] -> IO [String]
nodefaults
, commandAdvancedOptions :: [DarcsOptDescr DarcsFlag]
commandAdvancedOptions = OptSpec DarcsOptDescr DarcsFlag Any (Compression -> UMask -> Any)
-> [DarcsOptDescr DarcsFlag]
forall (d :: * -> *) f a b. OptSpec d f a b -> [d f]
odesc OptSpec DarcsOptDescr DarcsFlag Any (Compression -> UMask -> Any)
forall a.
OptSpec DarcsOptDescr DarcsFlag a (Compression -> UMask -> a)
tagAdvancedOpts
, commandBasicOptions :: [DarcsOptDescr DarcsFlag]
commandBasicOptions = OptSpec
DarcsOptDescr
DarcsFlag
Any
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> Any)
-> [DarcsOptDescr DarcsFlag]
forall (d :: * -> *) f a b. OptSpec d f a b -> [d f]
odesc OptSpec
DarcsOptDescr
DarcsFlag
Any
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> Any)
forall a.
OptSpec
DarcsOptDescr
DarcsFlag
a
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> a)
tagBasicOpts
, commandDefaults :: [DarcsFlag]
commandDefaults = OptSpec
DarcsOptDescr
DarcsFlag
[DarcsFlag]
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> Maybe StdCmdAction
-> Verbosity
-> Compression
-> UMask
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> [DarcsFlag])
-> [DarcsFlag]
forall (d :: * -> *) f b. OptSpec d f [f] b -> [f]
defaultFlags OptSpec
DarcsOptDescr
DarcsFlag
[DarcsFlag]
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> Maybe StdCmdAction
-> Verbosity
-> Compression
-> UMask
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> [DarcsFlag])
forall a.
DarcsOption
a
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> Maybe StdCmdAction
-> Verbosity
-> Compression
-> UMask
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
tagOpts
, commandCheckOptions :: [DarcsFlag] -> [String]
commandCheckOptions = OptSpec
DarcsOptDescr
DarcsFlag
Any
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> Maybe StdCmdAction
-> Verbosity
-> Compression
-> UMask
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> Any)
-> [DarcsFlag] -> [String]
forall (d :: * -> *) f a b. OptSpec d f a b -> [f] -> [String]
ocheck OptSpec
DarcsOptDescr
DarcsFlag
Any
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> Maybe StdCmdAction
-> Verbosity
-> Compression
-> UMask
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> Any)
forall a.
DarcsOption
a
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> Maybe StdCmdAction
-> Verbosity
-> Compression
-> UMask
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
tagOpts
}
where
tagBasicOpts :: OptSpec
DarcsOptDescr
DarcsFlag
a
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> a)
tagBasicOpts
= PrimOptSpec
DarcsOptDescr
DarcsFlag
(Maybe String
-> Bool -> Maybe AskLongComment -> Bool -> Maybe String -> a)
(Maybe String)
PrimDarcsOption (Maybe String)
O.patchname
PrimOptSpec
DarcsOptDescr
DarcsFlag
(Maybe String
-> Bool -> Maybe AskLongComment -> Bool -> Maybe String -> a)
(Maybe String)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Bool -> Maybe AskLongComment -> Bool -> Maybe String -> a)
(Maybe String
-> Bool -> Maybe AskLongComment -> Bool -> Maybe String -> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Bool -> Maybe AskLongComment -> Bool -> Maybe String -> a)
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
DarcsOptDescr
DarcsFlag
(Bool -> Maybe AskLongComment -> Bool -> Maybe String -> a)
(Maybe String
-> Bool -> Maybe AskLongComment -> Bool -> Maybe String -> a)
PrimDarcsOption (Maybe String)
O.author
OptSpec
DarcsOptDescr
DarcsFlag
(Bool -> Maybe AskLongComment -> Bool -> Maybe String -> a)
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Maybe AskLongComment -> Bool -> Maybe String -> a)
(Bool -> Maybe AskLongComment -> Bool -> Maybe String -> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Maybe AskLongComment -> Bool -> Maybe String -> a)
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
DarcsOptDescr
DarcsFlag
(Maybe AskLongComment -> Bool -> Maybe String -> a)
(Bool -> Maybe AskLongComment -> Bool -> Maybe String -> a)
PrimDarcsOption Bool
O.pipe
OptSpec
DarcsOptDescr
DarcsFlag
(Maybe AskLongComment -> Bool -> Maybe String -> a)
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Bool -> Maybe String -> a)
(Maybe AskLongComment -> Bool -> Maybe String -> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Bool -> Maybe String -> a)
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
DarcsOptDescr
DarcsFlag
(Bool -> Maybe String -> a)
(Maybe AskLongComment -> Bool -> Maybe String -> a)
PrimDarcsOption (Maybe AskLongComment)
O.askLongComment
OptSpec
DarcsOptDescr
DarcsFlag
(Bool -> Maybe String -> a)
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Maybe String -> a)
(Bool -> Maybe String -> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Maybe String -> a)
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec
DarcsOptDescr
DarcsFlag
(Maybe String -> a)
(Bool -> Maybe String -> a)
PrimDarcsOption Bool
O.askDeps
OptSpec
DarcsOptDescr
DarcsFlag
(Maybe String -> a)
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> a)
-> OptSpec DarcsOptDescr DarcsFlag a (Maybe String -> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
a
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr DarcsFlag a (Maybe String -> a)
PrimDarcsOption (Maybe String)
O.repoDir
tagAdvancedOpts :: OptSpec DarcsOptDescr DarcsFlag a (Compression -> UMask -> a)
tagAdvancedOpts = PrimOptSpec DarcsOptDescr DarcsFlag (UMask -> a) Compression
PrimDarcsOption Compression
O.compress PrimOptSpec DarcsOptDescr DarcsFlag (UMask -> a) Compression
-> OptSpec DarcsOptDescr DarcsFlag a (UMask -> a)
-> OptSpec DarcsOptDescr DarcsFlag a (Compression -> UMask -> a)
forall (d :: * -> *) f b c a.
OptSpec d f b c -> OptSpec d f a b -> OptSpec d f a c
^ OptSpec DarcsOptDescr DarcsFlag a (UMask -> a)
PrimDarcsOption UMask
O.umask
tagOpts :: DarcsOption
a
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> Maybe StdCmdAction
-> Verbosity
-> Compression
-> UMask
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
tagOpts = OptSpec
DarcsOptDescr
DarcsFlag
(Maybe StdCmdAction
-> Verbosity
-> Compression
-> UMask
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> Maybe StdCmdAction
-> Verbosity
-> Compression
-> UMask
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
forall a.
OptSpec
DarcsOptDescr
DarcsFlag
a
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> a)
tagBasicOpts OptSpec
DarcsOptDescr
DarcsFlag
(Maybe StdCmdAction
-> Verbosity
-> Compression
-> UMask
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> Maybe StdCmdAction
-> Verbosity
-> Compression
-> UMask
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
-> DarcsOption
(UseCache -> HooksConfig -> Bool -> Bool -> Bool -> a)
(Compression
-> UMask -> UseCache -> HooksConfig -> Bool -> Bool -> Bool -> a)
-> DarcsOption
a
(Maybe String
-> Maybe String
-> Bool
-> Maybe AskLongComment
-> Bool
-> Maybe String
-> Maybe StdCmdAction
-> Verbosity
-> Compression
-> UMask
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
forall b c a.
DarcsOption (Maybe StdCmdAction -> Verbosity -> b) c
-> DarcsOption
(UseCache -> HooksConfig -> Bool -> Bool -> Bool -> a) b
-> DarcsOption a c
`withStdOpts` DarcsOption
(UseCache -> HooksConfig -> Bool -> Bool -> Bool -> a)
(Compression
-> UMask -> UseCache -> HooksConfig -> Bool -> Bool -> Bool -> a)
forall a.
OptSpec DarcsOptDescr DarcsFlag a (Compression -> UMask -> a)
tagAdvancedOpts
tagCmd :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO ()
tagCmd :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO ()
tagCmd (AbsolutePath, AbsolutePath)
_ [DarcsFlag]
opts [String]
args =
DryRun -> UseCache -> UpdatePending -> UMask -> RepoJob () -> IO ()
forall a.
DryRun -> UseCache -> UpdatePending -> UMask -> RepoJob a -> IO a
withRepoLock DryRun
NoDryRun (PrimDarcsOption UseCache
useCache PrimDarcsOption UseCache -> [DarcsFlag] -> UseCache
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts) UpdatePending
YesUpdatePending (PrimDarcsOption UMask
umask PrimDarcsOption UMask -> [DarcsFlag] -> UMask
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
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
repository :: Repository rt p wR wU wR) -> do
String
date <- Bool -> IO String
getDate ([DarcsFlag] -> Bool
hasPipe [DarcsFlag]
opts)
String
the_author <- Maybe String -> Bool -> IO String
getAuthor (PrimDarcsOption (Maybe String)
author PrimDarcsOption (Maybe String) -> [DarcsFlag] -> Maybe String
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts) ([DarcsFlag] -> Bool
hasPipe [DarcsFlag]
opts)
PatchSet rt p Origin wR
patches <- Repository rt p wR wU wR -> IO (PatchSet rt p Origin wR)
forall (rt :: RepoType) (p :: * -> * -> *) wR wU wT.
(IsRepoType rt, RepoPatch p) =>
Repository rt p wR wU wT -> IO (PatchSet rt p Origin wR)
readRepo Repository rt p wR wU wR
repository
[String]
tags <- [String] -> IO [String]
forall (m :: * -> *) a. Monad m => a -> m a
return ([String] -> IO [String]) -> [String] -> IO [String]
forall a b. (a -> b) -> a -> b
$ PatchSet rt p Origin wR -> [String]
forall (rt :: RepoType) (p :: * -> * -> *) wX wY.
PatchSet rt p wX wY -> [String]
patchSetTags PatchSet rt p Origin wR
patches
Sealed PatchSet rt p Origin wX
chosenPatches <-
if PrimDarcsOption Bool
O.askDeps PrimDarcsOption Bool -> [DarcsFlag] -> Bool
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts
then (forall wX.
FL (PatchInfoAnd rt p) Origin wX -> PatchSet rt p Origin wX)
-> Sealed (FL (PatchInfoAnd rt p) Origin)
-> Sealed (PatchSet rt p Origin)
forall (a :: * -> *) (b :: * -> *).
(forall wX. a wX -> b wX) -> Sealed a -> Sealed b
mapSeal (PatchSet rt p Origin Origin
-> FL (PatchInfoAnd rt p) Origin wX -> PatchSet rt p Origin wX
forall (rt :: RepoType) (p :: * -> * -> *) wStart wX wY.
PatchSet rt p wStart wX
-> FL (PatchInfoAnd rt p) wX wY -> PatchSet rt p wStart wY
appendPSFL PatchSet rt p Origin Origin
forall (rt :: RepoType) (p :: * -> * -> *).
PatchSet rt p Origin Origin
emptyPatchSet) (Sealed (FL (PatchInfoAnd rt p) Origin)
-> Sealed (PatchSet rt p Origin))
-> IO (Sealed (FL (PatchInfoAnd rt p) Origin))
-> IO (Sealed (PatchSet rt p Origin))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [DarcsFlag]
-> FL (PatchInfoAnd rt p) Origin wR
-> IO (Sealed (FL (PatchInfoAnd rt p) Origin))
forall (rt :: RepoType) (p :: * -> * -> *) wX wY.
(RepoPatch p, ApplyState p ~ Tree) =>
[DarcsFlag]
-> FL (PatchInfoAnd rt p) wX wY
-> IO (Sealed (FL (PatchInfoAnd rt p) wX))
askAboutTagDepends [DarcsFlag]
opts (PatchSet rt p Origin wR -> FL (PatchInfoAnd rt p) Origin wR
forall (rt :: RepoType) (p :: * -> * -> *) wStart wX.
PatchSet rt p wStart wX -> FL (PatchInfoAnd rt p) wStart wX
patchSet2FL PatchSet rt p Origin wR
patches)
else Sealed (PatchSet rt p Origin) -> IO (Sealed (PatchSet rt p Origin))
forall (m :: * -> *) a. Monad m => a -> m a
return (Sealed (PatchSet rt p Origin)
-> IO (Sealed (PatchSet rt p Origin)))
-> Sealed (PatchSet rt p Origin)
-> IO (Sealed (PatchSet rt p Origin))
forall a b. (a -> b) -> a -> b
$ PatchSet rt p Origin wR -> Sealed (PatchSet rt p Origin)
forall (a :: * -> *) wX. a wX -> Sealed a
Sealed PatchSet rt p Origin wR
patches
let deps :: [PatchInfo]
deps = PatchSet rt p Origin wX -> [PatchInfo]
forall (rt :: RepoType) (p :: * -> * -> *) wStart wX.
PatchSet rt p wStart wX -> [PatchInfo]
getUncovered PatchSet rt p Origin wX
chosenPatches
(String
name, [String]
long_comment) <- FL (PrimOf p) Any Any
-> [String] -> [String] -> IO (String, [String])
forall (prim :: * -> * -> *) wA.
PrimPatch prim =>
FL prim wA wA -> [String] -> [String] -> IO (String, [String])
get_name_log (forall wA. FL (PrimOf p) wA wA
forall (a :: * -> * -> *) wX. FL a wX wX
NilFL :: FL (PrimOf p) wA wA) [String]
args [String]
tags
PatchInfo
myinfo <- String -> String -> String -> [String] -> IO PatchInfo
patchinfo String
date String
name String
the_author [String]
long_comment
let mypatch :: Named p wY wY
mypatch = PatchInfo -> FL (PrimOf p) wY wY -> Named p wY wY
forall (p :: * -> * -> *) wX wY.
FromPrim p =>
PatchInfo -> FL (PrimOf p) wX wY -> Named p wX wY
infopatch PatchInfo
myinfo FL (PrimOf p) wY wY
forall (a :: * -> * -> *) wX. FL a wX wX
NilFL
Repository rt p wR wU wR
_ <- Repository rt p wR wU wR
-> Compression
-> Verbosity
-> UpdatePending
-> PatchInfoAnd rt p wR wR
-> IO (Repository rt p wR wU wR)
forall (p :: * -> * -> *) (rt :: RepoType) wR wU wT wY.
(RepoPatch p, ApplyState p ~ Tree) =>
Repository rt p wR wU wT
-> Compression
-> Verbosity
-> UpdatePending
-> PatchInfoAnd rt p wT wY
-> IO (Repository rt p wR wU wY)
tentativelyAddPatch Repository rt p wR wU wR
repository (PrimDarcsOption Compression
compress PrimDarcsOption Compression -> [DarcsFlag] -> Compression
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts) (PrimDarcsOption Verbosity
verbosity PrimDarcsOption Verbosity -> [DarcsFlag] -> Verbosity
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts) UpdatePending
YesUpdatePending
(PatchInfoAnd rt p wR wR -> IO (Repository rt p wR wU wR))
-> PatchInfoAnd rt p wR wR -> IO (Repository rt p wR wU wR)
forall a b. (a -> b) -> a -> b
$ Named p wR wR -> PatchInfoAnd rt p wR wR
forall (p :: * -> * -> *) wX wY (rt :: RepoType).
(Ident p, PatchId p ~ PatchInfo) =>
p wX wY -> PatchInfoAndG rt p wX wY
n2pia (Named p wR wR -> PatchInfoAnd rt p wR wR)
-> Named p wR wR -> PatchInfoAnd rt p wR wR
forall a b. (a -> b) -> a -> b
$ Named p wR wR -> [PatchInfo] -> Named p wR wR
forall (p :: * -> * -> *) wX wY.
Named p wX wY -> [PatchInfo] -> Named p wX wY
adddeps Named p wR wR
forall wY. Named p wY wY
mypatch [PatchInfo]
deps
Repository rt p wR wU wR
_ <- Repository rt p wR wU wR
-> UpdatePending -> Compression -> IO (Repository rt p wR wU wR)
forall (rt :: RepoType) (p :: * -> * -> *) wR wU wT.
(IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) =>
Repository rt p wR wU wT
-> UpdatePending -> Compression -> IO (Repository rt p wT wU wT)
finalizeRepositoryChanges Repository rt p wR wU wR
repository UpdatePending
YesUpdatePending (PrimDarcsOption Compression
compress PrimDarcsOption Compression -> [DarcsFlag] -> Compression
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts)
[DarcsFlag] -> String -> IO ()
putFinished [DarcsFlag]
opts (String -> IO ()) -> String -> IO ()
forall a b. (a -> b) -> a -> b
$ String
"tagging '"String -> String -> String
forall a. [a] -> [a] -> [a]
++String
nameString -> String -> String
forall a. [a] -> [a] -> [a]
++String
"'"
where get_name_log ::(PrimPatch prim) => FL prim wA wA -> [String] -> [String] -> IO (String, [String])
get_name_log :: FL prim wA wA -> [String] -> [String] -> IO (String, [String])
get_name_log FL prim wA wA
nilFL [String]
a [String]
tags
= do (String
name, [String]
comment, Maybe String
_) <- Maybe String
-> Bool
-> Logfile
-> Maybe AskLongComment
-> Maybe (String, [String])
-> FL prim wA wA
-> IO (String, [String], Maybe String)
forall (prim :: * -> * -> *) wX wY.
PrimPatch prim =>
Maybe String
-> Bool
-> Logfile
-> Maybe AskLongComment
-> Maybe (String, [String])
-> FL prim wX wY
-> IO (String, [String], Maybe String)
getLog
(case PrimDarcsOption (Maybe String) -> [DarcsFlag] -> Maybe String
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
parseFlags PrimDarcsOption (Maybe String)
O.patchname [DarcsFlag]
opts of
Maybe String
Nothing -> String -> Maybe String
forall a. a -> Maybe a
Just ([String] -> String
unwords [String]
a)
Just String
s -> String -> Maybe String
forall a. a -> Maybe a
Just String
s)
([DarcsFlag] -> Bool
hasPipe [DarcsFlag]
opts)
((forall a. PrimOptSpec DarcsOptDescr DarcsFlag a Logfile)
-> [DarcsFlag] -> Logfile
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
parseFlags forall a. PrimOptSpec DarcsOptDescr DarcsFlag a Logfile
O.logfile [DarcsFlag]
opts)
(PrimDarcsOption (Maybe AskLongComment)
-> [DarcsFlag] -> Maybe AskLongComment
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
parseFlags PrimDarcsOption (Maybe AskLongComment)
O.askLongComment [DarcsFlag]
opts)
Maybe (String, [String])
forall a. Maybe a
Nothing FL prim wA wA
nilFL
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (String -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
name Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
2) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ Handle -> String -> IO ()
hPutStr Handle
stderr (String -> IO ()) -> String -> IO ()
forall a b. (a -> b) -> a -> b
$
String
"Do you really want to tag '"
String -> String -> String
forall a. [a] -> [a] -> [a]
++String
nameString -> String -> String
forall a. [a] -> [a] -> [a]
++String
"'? If not type: darcs obliterate --last=1\n"
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (String
name String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [String]
tags) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
String -> IO ()
putStrLn (String -> IO ()) -> String -> IO ()
forall a b. (a -> b) -> a -> b
$ String
"WARNING: The tag " String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
"\"" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
name String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\"" String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
" already exists."
(String, [String]) -> IO (String, [String])
forall (m :: * -> *) a. Monad m => a -> m a
return (String
"TAG " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
name, [String]
comment)
askAboutTagDepends
:: forall rt p wX wY . (RepoPatch p, ApplyState p ~ Tree)
=> [DarcsFlag]
-> FL (PatchInfoAnd rt p) wX wY
-> IO (Sealed (FL (PatchInfoAnd rt p) wX))
askAboutTagDepends :: [DarcsFlag]
-> FL (PatchInfoAnd rt p) wX wY
-> IO (Sealed (FL (PatchInfoAnd rt p) wX))
askAboutTagDepends [DarcsFlag]
flags FL (PatchInfoAnd rt p) wX wY
ps = do
let opts :: PatchSelectionOptions
opts = PatchSelectionOptions :: Verbosity
-> [MatchFlag]
-> Bool
-> SelectDeps
-> WithSummary
-> WithContext
-> PatchSelectionOptions
S.PatchSelectionOptions
{ verbosity :: Verbosity
S.verbosity = PrimDarcsOption Verbosity
verbosity PrimDarcsOption Verbosity -> [DarcsFlag] -> Verbosity
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
flags
, matchFlags :: [MatchFlag]
S.matchFlags = []
, interactive :: Bool
S.interactive = Bool
True
, selectDeps :: SelectDeps
S.selectDeps = SelectDeps
O.PromptDeps
, withSummary :: WithSummary
S.withSummary = WithSummary
O.NoSummary
, withContext :: WithContext
S.withContext = WithContext
O.NoContext
}
(FL (PatchInfoAnd rt p) wX wZ
deps:>FL (PatchInfoAnd rt p) wZ wY
_) <- FL (PatchInfoAnd rt p) wX wY
-> SelectionConfig (PatchInfoAnd rt p)
-> IO
((:>) (FL (PatchInfoAnd rt p)) (FL (PatchInfoAnd rt p)) wX wY)
forall (p :: * -> * -> *) 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)
runSelection FL (PatchInfoAnd rt p) wX wY
ps (SelectionConfig (PatchInfoAnd rt p)
-> IO
((:>) (FL (PatchInfoAnd rt p)) (FL (PatchInfoAnd rt p)) wX wY))
-> SelectionConfig (PatchInfoAnd rt p)
-> IO
((:>) (FL (PatchInfoAnd rt p)) (FL (PatchInfoAnd rt p)) wX wY)
forall a b. (a -> b) -> a -> b
$
((WhichChanges
-> String
-> PatchSelectionOptions
-> Maybe (Splitter (PatchInfoAnd rt p))
-> Maybe [AnchoredPath]
-> SelectionConfig (PatchInfoAnd rt p)
forall (p :: * -> * -> *).
Matchable p =>
WhichChanges
-> String
-> PatchSelectionOptions
-> Maybe (Splitter p)
-> Maybe [AnchoredPath]
-> SelectionConfig p
selectionConfig WhichChanges
FirstReversed String
"depend on" PatchSelectionOptions
opts Maybe (Splitter (PatchInfoAnd rt p))
forall a. Maybe a
Nothing Maybe [AnchoredPath]
forall a. Maybe a
Nothing)
{ allowSkipAll :: Bool
allowSkipAll = Bool
False })
Sealed (FL (PatchInfoAnd rt p) wX)
-> IO (Sealed (FL (PatchInfoAnd rt p) wX))
forall (m :: * -> *) a. Monad m => a -> m a
return (Sealed (FL (PatchInfoAnd rt p) wX)
-> IO (Sealed (FL (PatchInfoAnd rt p) wX)))
-> Sealed (FL (PatchInfoAnd rt p) wX)
-> IO (Sealed (FL (PatchInfoAnd rt p) wX))
forall a b. (a -> b) -> a -> b
$ FL (PatchInfoAnd rt p) wX wZ -> Sealed (FL (PatchInfoAnd rt p) wX)
forall (a :: * -> *) wX. a wX -> Sealed a
Sealed FL (PatchInfoAnd rt p) wX wZ
deps
hasPipe :: [DarcsFlag] -> Bool
hasPipe :: [DarcsFlag] -> Bool
hasPipe = PrimDarcsOption Bool -> [DarcsFlag] -> Bool
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
parseFlags PrimDarcsOption Bool
O.pipe