Hi,
Petr Ročkai <bugs@darcs.net> writes:
> addfile ./contrib/serve.pl
> hunk ./contrib/serve.pl 1
> +#!/usr/bin/perl
> +
> +use warnings;
> +use strict;
> +use CGI::Carp qw(fatalsToBrowser);
> +use File::Spec::Functions qw(rel2abs);
> +use File::Basename;
> +
> +$| = 1;
> +chdir(dirname(rel2abs($0)) . "/../..") or die $!;
> +open(DARCS, "| dist/build/darcs/darcs serve") or die $!;
> +while (<>) {
> + print DARCS $_;
> +}
Ok, this is a wrapper around darcs serve. I understand this part.
> addfile ./src/Darcs/Commands/Serve.hs
> hunk ./src/Darcs/Commands/Serve.hs 1
> +module Darcs.Commands.Serve ( serve ) where
> +
> +import Control.Applicative ( (<$>) )
> +import Control.Exception ( IOException, try )
> +import Darcs.Arguments ( DarcsFlag, workingRepoDir )
> +import Darcs.Commands ( DarcsCommand(..), nodefaults )
> +import Darcs.Global ( darcsdir )
> +import Darcs.RepoIO ( withRepoIO )
> +import Darcs.Repository ( amInRepository )
> +import Progress ( setProgressMode )
> +
> +serve :: DarcsCommand
> +serve = DarcsCommand
> + { commandName = "serve"
> + , commandHelp = ""
> + , commandDescription = ""
> + , commandExtraArgs = 0
> + , commandExtraArgHelp = []
> + , commandGetArgPossibilities = return []
> + , commandCommand = serveCmd
> + , commandPrereq = amInRepository
> + , commandArgdefaults = nodefaults
> + , commandAdvancedOptions = []
> + , commandBasicOptions = [workingRepoDir]
> + }
> +
> +serveCmd :: [DarcsFlag] -> [String] -> IO ()
> +serveCmd opts _ = do
> + setProgressMode False
> + withRepoIO opts "." $ \rio -> do
> + c <- try getLine
> + case c of
> + Left (e :: IOException) -> print404 $ show e
> + Right x -> print404 $ "darcs serve error: Unknown command " ++ x
> +
> +print404 :: String -> IO ()
> +print404 x = putStr $ unlines
> + [ "Status: 404 Not Found"
> + , "Content-Type: text/plain"
> + , ""
> + , x
> + ]
What I don't understand is what is this "darcs serve" supposed to be
doing. Whatever that is and however I look at this code, all I can see
is "error out with 404 no matter what".
How is this ever going to work?
Yours,
Petr.
|