-- | This module is used by the push and put commands to apply the a bundle to a-- remote repository. By remote I do not necessarily mean a repository on another-- machine, it is just not the repository we're located in.moduleDarcs.RemoteApply(remoteApply,applyAs)whereimportSystem.Exit(ExitCode)importDarcs.Flags(DarcsFlag(ApplyAs,Debug),remoteDarcs)importDarcs.Utils(breakCommand)importDarcs.URL(isHttpUrl,isSshUrl,splitSshUrl,SshFilePath(..))importDarcs.External(darcsProgram,pipeDoc,pipeDocSSH,maybeURLCmd)importqualifiedDarcs.SshasSsh(remoteDarcs)importPrinter(Doc)remoteApply::[DarcsFlag]->String->Doc->IOExitCoderemoteApplyoptsrepodirbundle=caseapplyAsoptsofNothing->ifisSshUrlrepodirthenapplyViaSshopts(splitSshUrlrepodir)bundleelseifisHttpUrlrepodirthenapplyViaUrloptsrepodirbundleelseapplyViaLocaloptsrepodirbundleJustun->ifisSshUrlrepodirthenapplyViaSshAndSudoopts(splitSshUrlrepodir)unbundleelseapplyViaSudounrepodirbundleapplyAs::[DarcsFlag]->MaybeStringapplyAs(ApplyAsuser:_)=JustuserapplyAs(_:fs)=applyAsfsapplyAs[]=NothingapplyViaSudo::String->String->Doc->IOExitCodeapplyViaSudouserrepobundle=darcsProgram>>=\darcs->pipeDoc"sudo"["-u",user,darcs,"apply","--all","--repodir",repo]bundleapplyViaLocal::[DarcsFlag]->String->Doc->IOExitCodeapplyViaLocaloptsrepobundle=darcsProgram>>=\darcs->pipeDocdarcs("apply":"--all":"--repodir":repo:applyoptsopts)bundleapplyViaUrl::[DarcsFlag]->String->Doc->IOExitCodeapplyViaUrloptsrepobundle=domaybeapply<-maybeURLCmd"APPLY"repocasemaybeapplyofNothing->applyViaLocaloptsrepobundleJustapply->dolet(cmd,args)=breakCommandapplypipeDoccmd(args++[repo])bundleapplyViaSsh::[DarcsFlag]->SshFilePath->Doc->IOExitCodeapplyViaSshoptsrepobundle=pipeDocSSHrepo[Ssh.remoteDarcs(remoteDarcsopts)++" apply --all "++unwords(applyoptsopts)++" --repodir '"++(sshReporepo)++"'"]bundleapplyViaSshAndSudo::[DarcsFlag]->SshFilePath->String->Doc->IOExitCodeapplyViaSshAndSudooptsrepousernamebundle=pipeDocSSHrepo["sudo -u "++username++" "++Ssh.remoteDarcs(remoteDarcsopts)++" apply --all --repodir '"++(sshReporepo)++"'"]bundleapplyopts::[DarcsFlag]->[String]applyoptsopts=ifDebug`elem`optsthen["--debug"]else[]