1 %  Copyright (C) 2002-2003 David Roundy
    2 %
    3 %  This program is free software; you can redistribute it and/or modify
    4 %  it under the terms of the GNU General Public License as published by
    5 %  the Free Software Foundation; either version 2, or (at your option)
    6 %  any later version.
    7 %
    8 %  This program is distributed in the hope that it will be useful,
    9 %  but WITHOUT ANY WARRANTY; without even the implied warranty of
   10 %  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   11 %  GNU General Public License for more details.
   12 %
   13 %  You should have received a copy of the GNU General Public License
   14 %  along with this program; see the file COPYING.  If not, write to
   15 %  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   16 %  Boston, MA 02110-1301, USA.
   17 
   18 \darcsCommand{initialize}
   19 \begin{code}
   20 module Darcs.Commands.Init ( initialize, initialize_cmd ) where
   21 import Darcs.Commands ( DarcsCommand(..), nodefaults )
   22 import Darcs.Arguments ( DarcsFlag, working_repo_dir,
   23                         inventory_choices )
   24 import Darcs.Repository ( amNotInRepository, createRepository )
   25 
   26 initialize_description :: String
   27 initialize_description = "Make the current directory a repository."
   28 
   29 initialize_help :: String
   30 initialize_help =
   31  "The `darcs initialize' command turns the current directory into a\n" ++
   32  "Darcs repository.  Any existing files and subdirectories become\n" ++
   33  "UNSAVED changes in the working tree: record them with `darcs add -r'\n" ++
   34  "and `darcs record'.\n" ++
   35  "\n" ++
   36  -- FIXME: confirm my assertion re conversion is true. --twb, 2008-12-14
   37  "When converting a project to Darcs from some other VCS, translating\n" ++
   38  "the full revision history to native Darcs patches is recommended.\n" ++
   39  "(The Darcs wiki lists utilities for this.)  Because Darcs is optimized\n" ++
   40  "for small patches, simply importing the latest revision as a single\n" ++
   41  "large patch can PERMANENTLY degrade Darcs performance in your\n" ++
   42  "repository by an order of magnitude.\n" ++
   43  "\n" ++
   44  "This command creates the `_darcs' directory, which stores version\n" ++
   45  "control metadata.  It also contains per-repository settings in\n" ++
   46  "_darcs/prefs/, which you can read about in the user manual.\n" ++
   47  "\n" ++
   48  "In addition to the default `darcs-2' format, there are two backward\n" ++
   49  "compatibility formats for the _darcs directory.  These formats are\n" ++
   50  "only useful if some of your contributors do not have access to Darcs\n" ++
   51  "2.0 or higher.  In that case, you need to use the original format\n" ++
   52  "(called `old-fashioned inventory' or `darcs-1') for any repositories\n" ++
   53  "those contributors access.\n" ++
   54  "\n" ++
   55  "As patches cannot be shared between darcs-2 and darcs-1 repositories,\n" ++
   56  "you cannot use the darcs-2 format for private branches of such a\n" ++
   57  "project.  Instead, you should use the `hashed' format, which provides\n" ++
   58  "most of the features of the darcs-2 format, while retaining the\n" ++
   59  "ability to share patches with darcs-1 repositories.  The `darcs get'\n" ++
   60  "command will do this by default.\n" ++
   61  "\n" ++
   62  "Once all contributors have access to Darcs 2.0 or higher, a darcs-1\n" ++
   63  "project can be migrated to darcs-2 using the `darcs convert' command.\n" ++
   64  "\n" ++
   65  "Darcs will create a hashed repository by default when you `darcs get'\n" ++
   66  "a repository in old-fashioned inventory format.  Once all contributors\n" ++
   67  "have upgraded to Darcs 2.0 or later, use `darcs convert' to convert\n" ++
   68  "the project to the darcs-2 format.\n" ++
   69  "\n" ++
   70  "Initialize is commonly abbreviated to `init'.\n"
   71 
   72 initialize :: DarcsCommand
   73 initialize = DarcsCommand {command_name = "initialize",
   74                          command_help = initialize_help,
   75                          command_description = initialize_description,
   76                          command_extra_args = 0,
   77                          command_extra_arg_help = [],
   78                          command_prereq = amNotInRepository,
   79                          command_command = initialize_cmd,
   80                          command_get_arg_possibilities = return [],
   81                          command_argdefaults = nodefaults,
   82                          command_advanced_options = [],
   83                          command_basic_options = [inventory_choices,
   84                                                   working_repo_dir]}
   85 
   86 initialize_cmd :: [DarcsFlag] -> [String] -> IO ()
   87 initialize_cmd opts _ = createRepository opts
   88 \end{code}
   89