-- 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.moduleDarcs.Flags(DarcsFlag(..),Compression(..),UseIndex(..),ScanKnown(..),RemoteDarcs(..),compression,remoteDarcs,diffingOpts,wantExternalMerge,isInteractive,maxCount,willIgnoreTimes,willRemoveLogFile,isUnified,isNotUnified,doHappyForwarding,includeBoring,doAllowCaseOnly,doAllowWindowsReserved,doReverse,usePacks,showChangesOnlyToFiles,rollbackInWorkingDir,removeFromAmended,defaultFlag)whereimportData.Maybe(fromMaybe)importDarcs.Patch.MatchData(PatchMatch)importDarcs.RepoPath(AbsolutePath,AbsolutePathOrStd)-- | The 'DarcsFlag' type is a list of all flags that can ever be-- passed to darcs, or to one of its commands.dataDarcsFlag=Help|ListOptions|NoTest|Test|OnlyChangesToFiles|ChangesToAllFiles|LeaveTestDir|NoLeaveTestDir|Timings|Debug|DebugVerbose|DebugHTTP|Verbose|NormalVerbosity|Quiet|TargetString|CcString|OutputAbsolutePathOrStd|OutputAutoNameAbsolutePath|SubjectString|InReplyToString|CharsetString|SendmailCmdString|AuthorString|PatchNameString|OnePatchString|SeveralPatchString|AfterPatchString|UpToPatchString|TagNameString|LastNInt|MaxCountInt|PatchIndexRangeIntInt|NumberPatches|OneTagString|AfterTagString|UpToTagString|GenContext|ContextAbsolutePath|Count|LogFileAbsolutePath|RmLogFile|DontRmLogFile|DistNameString|All|Recursive|NoRecursive|Reorder|RestrictPaths|DontRestrictPaths|AskDeps|NoAskDeps|IgnoreTimes|DontIgnoreTimes|LookForAdds|NoLookForAdds|AnyOrder|CreatorHashString|Intersection|Union|Complement|Sign|SignAsString|NoSign|SignSSLString|HappyForwarding|NoHappyForwarding|VerifyAbsolutePath|VerifySSLAbsolutePath|RemoteDarcsOptString|EditDescription|NoEditDescription|ToksString|EditLongComment|NoEditLongComment|PromptLongComment|KeepDate|NoKeepDate|AllowConflicts|MarkConflicts|NoAllowConflicts|SkipConflicts|Boring|SkipBoring|AllowCaseOnly|DontAllowCaseOnly|AllowWindowsReserved|DontAllowWindowsReserved|DontGrabDeps|DontPromptForDependencies|PromptForDependencies|Compress|NoCompress|UnCompress|WorkRepoDirString|WorkRepoUrlString|RemoteRepoString|NewRepoString|ReplyString|ApplyAsString|MachineReadable|HumanReadable|Pipe|Interactive|DiffCmdString|ExternalMergeString|Summary|NoSummary|Unified|NonUnified|Reverse|Forward|Complete|Lazy|FixFilePathAbsolutePathAbsolutePath|DiffFlagsString|XMLOutput|ForceReplace|OnePatternPatchMatch|SeveralPatternPatchMatch|AfterPatternPatchMatch|UpToPatternPatchMatch|NonApply|NonVerify|NonForce|DryRun-- The Bool parameters are a bit of a hack so that we can tell-- whether the user explicitly set the option or not.-- A more general mechanism would be better.-- True = explicitly set by user (on command-line or in prefs/defaults),-- False = defaulted by darcs|SetDefaultBool|NoSetDefaultBool|Disable|SetScriptsExecutable|DontSetScriptsExecutable|Bisect|UseHashedInventory|UseFormat2|UseNoWorkingDir|UseWorkingDir|NoUpdateWorking|SiblingAbsolutePath|Relink|OptimizePristine|OptimizeHTTP|UpgradeFormat|Files|NoFiles|Directories|NoDirectories|Pending|NoPending|PosthookCmdString|NoPosthook|AskPosthook|RunPosthook|PrehookCmdString|NoPrehook|AskPrehook|RunPrehook|UMaskString|StoreInMemory|ApplyOnDisk|NoHTTPPipelining|Packs|NoPacks|NoCache|AllowUnrelatedRepos|Check|Repair|JustThisRepo|NullFlag|RecordRollback|NoRecordRollback|NoAmendUnrecord|AmendUnrecordderiving(Eq,Show)-- ADTs for selecting specific behaviour... FIXME These should be eventually-- moved out from this module, closer to where they are actually useddataCompression=NoCompression|GzipCompressioncompression::[DarcsFlag]->Compressioncompressionf|NoCompress`elem`f=NoCompression|otherwise=GzipCompressionremoteDarcs::[DarcsFlag]->RemoteDarcsremoteDarcsf|(x:_)<-[c|RemoteDarcsOptc<-f]=RemoteDarcsx|otherwise=DefaultRemoteDarcsdataUseIndex=UseIndex|IgnoreIndexdataScanKnown=ScanKnown-- ^Just files already known to darcs|ScanAll-- ^All files, i.e. look for new ones|ScanBoring-- ^All files, even boring onesdiffingOpts::[DarcsFlag]->(UseIndex,ScanKnown)diffingOptsopts=(ifwillIgnoreTimesoptsthenIgnoreIndexelseUseIndex,ifLookForAdds`elem`optsthenifBoring`elem`optsthenScanBoringelseScanAllelseScanKnown)dataRemoteDarcs=RemoteDarcsString|DefaultRemoteDarcs----------------------wantExternalMerge::[DarcsFlag]->MaybeStringwantExternalMerge[]=NothingwantExternalMerge(ExternalMergec:_)=JustcwantExternalMerge(_:fs)=wantExternalMergefsisInteractive::[DarcsFlag]->BoolisInteractive=isInteractive_TruewhereisInteractive_def[]=defisInteractive__(Interactive:_)=TrueisInteractive__(All:_)=FalseisInteractive__(DryRun:fs)=isInteractive_FalsefsisInteractive_def(_:fs)=isInteractive_deffsmaxCount::[DarcsFlag]->MaybeIntmaxCount(MaxCountn:_)=JustnmaxCount(_:xs)=maxCountxsmaxCount[]=Nothing-- | @lastWord [(flag, value)] default opts@ scans @opts@ for a flag-- in the list and returns the value of the first match, or @default@-- if none is found.---- We call this the \"last\" word because we assume that flags are-- *prepended* in the order they arrive, so what is first internally-- is last from the user's point of view.lastWord::[(DarcsFlag,a)]->a->[DarcsFlag]->alastWordknown_flags=foldr.flip$\def->fromMaybedef.fliplookupknown_flagsgetBoolFlag::DarcsFlag->DarcsFlag->[DarcsFlag]->BoolgetBoolFlagtf=lastWord[(t,True),(f,False)]FalsewillIgnoreTimes::[DarcsFlag]->BoolwillIgnoreTimes=getBoolFlagIgnoreTimesDontIgnoreTimeswillRemoveLogFile::[DarcsFlag]->BoolwillRemoveLogFile=getBoolFlagRmLogFileDontRmLogFileisUnified::[DarcsFlag]->BoolisUnified=getBoolFlagUnifiedNonUnifiedisNotUnified::[DarcsFlag]->BoolisNotUnified=getBoolFlagNonUnifiedUnifieddoHappyForwarding::[DarcsFlag]->BooldoHappyForwarding=getBoolFlagHappyForwardingNoHappyForwardingincludeBoring::[DarcsFlag]->BoolincludeBoring=getBoolFlagBoringSkipBoringdoAllowCaseOnly::[DarcsFlag]->BooldoAllowCaseOnly=getBoolFlagAllowCaseOnlyDontAllowCaseOnlydoAllowWindowsReserved::[DarcsFlag]->BooldoAllowWindowsReserved=getBoolFlagAllowWindowsReservedDontAllowWindowsReserveddoReverse::[DarcsFlag]->BooldoReverse=getBoolFlagReverseForwardusePacks::[DarcsFlag]->BoolusePacks=getBoolFlagPacksNoPacksshowChangesOnlyToFiles::[DarcsFlag]->BoolshowChangesOnlyToFiles=getBoolFlagOnlyChangesToFilesChangesToAllFiles-- | Set flags to a default value, but only one has not already been provideddefaultFlag::[DarcsFlag]-- ^ distractors->DarcsFlag-- ^ default->[DarcsFlag]-- ^ flags->[DarcsFlag]-- ^ updated flagsdefaultFlagaltsdefflags=ifany(`elem`flags)altsthenflagselsedef:flagsrollbackInWorkingDir::[DarcsFlag]->BoolrollbackInWorkingDir=getBoolFlagNoRecordRollbackRecordRollbackremoveFromAmended::[DarcsFlag]->BoolremoveFromAmended=getBoolFlagAmendUnrecordNoAmendUnrecord