[darcs-devel] Support for darcshive repositories?

Anthony Towns aj at azure.humbug.org.au
Tue Nov 30 09:11:02 PST 2004


David Roundy wrote:

> Perhaps instead we could have two environment variables,
> $DARCS_DARCSHIVE_RETRIEVE and $DARCS_DARCSHIVE_APPLY?

>>I'm probably being whacky again, but I think it'd be kind of pretty if 
>>when darcs saw a url for foo://host/patch, it'd look up $DARCS_FOO, and 
>>if it was set, do the above. :)

> Whacky isn't always bad! :) I think I like this idea.  The only question is
> the command line interface for DARCS_PROTOCOL scripts.  Darcshive can get
> by with just a "get" command, which retrieves a file and an apply command,
> which accepts a patch bundle.  It this sufficiently general for dealing
> with other protocols?
> 
> I think with my modifications, we could trivially support http via wget
> with something like
> 
> DARCS_HTTP_RETRIEVE='wget [options]'.
 > which would be pretty.

Hrm. DARCS_HTTP_GET='curl -s', 'lynx -source', 'wget -q -O-' could work.

> I'm not sure what should be done with the srcfiles and dstfiles.

Is it possible to do "apply" in a way that doesn't require some sort of 
wrapper script? I can't imagine one offhand. How about for "sftp" 
multiget sorts of things? I can't think of one there either.

You could have "DARCS_FOO_GET" take a url, and expect it to dump the 
file on stdout; and have DARCS_FOO_MGET or DARCS_FOO_APPLY optionally 
available for special darcs-specific wrappers/scripts -- if _MGET isn't 
set it can be faked with multiple _GETs after all, and if _APPLY's not 
set, well you just can't push. Or since the scripts have to be darcs 
specific anyway, you could just have DARCS_HTTP_GET for the easy case 
and DARCS_DARCSHIVE_TRANSCIEVE for the general one. The separate 
variables might be easier to cope with though.



The only generalisation beyond get, mget and apply is possibly something 
that would let you translate "darcs pull remote:repository" to

     darcs changes --context |
         ssh remote darcs send --context - --repo-dir repository -o - |
         darcs apply -

which could be a good optimisation for high latency / reasonable 
bandwidth connections, or for when you've just done a "darcs init" (and 
darcs changes --context is hence very brief)... But that's kinda 
pie-in-the-sky, I'm sure we can worry about that later or never...



So, uh, be gentle: I've attached a go at implementing support for 
DARCS_GET_FOO, which is attached. It seems to work. It doesn't seem to 
inelegant. The "fail" code isn't actually used when it's passed back up 
to its invoker. It's my first haskell -- any mistakes are my fault, 
anything that actually complies correctly let alone works are thanks to 
the guys on FreeNode #haskell. :) I shudder to think how much faster I 
could've implemented that hack in just about any language other than 
Haskell. Well, except anything Lisp based. :)

Cheers,
aj
-------------- next part --------------

New patches:

[first pass at implementing DARCS_GET_foo support
aj at azure.humbug.org.au**20041130165021] {
hunk ./External.hs 18
+import Char ( toUpper )
hunk ./External.hs 75
-copyRemote u v cache = if have_libcurl
+copyRemote u v cache = 
+    do let p = map toUpper $ takeWhile (/= ':') u
+       justget <- liftM Just (getEnv ("DARCS_GET_" ++ p))
+                 `catch` \_ -> return Nothing
+       case justget of
+         Nothing -> copyRemoteNormal u v cache
+         Just get -> 
+           do let cmd = head $ words get
+                  args = tail $ words get
+              r <- exec cmd (args++[u]) "/dev/null" v
+              when (r /= ExitSuccess) $
+                  fail $ "(" ++ get ++ ") failed to fetch: " ++ u
+
+copyRemoteNormal :: String -> FilePath -> Cachable -> IO ()
+copyRemoteNormal u v cache = if have_libcurl
hunk ./External.hs 123
-copyRemotes opts u ns d cache =
+copyRemotes opts u ns d cache = 
+    do let p = map toUpper $ takeWhile (/= ':') u
+       justget <- liftM Just (getEnv ("DARCS_GET_" ++ p))
+                 `catch` \_ -> return Nothing
+       case justget of
+         Nothing -> copyRemotesNormal opts u ns d cache
+         Just _ -> doWithPatches opts (\n -> copyRemote (u++"/"++n) (d++"/"++n) cache) ns
+
+copyRemotesNormal :: [DarcsFlag] -> String -> [String] -> FilePath -> Cachable -> IO()
+copyRemotesNormal opts u ns d cache =
}



Context:

[don't link with patch tests, which aren't needed except for unit.
David Roundy <droundy at abridgegame.org>**20041129122201] 
[Merge changes
Ian Lynagh <igloo at earth.li>**20041128142245] 
[Refactor the equality tests
Ian Lynagh <igloo at earth.li>**20041128141504] 
[Merge equality changes
Ian Lynagh <igloo at earth.li>**20041128140424] 
[Give explicit import list
Ian Lynagh <igloo at earth.li>**20041128023749] 
[null_patch and is_null_patch
Ian Lynagh <igloo at earth.li>**20041128023010] 
[Factor out Patch tests and make equality/comparisons explicit
Ian Lynagh <igloo at earth.li>**20041128015824] 
[really fix annotate bug this time.
David Roundy <droundy at abridgegame.org>**20041128140601] 
[update ChangeLog.
David Roundy <droundy at abridgegame.org>**20041128125604] 
[fix bug in commutation of adjacent hunks which have either no new or no old lines.
David Roundy <droundy at abridgegame.org>**20041128124946] 
[fix bug introduced yesterday in named patch compare.
David Roundy <droundy at abridgegame.org>**20041128124913] 
[Use patch tags for patch selection
Ian Lynagh <igloo at earth.li>**20041127190622] 
[speed up named patch compare.
David Roundy <droundy at abridgegame.org>**20041127145844] 
[Fiddle with unpackPS a bit. Not sure what the best answer is yet.
Ian Lynagh <igloo at earth.li>**20041126163254] 
[Tweak takePS
Ian Lynagh <igloo at earth.li>**20041126135212] 
[unsafeHeadPS and unsafeTailPS
Ian Lynagh <igloo at earth.li>**20041126132813] 
[Optimise printableStringFromPS for Char
Ian Lynagh <igloo at earth.li>**20041126132009] 
[Remove unnecessary whitespace from darcs.cgi.in.
joe at elem.com**20041126185146
 Used emacs' nuke-trailing-whitespace to remove unsightly whitespace
 from the ends of lines.
] 
[append CR to conflict markers when existing contents end with CR
Will <will at glozer.net>**20041126231912] 
[use MAPI to resolve to and from addresses
Will <will at glozer.net>**20041126221236] 
[make curl_global_init test work with msys+mingw
Will <will at glozer.net>**20041126180215] 
[remove hardcoded references to /tmp in documentation
Samuel Tardieu <sam at rfc1149.net>**20041126135426] 
[fix bug in annotate.
David Roundy <droundy at abridgegame.org>**20041125120625] 
[check whether libcurl actually works (since curl-config may be broken).
David Roundy <droundy at abridgegame.org>**20041125120514] 
[display patch counts or names during get
Will <will at glozer.net>**20041124073551] 
[use libcurl if available for copyRemotes.
David Roundy <droundy at abridgegame.org>**20041123120456] 
[abstract user prompts and strip CR on win32
Will <will at glozer.net>**20041123065536] 
[fix problem where the --cc was ignored in apply if the patch succeeded.
David Roundy <droundy at abridgegame.org>**20041121140133] 
[TAG 1.0.1pre1
David Roundy <droundy at abridgegame.org>**20041121134516] 

Patch bundle hash:
2eb515492072c5b3d4e4b936d5be50bb602c619b


More information about the darcs-devel mailing list