[darcs-devel] darcs-3 compatibility [was: Again: conversion to darcs-3]

Ian Lynagh igloo at earth.li
Sat Feb 20 22:24:02 UTC 2021


On Sat, Feb 20, 2021 at 08:40:30PM +0100, Ben Franksen wrote:
> Am 20.02.21 um 13:39 schrieb Ian Lynagh:
> > 
> > I think you could get most of the benefit with little cost by having 2
> > libraries darcs2 and darcs3 that deal with the respective formats, and
> > have darcs itself link with both and just do the commandline parsing and
> > the "what repo am I in".
> 
> Sigh. I wish it were that simple.
> 
> The way the Darcs UI layer is structured this just doesn't work.

Well, a simple mostly-good-enough solution would be:

    main :: IO ()
    main = do args <- getArgs
              case args of
                  ("--2" : args') -> Darcs.Darcs2.Main.main args'
                  ("--3" : args') -> Darcs.Darcs3.Main.main args'
                  _ -> do
                      t <- getRepoType "."
                      case t of
                          NotARepo   -> Darcs.Darcs3.Main.main args
                          Darcs3Repo -> Darcs.Darcs3.Main.main args
                          Darcs2Repo -> Darcs.Darcs2.Main.main args

Now "darcs pull" etc will all do the right thing.
"darcs init" makes a darcs3 repo, and "darcs --2 init" will make a
darcs2 repo.

The annoying case would be "darcs pull --repodir someDir" where someDir
is a darcs2 repo. Now you need to say "darcs --2 pull --repodir someDir"
("darcs pull --repodir someDir" would still work fine for darcs3 repos,
unless you run it from a directory containing a darcs2 repo).


Thanks
Ian



More information about the darcs-devel mailing list