%Copyright(C)2002-2004DavidRoundy%%Thisprogramisfreesoftware;youcanredistributeitand/ormodify%itunderthetermsoftheGNUGeneralPublicLicenseaspublishedby%theFreeSoftwareFoundation;eitherversion2,or(atyouroption)%anylaterversion.%%Thisprogramisdistributedinthehopethatitwillbeuseful,%butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof%MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe%GNUGeneralPublicLicenseformoredetails.%%YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense%alongwiththisprogram;seethefileCOPYING.Ifnot,writeto%theFreeSoftwareFoundation,Inc.,51FranklinStreet,FifthFloor,%Boston,MA02110-1301,USA.\subsection{darcswhatsnew}\label{whatsnew}\begin{code}{-# OPTIONS_GHC -cpp #-}{-# LANGUAGE CPP #-}#include "gadts.h"moduleDarcs.Commands.WhatsNew(whatsnew)whereimportSystem.Exit(ExitCode(..),exitWith)importSystem.Directory(doesFileExist,doesDirectoryExist)importData.List(sort)importControl.Monad(when)importDarcs.Commands(DarcsCommand(..),nodefaults)importDarcs.Arguments(DarcsFlag(..),working_repo_dir,lookforadds,ignoretimes,noskip_boring,unified,summary,areFileArgs,fixSubPaths,list_registered_files,)importDarcs.Patch.FileName(encode_white)importDarcs.RepoPath(SubPath,toFilePath,sp2fn)importDarcs.Repository(Repository,withRepository,($-),slurp_recorded,get_unrecorded_no_look_for_adds,get_unrecorded_in_files,amInRepository)importDarcs.Repository.Internal(slurp_recorded_and_unrecorded)importDarcs.Repository.Prefs(filetype_function)importDarcs.Diff(unsafeDiff)importDarcs.Patch(RepoPatch,Prim,summarize,apply_to_slurpy,is_hunk)importDarcs.Patch.Permutations(partitionRL)importDarcs.Patch.Real(RealPatch,prim2real)importDarcs.PrintPatch(printPatch,contextualPrintPatch)importDarcs.Ordered(FL(..),mapFL_FL,reverseRL,reverseFL,(:>)(..),nullFL)importDarcs.SlurpDirectory(Slurpy,slurp_has)importPrinter(putDocLn,renderString,vcat,text)#include "impossible.h"\end{code}\options{whatsnew}\haskell{whatsnew_description}\begin{code}whatsnew_description::Stringwhatsnew_description="List unrecorded changes in the working tree."whatsnew_help::Stringwhatsnew_help="The `darcs whatsnew' command lists unrecorded changes to the working\n"++"tree. If you specify a set of files and directories, only unrecorded\n"++"changes to those files and directories are listed.\n"++"\n"++"With the --summary option, the changes are condensed to one line per\n"++"file, with mnemonics to indicate the nature and extent of the change.\n"++"The --look-for-adds option causes candidates for `darcs add' to be\n"++"included in the summary output.\n"++"\n"++"By default, `darcs whatsnew' uses Darcs' internal format for changes.\n"++"To see some context (unchanged lines) around each change, use the\n"++"--unified option. To view changes in conventional `diff' format, use\n"++"the `darcs diff' comand; but note that `darcs whatsnew' is faster.\n"++"\n"++"This command exits unsuccessfully (returns a non-zero exit status) if\n"++"there are no unrecorded changes.\n"whatsnew::DarcsCommandwhatsnew=DarcsCommand{command_name="whatsnew",command_help=whatsnew_help,command_description=whatsnew_description,command_extra_args=-1,command_extra_arg_help=["[FILE or DIRECTORY]..."],command_command=whatsnew_cmd,command_prereq=amInRepository,command_get_arg_possibilities=list_registered_files,command_argdefaults=nodefaults,command_advanced_options=[ignoretimes,noskip_boring],command_basic_options=[summary,unified,lookforadds,working_repo_dir]}whatsnew_cmd::[DarcsFlag]->[String]->IO()whatsnew_cmdopts'args|LookForAdds`elem`opts'&&NoSummary`notElem`opts'=-- add Summary to the opts since 'darcs whatsnew --look-for-adds'-- implies summarywithRepository(Summary:opts')$-\repository->dofiles<-fixSubPathsopts'argswhen(areFileArgsfiles)(doslurps<-slurp_recorded_and_unrecordedrepositorywarn_if_bogusslurpsfilesputStrLn$"What's new in "++unwords(mapshowfiles)++":\n")all_changes<-get_unrecorded_in_filesrepository(mapsp2fnfiles)chold<-get_unrecorded_no_look_for_addsrepository(mapsp2fnfiles)s<-slurp_recordedrepositoryftf<-filetype_functioncho_adds:>_<-return$partitionRLis_hunk$reverseFLcholdcha:>_<-return$partitionRLis_hunk$reverseFLall_changesletchn=unsafeDiff[LookForAdds,Summary]ftf(fromJust$apply_to_slurpy(reverseRLcho_adds)s)(fromJust$apply_to_slurpy(reverseRLcha)s)exitOnNoChanges(chn,chold)putDocLn$summarizecholdprintSummarychnwherelower_asx=vcat$map(text.l_as)$linesxl_as('A':x)='a':xl_asx=xexitOnNoChanges::(FLPrimC(xy),FLpC(uv))->IO()exitOnNoChanges(NilFL,NilFL)=doputStrLn"No changes!"exitWith$ExitFailure1exitOnNoChanges_=return()printSummary::FLPrimC(xy)->IO()printSummaryNilFL=return()printSummarynew=putDocLn$lower_as$renderString$summarizenewwhatsnew_cmdoptsargs|otherwise=withRepositoryopts$-\repository->dofiles<-sort`fmap`fixSubPathsoptsargswhen(areFileArgsfiles)(doslurps<-slurp_recorded_and_unrecordedrepositorywarn_if_bogusslurpsfilesputStrLn$"What's new in "++unwords(mapshowfiles)++":\n")changes<-get_unrecorded_in_filesrepository(mapsp2fnfiles)when(nullFLchanges)$putStrLn"No changes!">>(exitWith$ExitFailure1)printSummaryrepository$mapFL_FLprim2realchangeswhereprintSummary::RepoPatchp=>RepositorypC(rut)->FLRealPatchC(ry)->IO()printSummary_NilFL=doputStrLn"No changes!"exitWith$ExitFailure1printSummaryrch=ifSummary`elem`optsthenputDocLn$summarizechelseifUnified`elem`optsthendos<-slurp_recordedrcontextualPrintPatchschelseprintPatchchwarn_if_bogus::(Slurpy,Slurpy)->[SubPath]->IO()warn_if_bogus_[]=return()warn_if_bogus(rec,pend)(f:fs)=doexist1<-doesFileExistfileexist2<-doesDirectoryExistfileletexist=exist1||exist2ifexistthenwhen(not(slurp_hasfprec||slurp_hasfppend))$putStrLn$"WARNING: File '"++file++"' not in repository!"elseputStrLn$"WARNING: File '"++file++"' does not exist!"warn_if_bogus(rec,pend)fswherefp=toFilePathffile=encode_whitefp\end{code}