darcs

Patch 350 Add serve.pl to contrib (and 1 more)

Title Add serve.pl to contrib (and 1 more)
Superseder Nosy List exlevan
Related Issues
Status rejected Assigned To
Milestone

Created on 2010-08-16.19:08:30 by exlevan, last changed 2011-05-10.19:35:39 by darcswatch. Tracked on DarcsWatch.

Files
File name Status Uploaded Type Edit Remove
add-serve_pl-to-contrib.dpatch exlevan, 2010-08-16.19:08:30 text/x-darcs-patch
add-serve_pl-to-contrib.dpatch mornfall, 2010-08-17.09:18:15 text/x-darcs-patch
unnamed exlevan, 2010-08-16.19:08:30
unnamed mornfall, 2010-08-17.09:18:15
See mailing list archives for discussion on individual patches.
Messages
msg12210 (view) Author: exlevan Date: 2010-08-16.19:08:30
The same patches, now with description.

State of smart server work at the pencils down time.  Implemented repo
identification, File and HTTP dumb protocols and prototype of SmartHTTP one.
Implemented getting Repository datatype out of RepoIO for compability with
older code.  Pull command partly rewritten to use RepoIO.  Currently making a
pull via RepoIO may corrupt a repository.

To serve a repository:
$ mkdir _darcs/cgi
$ cp contrib/serve.pl _darcs/cgi

Make sure _darcs/cgi/serve.pl is executable as cgi script and has access to
the repository.

2 patches for repository http://darcs.net:

Mon Aug 16 21:35:34 EEST 2010  Alexey Levan <exlevan@gmail.com>
  * Add serve.pl to contrib

Mon Aug 16 21:59:30 EEST 2010  Alexey Levan <exlevan@gmail.com>
  * Smart server
Attachments
msg12213 (view) Author: mornfall Date: 2010-08-17.09:18:15
I have amended out the obvious junk, so this is the patch that is going to be
reviewed.

Yours,
   Petr.

2 patches for repository http://darcs.net:

Mon Aug 16 20:35:34 CEST 2010  Alexey Levan <exlevan@gmail.com>
  * Add serve.pl to contrib

Mon Aug 16 20:59:30 CEST 2010  Alexey Levan <exlevan@gmail.com>
  * Smart server
Attachments
msg12214 (view) Author: mornfall Date: 2010-08-17.09:25:46
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.
msg12215 (view) Author: exlevan Date: 2010-08-17.10:45:49
(just realized that mail wasn't sent to BTS, sorry for duplicate)

>> +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?

It's stub for smart server, and is meant to be extended to support
vsrious commands. Currently the only command send to server is "ping",
and I should have added a line to support it.  However, that wouldn't
make a difference as for everyting else smart server should fall back
to old repository interface.
msg12571 (view) Author: kowey Date: 2010-09-15.21:05:08
I believe this will have to be future work as a new submission.
History
Date User Action Args
2010-08-16 19:08:30exlevancreate
2010-08-16 19:14:00darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-9ffd729ead084ab1841a81a0933817ec6a8329da
2010-08-17 09:18:16mornfallsetfiles: + add-serve_pl-to-contrib.dpatch, unnamed
messages: + msg12213
2010-08-17 09:18:55darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-9ffd729ead084ab1841a81a0933817ec6a8329da -> http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-0b569e55e545960d46d16718131f9051fb37c329
2010-08-17 09:25:47mornfallsetstatus: needs-review -> in-discussion
messages: + msg12214
2010-08-17 10:45:49exlevansetmessages: + msg12215
2010-09-15 21:05:08koweysetstatus: in-discussion -> rejected
messages: + msg12571
2011-05-10 19:06:02darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-0b569e55e545960d46d16718131f9051fb37c329 -> http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-0b569e55e545960d46d16718131f9051fb37c329
2011-05-10 19:35:39darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-0b569e55e545960d46d16718131f9051fb37c329 -> http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-9ffd729ead084ab1841a81a0933817ec6a8329da