{-# LANGUAGE OverloadedStrings #-}
module Darcs.UI.Commands.Push ( push ) where
import Darcs.Prelude
import System.Exit ( exitWith, ExitCode( ExitSuccess, ExitFailure ), exitSuccess )
import Control.Monad ( when, unless )
import Data.Maybe ( isJust )
import Darcs.UI.Commands
( DarcsCommand(..), withStdOpts
, putVerbose
, putInfo
, putFinished
, abortRun
, setEnvDarcsPatches
, defaultRepo
, amInHashedRepository
)
import Darcs.UI.Commands.Clone ( otherHelpInheritDefault )
import Darcs.UI.Commands.Util ( printDryRunMessageAndExit, checkUnrelatedRepos )
import Darcs.UI.Completion ( prefArgs )
import Darcs.UI.Flags
( DarcsFlag
, isInteractive, verbosity, withContext
, xmlOutput, selectDeps, applyAs, remoteDarcs
, changesReverse, dryRun, useCache, remoteRepos, setDefault, fixUrl )
import Darcs.UI.Options
( (^), odesc, ocheck
, defaultFlags, parseFlags, (?) )
import qualified Darcs.UI.Options.All as O
import Darcs.Repository.Flags ( DryRun (..) )
import qualified Darcs.Repository.Flags as R ( remoteDarcs )
import Darcs.Patch.PatchInfoAnd ( PatchInfoAnd, hopefully )
import Darcs.Repository
( RepoJob(..)
, Repository
, identifyRepositoryFor
, ReadingOrWriting(..)
, readRepo
, withRepository
)
import Darcs.Patch ( IsRepoType, RepoPatch, description )
import Darcs.Patch.Apply( ApplyState )
import Darcs.Patch.Witnesses.Ordered
( (:>)(..), RL, FL, nullRL,
nullFL, reverseFL, mapFL_FL, mapRL )
import Darcs.Repository.Prefs ( addRepoSource, getPreflist )
import Darcs.UI.External ( signString, darcsProgram
, pipeDoc, pipeDocSSH )
import Darcs.Util.Exception ( die )
import Darcs.Util.URL ( isHttpUrl, isValidLocalPath
, isSshUrl, splitSshUrl, SshFilePath(..) )
import Darcs.Util.Path ( AbsolutePath )
import Darcs.UI.SelectChanges
( WhichChanges(..)
, selectionConfig
, runSelection
)
import qualified Darcs.UI.SelectChanges as S ( PatchSelectionOptions (..) )
import Darcs.Patch.Depends ( findCommonWithThem, countUsThem )
import Darcs.Patch.Bundle ( makeBundle )
import Darcs.Patch.Show( ShowPatch )
import Darcs.Patch.Set ( PatchSet, Origin )
import Darcs.Util.Printer.Color ( ePutDocLn )
import Darcs.Util.Printer
( Doc
, ($$)
, ($+$)
, (<+>)
, empty
, formatWords
, quoted
, text
, vcat
)
import Darcs.UI.Email ( makeEmail )
import Darcs.Util.English (englishNum, Noun(..))
import Darcs.Util.Workaround ( getCurrentDirectory )
import Darcs.Util.Tree( Tree )
pushDescription :: String
pushDescription :: String
pushDescription =
String
"Copy and apply patches from this repository to another one."
pushHelp :: Doc
pushHelp :: Doc
pushHelp =
[String] -> Doc
formatWords
[ String
"Push is the opposite of pull. Push allows you to copy patches from the"
, String
"current repository into another repository."
]
Doc -> Doc -> Doc
$+$ [String] -> Doc
formatWords
[ String
"If you give the `--apply-as` flag, darcs will use `sudo` to apply the"
, String
"patches as a different user. This can be useful if you want to set up a"
, String
"system where several users can modify the same repository, but you don't"
, String
"want to allow them full write access. This isn't secure against skilled"
, String
"malicious attackers, but at least can protect your repository from clumsy,"
, String
"inept or lazy users."
]
Doc -> Doc -> Doc
$+$ [String] -> Doc
formatWords
[ String
"`darcs push` will compress the patch data before sending it to a remote"
, String
"location via ssh. This works as long as the remote darcs is not older"
, String
"than version 2.5. If you get errors that indicate a corrupt patch bundle,"
, String
"you should try again with the `--no-compress` option."
]
Doc -> Doc -> Doc
$+$
Doc
otherHelpInheritDefault
push :: DarcsCommand
push :: DarcsCommand
push = 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
"push"
, commandHelp :: Doc
commandHelp = Doc
pushHelp
, commandDescription :: String
commandDescription = String
pushDescription
, commandExtraArgs :: Int
commandExtraArgs = -Int
1
, commandExtraArgHelp :: [String]
commandExtraArgHelp = [String
"[REPOSITORY]"]
, commandCommand :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO ()
commandCommand = (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO ()
pushCmd
, commandPrereq :: [DarcsFlag] -> IO (Either String ())
commandPrereq = [DarcsFlag] -> IO (Either String ())
amInHashedRepository
, commandCompleteArgs :: (AbsolutePath, AbsolutePath)
-> [DarcsFlag] -> [String] -> IO [String]
commandCompleteArgs = String
-> (AbsolutePath, AbsolutePath)
-> [DarcsFlag]
-> [String]
-> IO [String]
prefArgs String
"repos"
, commandArgdefaults :: [DarcsFlag] -> AbsolutePath -> [String] -> IO [String]
commandArgdefaults = [DarcsFlag] -> AbsolutePath -> [String] -> IO [String]
defaultRepo
, commandAdvancedOptions :: [DarcsOptDescr DarcsFlag]
commandAdvancedOptions = OptSpec
DarcsOptDescr
DarcsFlag
Any
(Maybe String
-> RemoteRepos -> Bool -> Compression -> NetworkOptions -> Any)
-> [DarcsOptDescr DarcsFlag]
forall (d :: * -> *) f a b. OptSpec d f a b -> [d f]
odesc OptSpec
DarcsOptDescr
DarcsFlag
Any
(Maybe String
-> RemoteRepos -> Bool -> Compression -> NetworkOptions -> Any)
forall a.
OptSpec
DarcsOptDescr
DarcsFlag
a
(Maybe String
-> RemoteRepos -> Bool -> Compression -> NetworkOptions -> a)
pushAdvancedOpts
, commandBasicOptions :: [DarcsOptDescr DarcsFlag]
commandBasicOptions = OptSpec
DarcsOptDescr
DarcsFlag
Any
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> Any)
-> [DarcsOptDescr DarcsFlag]
forall (d :: * -> *) f a b. OptSpec d f a b -> [d f]
odesc OptSpec
DarcsOptDescr
DarcsFlag
Any
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> Any)
forall a.
OptSpec
DarcsOptDescr
DarcsFlag
a
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
pushBasicOpts
, commandDefaults :: [DarcsFlag]
commandDefaults = OptSpec
DarcsOptDescr
DarcsFlag
[DarcsFlag]
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> Maybe StdCmdAction
-> Verbosity
-> Maybe String
-> RemoteRepos
-> Bool
-> Compression
-> NetworkOptions
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> [DarcsFlag])
-> [DarcsFlag]
forall (d :: * -> *) f b. OptSpec d f [f] b -> [f]
defaultFlags OptSpec
DarcsOptDescr
DarcsFlag
[DarcsFlag]
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> Maybe StdCmdAction
-> Verbosity
-> Maybe String
-> RemoteRepos
-> Bool
-> Compression
-> NetworkOptions
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> [DarcsFlag])
forall a.
DarcsOption
a
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> Maybe StdCmdAction
-> Verbosity
-> Maybe String
-> RemoteRepos
-> Bool
-> Compression
-> NetworkOptions
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
pushOpts
, commandCheckOptions :: [DarcsFlag] -> [String]
commandCheckOptions = OptSpec
DarcsOptDescr
DarcsFlag
Any
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> Maybe StdCmdAction
-> Verbosity
-> Maybe String
-> RemoteRepos
-> Bool
-> Compression
-> NetworkOptions
-> 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
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> Maybe StdCmdAction
-> Verbosity
-> Maybe String
-> RemoteRepos
-> Bool
-> Compression
-> NetworkOptions
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> Any)
forall a.
DarcsOption
a
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> Maybe StdCmdAction
-> Verbosity
-> Maybe String
-> RemoteRepos
-> Bool
-> Compression
-> NetworkOptions
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
pushOpts
}
where
pushBasicOpts :: OptSpec
DarcsOptDescr
DarcsFlag
a
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
pushBasicOpts
= PrimOptSpec
DarcsOptDescr
DarcsFlag
(SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
[MatchFlag]
MatchOption
O.matchSeveral
PrimOptSpec
DarcsOptDescr
DarcsFlag
(SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
[MatchFlag]
-> OptSpec
DarcsOptDescr
DarcsFlag
(Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
(SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> 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
DarcsFlag
(Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
(SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
PrimDarcsOption SelectDeps
O.selectDeps
OptSpec
DarcsOptDescr
DarcsFlag
(Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
(Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> 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
DarcsFlag
(Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
(Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
PrimDarcsOption (Maybe Bool)
O.interactive
OptSpec
DarcsOptDescr
DarcsFlag
(Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
(Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> 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
DarcsFlag
(DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
(Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
PrimDarcsOption Sign
O.sign
OptSpec
DarcsOptDescr
DarcsFlag
(DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(WithSummary
-> Maybe String -> Maybe Bool -> InheritDefault -> Bool -> a)
(DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(WithSummary
-> Maybe String -> Maybe Bool -> InheritDefault -> Bool -> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> 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
DarcsFlag
(WithSummary
-> Maybe String -> Maybe Bool -> InheritDefault -> Bool -> a)
(DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
forall a. DarcsOption a (DryRun -> XmlOutput -> a)
O.dryRunXml
OptSpec
DarcsOptDescr
DarcsFlag
(WithSummary
-> Maybe String -> Maybe Bool -> InheritDefault -> Bool -> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Maybe String -> Maybe Bool -> InheritDefault -> Bool -> a)
(WithSummary
-> Maybe String -> Maybe Bool -> InheritDefault -> Bool -> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Maybe String -> Maybe Bool -> InheritDefault -> Bool -> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> 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
DarcsFlag
(Maybe String -> Maybe Bool -> InheritDefault -> Bool -> a)
(WithSummary
-> Maybe String -> Maybe Bool -> InheritDefault -> Bool -> a)
PrimDarcsOption WithSummary
O.withSummary
OptSpec
DarcsOptDescr
DarcsFlag
(Maybe String -> Maybe Bool -> InheritDefault -> Bool -> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Maybe Bool -> InheritDefault -> Bool -> a)
(Maybe String -> Maybe Bool -> InheritDefault -> Bool -> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Maybe Bool -> InheritDefault -> Bool -> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> 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
DarcsFlag
(Maybe Bool -> InheritDefault -> Bool -> a)
(Maybe String -> Maybe Bool -> InheritDefault -> Bool -> a)
PrimDarcsOption (Maybe String)
O.repoDir
OptSpec
DarcsOptDescr
DarcsFlag
(Maybe Bool -> InheritDefault -> Bool -> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(InheritDefault -> Bool -> a)
(Maybe Bool -> InheritDefault -> Bool -> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(InheritDefault -> Bool -> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> 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
DarcsFlag
(InheritDefault -> Bool -> a)
(Maybe Bool -> InheritDefault -> Bool -> a)
PrimDarcsOption (Maybe Bool)
O.setDefault
OptSpec
DarcsOptDescr
DarcsFlag
(InheritDefault -> Bool -> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
-> OptSpec
DarcsOptDescr DarcsFlag (Bool -> a) (InheritDefault -> Bool -> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Bool -> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> 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 DarcsFlag (Bool -> a) (InheritDefault -> Bool -> a)
PrimDarcsOption InheritDefault
O.inheritDefault
OptSpec
DarcsOptDescr
DarcsFlag
(Bool -> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
-> OptSpec DarcsOptDescr DarcsFlag a (Bool -> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
a
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> 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 DarcsFlag a (Bool -> a)
PrimDarcsOption Bool
O.allowUnrelatedRepos
pushAdvancedOpts :: OptSpec
DarcsOptDescr
DarcsFlag
a
(Maybe String
-> RemoteRepos -> Bool -> Compression -> NetworkOptions -> a)
pushAdvancedOpts
= PrimOptSpec
DarcsOptDescr
DarcsFlag
(RemoteRepos -> Bool -> Compression -> NetworkOptions -> a)
(Maybe String)
PrimDarcsOption (Maybe String)
O.applyAs
PrimOptSpec
DarcsOptDescr
DarcsFlag
(RemoteRepos -> Bool -> Compression -> NetworkOptions -> a)
(Maybe String)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Bool -> Compression -> NetworkOptions -> a)
(RemoteRepos -> Bool -> Compression -> NetworkOptions -> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Bool -> Compression -> NetworkOptions -> a)
(Maybe String
-> RemoteRepos -> Bool -> Compression -> NetworkOptions -> 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 -> Compression -> NetworkOptions -> a)
(RemoteRepos -> Bool -> Compression -> NetworkOptions -> a)
PrimDarcsOption RemoteRepos
O.remoteRepos
OptSpec
DarcsOptDescr
DarcsFlag
(Bool -> Compression -> NetworkOptions -> a)
(Maybe String
-> RemoteRepos -> Bool -> Compression -> NetworkOptions -> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Compression -> NetworkOptions -> a)
(Bool -> Compression -> NetworkOptions -> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(Compression -> NetworkOptions -> a)
(Maybe String
-> RemoteRepos -> Bool -> Compression -> NetworkOptions -> 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
(Compression -> NetworkOptions -> a)
(Bool -> Compression -> NetworkOptions -> a)
PrimDarcsOption Bool
O.changesReverse
OptSpec
DarcsOptDescr
DarcsFlag
(Compression -> NetworkOptions -> a)
(Maybe String
-> RemoteRepos -> Bool -> Compression -> NetworkOptions -> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(NetworkOptions -> a)
(Compression -> NetworkOptions -> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
(NetworkOptions -> a)
(Maybe String
-> RemoteRepos -> Bool -> Compression -> NetworkOptions -> 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
(NetworkOptions -> a)
(Compression -> NetworkOptions -> a)
PrimDarcsOption Compression
O.compress
OptSpec
DarcsOptDescr
DarcsFlag
(NetworkOptions -> a)
(Maybe String
-> RemoteRepos -> Bool -> Compression -> NetworkOptions -> a)
-> OptSpec DarcsOptDescr DarcsFlag a (NetworkOptions -> a)
-> OptSpec
DarcsOptDescr
DarcsFlag
a
(Maybe String
-> RemoteRepos -> Bool -> Compression -> NetworkOptions -> 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 (NetworkOptions -> a)
PrimDarcsOption NetworkOptions
O.network
pushOpts :: DarcsOption
a
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> Maybe StdCmdAction
-> Verbosity
-> Maybe String
-> RemoteRepos
-> Bool
-> Compression
-> NetworkOptions
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
pushOpts = OptSpec
DarcsOptDescr
DarcsFlag
(Maybe StdCmdAction
-> Verbosity
-> Maybe String
-> RemoteRepos
-> Bool
-> Compression
-> NetworkOptions
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> Maybe StdCmdAction
-> Verbosity
-> Maybe String
-> RemoteRepos
-> Bool
-> Compression
-> NetworkOptions
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
forall a.
OptSpec
DarcsOptDescr
DarcsFlag
a
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> a)
pushBasicOpts OptSpec
DarcsOptDescr
DarcsFlag
(Maybe StdCmdAction
-> Verbosity
-> Maybe String
-> RemoteRepos
-> Bool
-> Compression
-> NetworkOptions
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> Maybe StdCmdAction
-> Verbosity
-> Maybe String
-> RemoteRepos
-> Bool
-> Compression
-> NetworkOptions
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
-> DarcsOption
(UseCache -> HooksConfig -> Bool -> Bool -> Bool -> a)
(Maybe String
-> RemoteRepos
-> Bool
-> Compression
-> NetworkOptions
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
-> DarcsOption
a
([MatchFlag]
-> SelectDeps
-> Maybe Bool
-> Sign
-> DryRun
-> XmlOutput
-> WithSummary
-> Maybe String
-> Maybe Bool
-> InheritDefault
-> Bool
-> Maybe StdCmdAction
-> Verbosity
-> Maybe String
-> RemoteRepos
-> Bool
-> Compression
-> NetworkOptions
-> 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)
(Maybe String
-> RemoteRepos
-> Bool
-> Compression
-> NetworkOptions
-> UseCache
-> HooksConfig
-> Bool
-> Bool
-> Bool
-> a)
forall a.
OptSpec
DarcsOptDescr
DarcsFlag
a
(Maybe String
-> RemoteRepos -> Bool -> Compression -> NetworkOptions -> a)
pushAdvancedOpts
pushCmd :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO ()
pushCmd :: (AbsolutePath, AbsolutePath) -> [DarcsFlag] -> [String] -> IO ()
pushCmd (AbsolutePath
_, AbsolutePath
o) [DarcsFlag]
opts [String
unfixedrepodir] = do
String
repodir <- AbsolutePath -> String -> IO String
fixUrl AbsolutePath
o String
unfixedrepodir
String
here <- IO String
getCurrentDirectory
[DarcsFlag] -> String -> IO ()
checkOptionsSanity [DarcsFlag]
opts String
repodir
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (String
repodir String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
here) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO ()
forall a. String -> IO a
die String
"Cannot push from repository to itself."
Doc
bundle <-
UseCache -> RepoJob Doc -> IO Doc
forall a. UseCache -> RepoJob a -> IO a
withRepository (PrimDarcsOption UseCache
useCache PrimDarcsOption UseCache -> [DarcsFlag] -> UseCache
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts) (RepoJob Doc -> IO Doc) -> RepoJob Doc -> IO Doc
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 Doc)
-> RepoJob Doc
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 Doc)
-> RepoJob Doc)
-> (forall (rt :: RepoType) (p :: * -> * -> *) wR wU.
(IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) =>
Repository rt p wR wU wR -> IO Doc)
-> RepoJob Doc
forall a b. (a -> b) -> a -> b
$ [DarcsFlag] -> String -> Repository rt p wR wU wR -> IO Doc
forall (rt :: RepoType) (p :: * -> * -> *) wR wU wT.
(IsRepoType rt, RepoPatch p, ApplyState p ~ Tree) =>
[DarcsFlag] -> String -> Repository rt p wR wU wT -> IO Doc
prepareBundle [DarcsFlag]
opts String
repodir
Doc
sbundle <- Sign -> Doc -> IO Doc
signString (PrimDarcsOption Sign -> [DarcsFlag] -> Sign
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
parseFlags PrimDarcsOption Sign
O.sign [DarcsFlag]
opts) Doc
bundle
let body :: Doc
body =
if String -> Bool
isValidLocalPath String
repodir
then Doc
sbundle
else String
-> [(String, String)]
-> Maybe Doc
-> Maybe String
-> Doc
-> Maybe String
-> Doc
makeEmail String
repodir [] Maybe Doc
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing Doc
sbundle Maybe String
forall a. Maybe a
Nothing
ExitCode
rval <- [DarcsFlag] -> String -> Doc -> IO ExitCode
remoteApply [DarcsFlag]
opts String
repodir Doc
body
case ExitCode
rval of
ExitFailure Int
ec -> do
Doc -> IO ()
ePutDocLn (String -> Doc
text String
"Apply failed!")
ExitCode -> IO ()
forall a. ExitCode -> IO a
exitWith (Int -> ExitCode
ExitFailure Int
ec)
ExitCode
ExitSuccess -> [DarcsFlag] -> String -> IO ()
putFinished [DarcsFlag]
opts String
"pushing"
pushCmd (AbsolutePath, AbsolutePath)
_ [DarcsFlag]
_ [] = String -> IO ()
forall a. String -> IO a
die String
"No default repository to push to, please specify one."
pushCmd (AbsolutePath, AbsolutePath)
_ [DarcsFlag]
_ [String]
_ = String -> IO ()
forall a. String -> IO a
die String
"Cannot push to more than one repo."
prepareBundle :: forall rt p wR wU wT. (IsRepoType rt, RepoPatch p, ApplyState p ~ Tree)
=> [DarcsFlag] -> String -> Repository rt p wR wU wT -> IO Doc
prepareBundle :: [DarcsFlag] -> String -> Repository rt p wR wU wT -> IO Doc
prepareBundle [DarcsFlag]
opts String
repodir Repository rt p wR wU wT
repository = do
[String]
old_default <- String -> IO [String]
getPreflist String
"defaultrepo"
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when ([String]
old_default [String] -> [String] -> Bool
forall a. Eq a => a -> a -> Bool
== [String
repodir]) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
let pushing :: String
pushing = if PrimDarcsOption DryRun
dryRun PrimDarcsOption DryRun -> [DarcsFlag] -> DryRun
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts DryRun -> DryRun -> Bool
forall a. Eq a => a -> a -> Bool
== DryRun
YesDryRun then String
"Would push" else String
"Pushing"
in [DarcsFlag] -> Doc -> IO ()
putInfo [DarcsFlag]
opts (Doc -> IO ()) -> Doc -> IO ()
forall a b. (a -> b) -> a -> b
$ String -> Doc
text String
pushing Doc -> Doc -> Doc
<+> Doc
"to" Doc -> Doc -> Doc
<+> String -> Doc
quoted String
repodir Doc -> Doc -> Doc
forall a. Semigroup a => a -> a -> a
<> Doc
"..."
PatchSet rt p Origin Any
them <- ReadingOrWriting
-> Repository rt p wR wU wT
-> UseCache
-> String
-> IO (Repository rt p Any Any Any)
forall (rt :: RepoType) (p :: * -> * -> *) wR wU wT vR vU vT.
ReadingOrWriting
-> Repository rt p wR wU wT
-> UseCache
-> String
-> IO (Repository rt p vR vU vT)
identifyRepositoryFor ReadingOrWriting
Writing Repository rt p wR wU wT
repository (PrimDarcsOption UseCache
useCache PrimDarcsOption UseCache -> [DarcsFlag] -> UseCache
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts) String
repodir IO (Repository rt p Any Any Any)
-> (Repository rt p Any Any Any -> IO (PatchSet rt p Origin Any))
-> IO (PatchSet rt p Origin Any)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Repository rt p Any Any Any -> IO (PatchSet rt p Origin Any)
forall (rt :: RepoType) (p :: * -> * -> *) wR wU wT.
(IsRepoType rt, RepoPatch p) =>
Repository rt p wR wU wT -> IO (PatchSet rt p Origin wR)
readRepo
String
-> DryRun
-> RemoteRepos
-> SetDefault
-> InheritDefault
-> Bool
-> IO ()
addRepoSource String
repodir (PrimDarcsOption DryRun
dryRun PrimDarcsOption DryRun -> [DarcsFlag] -> DryRun
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts) (PrimDarcsOption RemoteRepos
remoteRepos PrimDarcsOption RemoteRepos -> [DarcsFlag] -> RemoteRepos
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts)
(Bool -> [DarcsFlag] -> SetDefault
setDefault Bool
False [DarcsFlag]
opts) (PrimDarcsOption InheritDefault
O.inheritDefault PrimDarcsOption InheritDefault -> [DarcsFlag] -> InheritDefault
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts) (Bool -> [DarcsFlag] -> Bool
isInteractive Bool
True [DarcsFlag]
opts)
PatchSet rt p Origin wR
us <- Repository rt p wR wU wT -> 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 wT
repository
PatchSet rt p Origin wZ
common :> FL (PatchInfoAnd rt p) wZ wR
us' <- (:>) (PatchSet rt p) (FL (PatchInfoAnd rt p)) Origin wR
-> IO ((:>) (PatchSet rt p) (FL (PatchInfoAnd rt p)) Origin wR)
forall (m :: * -> *) a. Monad m => a -> m a
return ((:>) (PatchSet rt p) (FL (PatchInfoAnd rt p)) Origin wR
-> IO ((:>) (PatchSet rt p) (FL (PatchInfoAnd rt p)) Origin wR))
-> (:>) (PatchSet rt p) (FL (PatchInfoAnd rt p)) Origin wR
-> IO ((:>) (PatchSet rt p) (FL (PatchInfoAnd rt p)) Origin wR)
forall a b. (a -> b) -> a -> b
$ PatchSet rt p Origin wR
-> PatchSet rt p Origin Any
-> (:>) (PatchSet rt p) (FL (PatchInfoAnd rt p)) Origin wR
forall (p :: * -> * -> *) (rt :: RepoType) wX wY.
Commute p =>
PatchSet rt p Origin wX
-> PatchSet rt p Origin wY
-> (:>) (PatchSet rt p) (FL (PatchInfoAnd rt p)) Origin wX
findCommonWithThem PatchSet rt p Origin wR
us PatchSet rt p Origin Any
them
[DarcsFlag]
-> PatchSet rt p Origin wR
-> RL (PatchInfoAnd rt p) wZ wR
-> PatchSet rt p Origin Any
-> IO ()
forall (rt :: RepoType) (p :: * -> * -> *) (a :: * -> * -> *) wX wY
wT.
(RepoPatch p, ShowPatch a) =>
[DarcsFlag]
-> PatchSet rt p Origin wX
-> RL a wT wX
-> PatchSet rt p Origin wY
-> IO ()
prePushChatter [DarcsFlag]
opts PatchSet rt p Origin wR
us (FL (PatchInfoAnd rt p) wZ wR -> RL (PatchInfoAnd rt p) wZ wR
forall (a :: * -> * -> *) wX wZ. FL a wX wZ -> RL a wX wZ
reverseFL FL (PatchInfoAnd rt p) wZ wR
us') PatchSet rt p Origin Any
them
let direction :: WhichChanges
direction = if PrimDarcsOption Bool
changesReverse PrimDarcsOption Bool -> [DarcsFlag] -> Bool
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts then WhichChanges
FirstReversed else WhichChanges
First
selection_config :: SelectionConfig (PatchInfoAnd rt p)
selection_config = 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
direction String
"push" ([DarcsFlag] -> PatchSelectionOptions
pushPatchSelOpts [DarcsFlag]
opts) Maybe (Splitter (PatchInfoAnd rt p))
forall a. Maybe a
Nothing Maybe [AnchoredPath]
forall a. Maybe a
Nothing
FL (PatchInfoAnd rt p) wZ wR
-> SelectionConfig (PatchInfoAnd rt p)
-> IO
((:>) (FL (PatchInfoAnd rt p)) (FL (PatchInfoAnd rt p)) wZ wR)
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) wZ wR
us' SelectionConfig (PatchInfoAnd rt p)
selection_config
IO ((:>) (FL (PatchInfoAnd rt p)) (FL (PatchInfoAnd rt p)) wZ wR)
-> ((:>) (FL (PatchInfoAnd rt p)) (FL (PatchInfoAnd rt p)) wZ wR
-> IO Doc)
-> IO Doc
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [DarcsFlag]
-> PatchSet rt p Origin wZ
-> (:>) (FL (PatchInfoAnd rt p)) (FL (PatchInfoAnd rt p)) wZ wR
-> IO Doc
forall (t :: * -> * -> *) (rt :: RepoType) (p :: * -> * -> *) wZ wW
wA.
(RepoPatch p, ApplyState p ~ Tree) =>
[DarcsFlag]
-> PatchSet rt p wA wZ
-> (:>) (FL (PatchInfoAnd rt p)) t wZ wW
-> IO Doc
bundlePatches [DarcsFlag]
opts PatchSet rt p Origin wZ
common
prePushChatter :: forall rt p a wX wY wT . (RepoPatch p, ShowPatch a) =>
[DarcsFlag] -> PatchSet rt p Origin wX ->
RL a wT wX -> PatchSet rt p Origin wY -> IO ()
prePushChatter :: [DarcsFlag]
-> PatchSet rt p Origin wX
-> RL a wT wX
-> PatchSet rt p Origin wY
-> IO ()
prePushChatter [DarcsFlag]
opts PatchSet rt p Origin wX
us RL a wT wX
us' PatchSet rt p Origin wY
them = do
Bool -> PatchSet rt p Origin wX -> PatchSet rt p Origin wY -> IO ()
forall (p :: * -> * -> *) (rt :: RepoType) wX wY.
RepoPatch p =>
Bool -> PatchSet rt p Origin wX -> PatchSet rt p Origin wY -> IO ()
checkUnrelatedRepos (PrimDarcsOption Bool -> [DarcsFlag] -> Bool
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
parseFlags PrimDarcsOption Bool
O.allowUnrelatedRepos [DarcsFlag]
opts) PatchSet rt p Origin wX
us PatchSet rt p Origin wY
them
let num_to_pull :: Int
num_to_pull = (Int, Int) -> Int
forall a b. (a, b) -> b
snd ((Int, Int) -> Int) -> (Int, Int) -> Int
forall a b. (a -> b) -> a -> b
$ PatchSet rt p Origin wX -> PatchSet rt p Origin wY -> (Int, Int)
forall (p :: * -> * -> *) (rt :: RepoType) wX wY.
Commute p =>
PatchSet rt p Origin wX -> PatchSet rt p Origin wY -> (Int, Int)
countUsThem PatchSet rt p Origin wX
us PatchSet rt p Origin wY
them
pull_reminder :: Doc
pull_reminder = if Int
num_to_pull Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0
then String -> Doc
text (String -> Doc) -> String -> Doc
forall a b. (a -> b) -> a -> b
$ String
"The remote repository has " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
num_to_pull
String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Int -> Noun -> String -> String
forall n. Countable n => Int -> n -> String -> String
englishNum Int
num_to_pull (String -> Noun
Noun String
"patch") String
" to pull."
else Doc
empty
[DarcsFlag] -> Doc -> IO ()
putVerbose [DarcsFlag]
opts (Doc -> IO ()) -> Doc -> IO ()
forall a b. (a -> b) -> a -> b
$ String -> Doc
text String
"We have the following patches to push:" Doc -> Doc -> Doc
$$ [Doc] -> Doc
vcat ((forall wW wZ. a wW wZ -> Doc) -> RL a wT wX -> [Doc]
forall (a :: * -> * -> *) b wX wY.
(forall wW wZ. a wW wZ -> b) -> RL a wX wY -> [b]
mapRL forall wW wZ. a wW wZ -> Doc
forall (p :: * -> * -> *) wX wY. ShowPatch p => p wX wY -> Doc
description RL a wT wX
us')
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (RL a wT wX -> Bool
forall (a :: * -> * -> *) wX wZ. RL a wX wZ -> Bool
nullRL RL a wT wX
us') (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ [DarcsFlag] -> Doc -> IO ()
putInfo [DarcsFlag]
opts Doc
pull_reminder
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (RL a wT wX -> Bool
forall (a :: * -> * -> *) wX wZ. RL a wX wZ -> Bool
nullRL RL a wT wX
us') (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ do [DarcsFlag] -> Doc -> IO ()
putInfo [DarcsFlag]
opts (Doc -> IO ()) -> Doc -> IO ()
forall a b. (a -> b) -> a -> b
$ String -> Doc
text String
"No recorded local patches to push!"
IO ()
forall a. IO a
exitSuccess
bundlePatches :: forall t rt p wZ wW wA. (RepoPatch p, ApplyState p ~ Tree)
=> [DarcsFlag] -> PatchSet rt p wA wZ
-> (FL (PatchInfoAnd rt p) :> t) wZ wW
-> IO Doc
bundlePatches :: [DarcsFlag]
-> PatchSet rt p wA wZ
-> (:>) (FL (PatchInfoAnd rt p)) t wZ wW
-> IO Doc
bundlePatches [DarcsFlag]
opts PatchSet rt p wA wZ
common (FL (PatchInfoAnd rt p) wZ wZ
to_be_pushed :> t wZ wW
_) =
do
FL (PatchInfoAnd rt p) wZ wZ -> IO ()
forall (p :: * -> * -> *) (rt :: RepoType) wX wY.
RepoPatch p =>
FL (PatchInfoAnd rt p) wX wY -> IO ()
setEnvDarcsPatches FL (PatchInfoAnd rt p) wZ wZ
to_be_pushed
String
-> Verbosity
-> WithSummary
-> DryRun
-> XmlOutput
-> Bool
-> FL (PatchInfoAnd rt p) wZ wZ
-> IO ()
forall (p :: * -> * -> *) (rt :: RepoType) wX wY.
RepoPatch p =>
String
-> Verbosity
-> WithSummary
-> DryRun
-> XmlOutput
-> Bool
-> FL (PatchInfoAnd rt p) wX wY
-> IO ()
printDryRunMessageAndExit String
"push"
(PrimDarcsOption Verbosity
verbosity PrimDarcsOption Verbosity -> [DarcsFlag] -> Verbosity
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts)
(PrimDarcsOption WithSummary
O.withSummary PrimDarcsOption WithSummary -> [DarcsFlag] -> WithSummary
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts)
(PrimDarcsOption DryRun
dryRun PrimDarcsOption DryRun -> [DarcsFlag] -> DryRun
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts)
(PrimDarcsOption XmlOutput
xmlOutput PrimDarcsOption XmlOutput -> [DarcsFlag] -> XmlOutput
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts)
(Bool -> [DarcsFlag] -> Bool
isInteractive Bool
True [DarcsFlag]
opts)
FL (PatchInfoAnd rt p) wZ wZ
to_be_pushed
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (FL (PatchInfoAnd rt p) wZ wZ -> Bool
forall (a :: * -> * -> *) wX wZ. FL a wX wZ -> Bool
nullFL FL (PatchInfoAnd rt p) wZ wZ
to_be_pushed) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
[DarcsFlag] -> Doc -> IO ()
putInfo [DarcsFlag]
opts (Doc -> IO ()) -> Doc -> IO ()
forall a b. (a -> b) -> a -> b
$
String -> Doc
text String
"You don't want to push any patches, and that's fine with me!"
IO ()
forall a. IO a
exitSuccess
Maybe (Tree IO)
-> PatchSet rt p wA wZ -> FL (Named p) wZ wZ -> IO Doc
forall (p :: * -> * -> *) (rt :: RepoType) wStart wX wY.
(ApplyState p ~ Tree, RepoPatch p) =>
Maybe (Tree IO)
-> PatchSet rt p wStart wX -> FL (Named p) wX wY -> IO Doc
makeBundle Maybe (Tree IO)
forall a. Maybe a
Nothing PatchSet rt p wA wZ
common ((forall wW wY. PatchInfoAnd rt p wW wY -> Named p wW wY)
-> FL (PatchInfoAnd rt p) wZ wZ -> FL (Named p) wZ wZ
forall (a :: * -> * -> *) (b :: * -> * -> *) wX wZ.
(forall wW wY. a wW wY -> b wW wY) -> FL a wX wZ -> FL b wX wZ
mapFL_FL forall wW wY. PatchInfoAnd rt p wW wY -> Named p wW wY
forall (rt :: RepoType) (p :: * -> * -> *) wA wB.
PatchInfoAndG rt p wA wB -> p wA wB
hopefully FL (PatchInfoAnd rt p) wZ wZ
to_be_pushed)
checkOptionsSanity :: [DarcsFlag] -> String -> IO ()
checkOptionsSanity :: [DarcsFlag] -> String -> IO ()
checkOptionsSanity [DarcsFlag]
opts String
repodir =
if String -> Bool
isHttpUrl String
repodir then do
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Maybe String -> Bool
forall a. Maybe a -> Bool
isJust (Maybe String -> Bool) -> Maybe String -> Bool
forall a b. (a -> b) -> a -> b
$ PrimDarcsOption (Maybe String)
applyAs PrimDarcsOption (Maybe String) -> [DarcsFlag] -> Maybe String
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
[DarcsFlag] -> Doc -> IO ()
abortRun [DarcsFlag]
opts (Doc -> IO ()) -> Doc -> IO ()
forall a b. (a -> b) -> a -> b
$ String -> Doc
text String
"Cannot --apply-as when pushing to URLs"
let lprot :: String
lprot = (Char -> Bool) -> String -> String
forall a. (a -> Bool) -> [a] -> [a]
takeWhile (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/= Char
':') String
repodir
msg :: Doc
msg = String -> Doc
text (String
"Pushing to "String -> String -> String
forall a. [a] -> [a] -> [a]
++String
lprotString -> String -> String
forall a. [a] -> [a] -> [a]
++String
" URLs is not supported.")
[DarcsFlag] -> Doc -> IO ()
abortRun [DarcsFlag]
opts Doc
msg
else Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (PrimDarcsOption Sign -> [DarcsFlag] -> Sign
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
parseFlags PrimDarcsOption Sign
O.sign [DarcsFlag]
opts Sign -> Sign -> Bool
forall a. Eq a => a -> a -> Bool
/= Sign
O.NoSign) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
[DarcsFlag] -> Doc -> IO ()
abortRun [DarcsFlag]
opts (Doc -> IO ()) -> Doc -> IO ()
forall a b. (a -> b) -> a -> b
$ String -> Doc
text String
"Signing doesn't make sense for local repositories or when pushing over ssh."
pushPatchSelOpts :: [DarcsFlag] -> S.PatchSelectionOptions
pushPatchSelOpts :: [DarcsFlag] -> PatchSelectionOptions
pushPatchSelOpts [DarcsFlag]
flags = 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 = MatchOption -> [DarcsFlag] -> [MatchFlag]
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
parseFlags MatchOption
O.matchSeveral [DarcsFlag]
flags
, interactive :: Bool
S.interactive = Bool -> [DarcsFlag] -> Bool
isInteractive Bool
True [DarcsFlag]
flags
, selectDeps :: SelectDeps
S.selectDeps = PrimDarcsOption SelectDeps
selectDeps PrimDarcsOption SelectDeps -> [DarcsFlag] -> SelectDeps
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
flags
, withSummary :: WithSummary
S.withSummary = PrimDarcsOption WithSummary
O.withSummary PrimDarcsOption WithSummary -> [DarcsFlag] -> WithSummary
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
flags
, withContext :: WithContext
S.withContext = PrimDarcsOption WithContext
withContext PrimDarcsOption WithContext -> [DarcsFlag] -> WithContext
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
flags
}
remoteApply :: [DarcsFlag] -> String -> Doc -> IO ExitCode
remoteApply :: [DarcsFlag] -> String -> Doc -> IO ExitCode
remoteApply [DarcsFlag]
opts String
repodir Doc
bundle
= case PrimDarcsOption (Maybe String)
applyAs PrimDarcsOption (Maybe String) -> [DarcsFlag] -> Maybe String
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
? [DarcsFlag]
opts of
Maybe String
Nothing
| String -> Bool
isSshUrl String
repodir -> [DarcsFlag] -> SshFilePath -> Doc -> IO ExitCode
applyViaSsh [DarcsFlag]
opts (String -> SshFilePath
splitSshUrl String
repodir) Doc
bundle
| Bool
otherwise -> [DarcsFlag] -> String -> Doc -> IO ExitCode
applyViaLocal [DarcsFlag]
opts String
repodir Doc
bundle
Just String
un
| String -> Bool
isSshUrl String
repodir -> [DarcsFlag] -> SshFilePath -> String -> Doc -> IO ExitCode
applyViaSshAndSudo [DarcsFlag]
opts (String -> SshFilePath
splitSshUrl String
repodir) String
un Doc
bundle
| Bool
otherwise -> String -> String -> Doc -> IO ExitCode
applyViaSudo String
un String
repodir Doc
bundle
applyViaSudo :: String -> String -> Doc -> IO ExitCode
applyViaSudo :: String -> String -> Doc -> IO ExitCode
applyViaSudo String
user String
repo Doc
bundle =
IO String
darcsProgram IO String -> (String -> IO ExitCode) -> IO ExitCode
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \String
darcs ->
String -> [String] -> Doc -> IO ExitCode
pipeDoc String
"sudo" [String
"-u",String
user,String
darcs,String
"apply",String
"--all",String
"--repodir",String
repo] Doc
bundle
applyViaLocal :: [DarcsFlag] -> String -> Doc -> IO ExitCode
applyViaLocal :: [DarcsFlag] -> String -> Doc -> IO ExitCode
applyViaLocal [DarcsFlag]
opts String
repo Doc
bundle =
IO String
darcsProgram IO String -> (String -> IO ExitCode) -> IO ExitCode
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \String
darcs ->
String -> [String] -> Doc -> IO ExitCode
pipeDoc String
darcs (String
"apply"String -> [String] -> [String]
forall a. a -> [a] -> [a]
:String
"--all"String -> [String] -> [String]
forall a. a -> [a] -> [a]
:String
"--repodir"String -> [String] -> [String]
forall a. a -> [a] -> [a]
:String
repoString -> [String] -> [String]
forall a. a -> [a] -> [a]
:[DarcsFlag] -> [String]
applyopts [DarcsFlag]
opts) Doc
bundle
applyViaSsh :: [DarcsFlag] -> SshFilePath -> Doc -> IO ExitCode
applyViaSsh :: [DarcsFlag] -> SshFilePath -> Doc -> IO ExitCode
applyViaSsh [DarcsFlag]
opts SshFilePath
repo =
Compression -> SshFilePath -> [String] -> Doc -> IO ExitCode
pipeDocSSH (PrimDarcsOption Compression -> [DarcsFlag] -> Compression
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
parseFlags PrimDarcsOption Compression
O.compress [DarcsFlag]
opts) SshFilePath
repo
[RemoteDarcs -> String
R.remoteDarcs ([DarcsFlag] -> RemoteDarcs
remoteDarcs [DarcsFlag]
opts) String -> String -> String
forall a. [a] -> [a] -> [a]
++String
" apply --all "String -> String -> String
forall a. [a] -> [a] -> [a]
++[String] -> String
unwords ([DarcsFlag] -> [String]
applyopts [DarcsFlag]
opts)String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
" --repodir '"String -> String -> String
forall a. [a] -> [a] -> [a]
++SshFilePath -> String
sshRepo SshFilePath
repoString -> String -> String
forall a. [a] -> [a] -> [a]
++String
"'"]
applyViaSshAndSudo :: [DarcsFlag] -> SshFilePath -> String -> Doc -> IO ExitCode
applyViaSshAndSudo :: [DarcsFlag] -> SshFilePath -> String -> Doc -> IO ExitCode
applyViaSshAndSudo [DarcsFlag]
opts SshFilePath
repo String
username =
Compression -> SshFilePath -> [String] -> Doc -> IO ExitCode
pipeDocSSH (PrimDarcsOption Compression -> [DarcsFlag] -> Compression
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
parseFlags PrimDarcsOption Compression
O.compress [DarcsFlag]
opts) SshFilePath
repo
[String
"sudo -u "String -> String -> String
forall a. [a] -> [a] -> [a]
++String
usernameString -> String -> String
forall a. [a] -> [a] -> [a]
++String
" "String -> String -> String
forall a. [a] -> [a] -> [a]
++RemoteDarcs -> String
R.remoteDarcs ([DarcsFlag] -> RemoteDarcs
remoteDarcs [DarcsFlag]
opts)String -> String -> String
forall a. [a] -> [a] -> [a]
++
String
" apply --all --repodir '"String -> String -> String
forall a. [a] -> [a] -> [a]
++SshFilePath -> String
sshRepo SshFilePath
repoString -> String -> String
forall a. [a] -> [a] -> [a]
++String
"'"]
applyopts :: [DarcsFlag] -> [String]
applyopts :: [DarcsFlag] -> [String]
applyopts [DarcsFlag]
opts = if PrimDarcsOption Bool -> [DarcsFlag] -> Bool
forall (d :: * -> *) f v.
(forall a. PrimOptSpec d f a v) -> [f] -> v
parseFlags PrimDarcsOption Bool
O.debug [DarcsFlag]
opts then [String
"--debug"] else []