-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Le 15/10/2010 19:58, Alexey Levan a écrit : > > New submission from Alexey Levan <exle...@gmail.com>: > > 1 patch for repository http://darcs.net/: > > Fri Oct 15 20:54:49 EEST 2010 Alexey Levan <exle...@gmail.com> > * Resolve issue1266: add a warning about nested repositories
Review follows: Resolve issue1266: add a warning about nested repositories - ---------------------------------------------------------- Alexey Levan <exle...@gmail.com>**20101015175449 hunk ./src/Darcs/Repository.hs 49 > > import System.Exit ( ExitCode(..), exitWith ) > import Data.List ( isPrefixOf ) > -import Data.Maybe( catMaybes ) > +import Data.Maybe( catMaybes, isJust ) > > import Darcs.Repository.State( readRecorded, readUnrecorded, readWorking, unrecordedChanges > , readPending, readIndex, invalidateIndex hunk ./src/Darcs/Repository.hs 74 > getMarkedupFile, > setScriptsExecutable, setScriptsExecutablePatches, > testTentative, testRecorded, > - makeNewPending > + makeNewPending, seekRepo > ) > import Darcs.Repository.Merge( tentativelyMergePatches, considerMergeToWorking ) > import Darcs.Repository.Cache ( unionRemoteCaches, fetchFileUsingCache, hunk ./src/Darcs/Repository.hs 94 > import Control.Monad ( unless, when ) > import System.Directory ( createDirectory, renameDirectory, > createDirectoryIfMissing, renameFile, > - doesFileExist, removeFile, getDirectoryContents ) > + doesFileExist, removeFile, getDirectoryContents, > + getCurrentDirectory, setCurrentDirectory ) > import System.IO ( stderr ) > import System.IO.Error ( isAlreadyExistsError ) > import System.Posix.Files ( createLink ) [snip imports...] hunk ./src/Darcs/Repository.hs 157 > (\e-> if isAlreadyExistsError e > then fail "Tree has already been initialized!" > else fail $ "Error creating directory `"++darcsdir++"'.") > + cwd <- getCurrentDirectory > + x <- seekRepo > + when (isJust x) $ do > + setCurrentDirectory cwd > + putStrLn $ "WARNING: creating a nested repository." > let rf = createRepoFormat opts > createPristine $ flagsToPristine opts rf > createDirectory $ darcsdir ++ "/patches" Ok, warn when creating a nested repository hunk ./src/Darcs/Repository/Internal.hs 49 > getRepository, rIO, > testTentative, testRecorded, > UpdatePristine(..), MakeChanges(..), applyToTentativePristine, > - makeNewPending > + makeNewPending, seekRepo > ) where > > import Printer ( putDocLn, (<+>), text, ($$) ) Exports seekRepo, good. hunk ./src/Darcs/Repository/Internal.hs 72 > import System.Directory ( doesDirectoryExist, setCurrentDirectory, > createDirectoryIfMissing, doesFileExist ) > import Control.Monad ( liftM, when, unless, filterM ) > +import Control.Applicative ( (<$>) ) > import Workaround ( getCurrentDirectory, renameFile, setExecutable ) > > import ByteStringUtils ( gzReadFilePS ) hunk ./src/Darcs/Repository/Internal.hs 252 > BadRepository e -> return (Left $ "While " ++ d ++ " looks like a repository directory, we have a problem with it:\n" ++ e) > NonRepository _ -> return (Left "You need to be in a repository directory to run this command.") > amInRepository (_:fs) = amInRepository fs > -amInRepository [] = > - seekRepo (Left "You need to be in a repository directory to run this command.") > +amInRepository [] = do > + maybe (Left $ "You need to be in a repository directory " ++ > + "to run this command.") id <$> seekRepo > > -- | hunt upwards for the darcs repository > -- This keeps changing up one parent directory, testing at each Use the new seekRepo hunk ./src/Darcs/Repository/Internal.hs 259 > -- step if the current directory is a repository or not. $ > +-- The result is: > +-- Nothing, if no repository found > +-- Just (Left errorMessage), if bad repository found > +-- Just (Right ()), if good repository found. > -- WARNING this changes the current directory for good if matchFn succeeds hunk ./src/Darcs/Repository/Internal.hs 264 > -seekRepo :: Either String () > - -- ^ what to return if we don't find a repository > - -> IO (Either String ()) > -seekRepo onFail = getCurrentDirectory >>= helper where > +seekRepo :: IO (Maybe (Either String ())) > +seekRepo = getCurrentDirectory >>= helper where > helper startpwd = do > status <- maybeIdentifyRepository [] "." > case status of hunk ./src/Darcs/Repository/Internal.hs 269 > - GoodRepository _ -> return (Right ()) > - BadRepository e -> return (Left e) > + GoodRepository _ -> return . Just $ Right () > + BadRepository e -> return . Just $ Left e > NonRepository _ -> > do cd <- toFilePath `fmap` getCurrentDirectory > setCurrentDirectory ".." hunk ./src/Darcs/Repository/Internal.hs 278 > if cd' /= cd > then helper startpwd > else do setCurrentDirectory startpwd > - return onFail > + return Nothing > > -- The performGC in this function is a workaround for a library/GHC bug, > -- http://hackage.haskell.org/trac/ghc/ticket/2924 -- (doesn't seem to be a Makes seekRepo saner by remoding cps-style, good. hunk ./src/Darcs/Repository/Internal.hs 305 > do setCurrentDirectory d `catchall` (fail $ "can't set directory to "++d) > findRepository [] > findRepository (_:fs) = findRepository fs > -findRepository [] = seekRepo (Right ()) > +findRepository [] = maybe (Right ()) id <$> seekRepo > > makeNewPending :: forall p C(r u t y). RepoPatch p > => Repository p C(r u t) -> FL Prim C(t y) -> IO () idem, use the new seekRepo. Thanks, applying. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkzP7CcACgkQTCPcDztjGo4VnQCdFcOER1NGy+8PgeRMl3yM73O3 Mh8AnikcOEgPSvJfKGhqVgt1kgmP8IX7 =8tye -----END PGP SIGNATURE----- _______________________________________________ darcs-users mailing list darcs-users@darcs.net http://lists.osuosl.org/mailman/listinfo/darcs-users