% Copyright (C) 2007 Eric Kow % % 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. \darcsCommand{show contents} \begin{code}
module Darcs.Commands.ShowContents ( showContents ) where

import Control.Monad ( filterM, forM_, unless )
import System.IO ( stdout )
import Data.Maybe( fromJust )

import qualified Data.ByteString as B

import Darcs.Commands ( DarcsCommand(..), nodefaults )
import Darcs.Arguments ( DarcsFlag, matchOne,
workingRepoDir, fixSubPaths )
import Darcs.RepoPath ( sp2fn )
import Darcs.IO ( mReadFilePS, mDoesFileExist )
import Darcs.Patch.Match( Matcher )
import Darcs.Match ( haveNonrangeMatch, applyInvToMatcher, nonrangeMatcher
, InclusiveOrExclusive(..), matchExists )
import Darcs.Repository ( withRepository, ($-), findRepository, readRepo, readRecorded ) import Darcs.Patch( RepoPatch ) import Storage.Hashed.Monad( virtualTreeIO ) showContentsDescription :: String showContentsDescription = "Outputs a specific version of a file." showContentsHelp :: String showContentsHelp = "Show contents can be used to display an earlier version of some file(s).\n"++ "If you give show contents no version arguments, it displays the recorded\n"++ "version of the file(s).\n" showContents :: DarcsCommand showContents = DarcsCommand {commandProgramName = "darcs", commandName = "contents", commandHelp = showContentsHelp, commandDescription = showContentsDescription, commandExtraArgs = -1, commandExtraArgHelp = ["[FILE]..."], commandCommand = showContentsCmd, commandPrereq = findRepository, commandGetArgPossibilities = return [], commandArgdefaults = nodefaults, commandAdvancedOptions = [], commandBasicOptions = [matchOne, workingRepoDir]} getMatcher :: (RepoPatch p) => [DarcsFlag] -> Matcher p getMatcher = fromJust . nonrangeMatcher showContentsCmd :: [DarcsFlag] -> [String] -> IO () showContentsCmd _ [] = fail "show contents needs at least one argument." showContentsCmd opts args = withRepository opts$- \repository -> do
path_list <- map sp2fn fmap fixSubPaths opts args
unless (matchExists matcher patchset) $fail$ "Couldn't match pattern " ++ show matcher
snd fmap virtualTreeIO (unapply_to_match patchset) pristine
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.994099497795105, "perplexity": 19334.47966007234}, "config": {"markdown_headings": true, "markdown_code": false, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2015-27/segments/1435376093097.69/warc/CC-MAIN-20150627033453-00304-ip-10-179-60-89.ec2.internal.warc.gz"}