1 % Copyright (C) 2003,2005 David Roundy
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)
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.
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.
18 \subsection{darcs repair}
20 module Darcs.Commands.Repair ( repair ) where
22 import System.Exit ( exitWith, ExitCode(..) )
25 import Darcs.Arguments ( DarcsFlag(),
26 working_repo_dir, umask_option,
28 import Darcs.Repository ( withRepoLock, ($-), amInRepository,
29 replacePristineFromSlurpy )
30 import Darcs.Repository.Repair( replayRepository, cleanupRepositoryReplay,
31 RepositoryConsistency(..), CanRepair(..) )
36 repair_description :: String
37 repair_description = "Repair the corrupted repository."
44 "Repair attempts to fix corruption that may have entered your\n"++
49 repair :: DarcsCommand
50 repair = DarcsCommand {command_name = "repair",
51 command_help = repair_help,
52 command_description = repair_description,
53 command_extra_args = 0,
54 command_extra_arg_help = [],
55 command_command = repair_cmd,
56 command_prereq = amInRepository,
57 command_get_arg_possibilities = return [],
58 command_argdefaults = nodefaults,
59 command_advanced_options = [umask_option],
60 command_basic_options = [working_repo_dir]}
63 Repair currently will only repair damage to the pristine tree.
64 Fortunately this is just the sort of corruption that is most
69 repair_cmd :: [DarcsFlag] -> [String] -> IO ()
70 repair_cmd opts _ = withRepoLock opts $- \repository -> do
71 state <- replayRepository CanRepair repository opts
73 RepositoryConsistent ->
74 putStrLn "The repository is already consistent, no changes made."
75 RepositoryInconsistent s -> do
76 putStrLn "Fixing pristine tree..."
77 replacePristineFromSlurpy repository s
78 cleanupRepositoryReplay repository