[prev in list] [next in list] [prev in thread] [next in thread]
List: darcs-devel
Subject: [darcs-devel] [patch1064] resolve issue2311: posthook for 'get' should run in cr...
From: Sebastian Fischer <bugs () darcs ! net>
Date: 2013-03-08 13:33:37
Message-ID: 5139e86c.85b30e0a.214a.0d88 () mx ! google ! com
[Download RAW message or body]
New submission from Sebastian Fischer <mail@sebfisch.de>:
1 patch for repository /home/sebfisch/Code/Haskell/darcs/screened:
Fri Mar 8 14:07:54 CET 2013 Sebastian Fischer <mail@sebfisch.de>
* resolve issue2311: posthook for 'get' should run in created repo
I have added a function `getPosthookDir` to `Darcs.UI.RunCommand` that
computes a working dir for posthooks based on the current directory
based on the name of the command and the directory in which the
command is run.
For most commands the previous behavior is retained. For the `get`
command, the newly created repository is used as working dir for
posthooks.
To avoid code duplication, I have exported `makeRepoName` from
`Darcs.UI.Commands.Get` and used it in the function `getPosthookDir`
to compute the name that darcs will use for the newly created
repository.
The newly added tests for issue2311 (which were previously failing)
now pass.
----------
files: patch-preview.txt, \
resolve-issue2311_-posthook-for-_get_-should-run-in-created-repo.dpatch, \
unnamed
messages: 16748
nosy: sebfisch
status: needs-screening
title: resolve issue2311: posthook for 'get' should run in cr...
__________________________________
Darcs bug tracker <bugs@darcs.net>
<http://bugs.darcs.net/patch1064>
__________________________________
["patch-preview.txt" (text/x-darcs-patch)]
[resolve issue2311: posthook for 'get' should run in created repo
Sebastian Fischer <mail@sebfisch.de>**20130308130754
Ignore-this: e340bfcfac76da2afe9c919b25c219e7
I have added a function `getPosthookDir` to `Darcs.UI.RunCommand` that
computes a working dir for posthooks based on the current directory
based on the name of the command and the directory in which the
command is run.
For most commands the previous behavior is retained. For the `get`
command, the newly created repository is used as working dir for
posthooks.
To avoid code duplication, I have exported `makeRepoName` from
`Darcs.UI.Commands.Get` and used it in the function `getPosthookDir`
to compute the name that darcs will use for the newly created
repository.
The newly added tests for issue2311 (which were previously failing)
now pass.
] hunk ./src/Darcs/UI/Commands/Get.hs 23
module Darcs.UI.Commands.Get
( get
, clone
+ , makeRepoName
) where
import Prelude hiding ( catch )
hunk ./src/Darcs/UI/RunCommand.hs 21
{-# LANGUAGE CPP #-}
module Darcs.UI.RunCommand ( runTheCommand ) where
+import Data.Functor ((<$>))
import Control.Monad ( unless, when )
import System.Console.GetOpt( ArgOrder( Permute, RequireOrder ),
OptDescr( Option ),
hunk ./src/Darcs/UI/RunCommand.hs 55
, formatPath
)
import Darcs.UI.Commands.GZCRCs ( doCRCWarnings )
+import Darcs.UI.Commands.Get ( makeRepoName )
import Darcs.UI.External ( viewDoc )
import Darcs.Util.AtExit ( atexit )
hunk ./src/Darcs/UI/RunCommand.hs 62
import Darcs.Util.Global ( setDebugMode, setTimingsMode )
import Darcs.Patch.Match ( checkMatchSyntax )
import Darcs.Util.Progress ( setProgressMode )
-import Darcs.Util.Path ( getCurrentDirectory )
+import Darcs.Util.Path ( AbsolutePath, getCurrentDirectory, toPath, \
ioAbsoluteOrRemote, makeAbsolute )
import Darcs.Repository.Test ( runPosthook, runPrehook )
import Data.List ( intercalate )
hunk ./src/Darcs/UI/RunCommand.hs 138
if preHookExitCode /= ExitSuccess
then exitWith preHookExitCode
else do fixedOs <- mapM (fixUrlFlag cwd) os
+ phDir <- getPosthookDir here cmd fixedOs ex
commandCommand cmd (here, cwd) fixedOs ex
hunk ./src/Darcs/UI/RunCommand.hs 140
- postHookExitCode <- runPosthook (getPosthookCmd os) \
(AskPosthook `elem` os) (verbosity os) here + \
postHookExitCode <- runPosthook (getPosthookCmd os) (AskPosthook `elem` os) \
(verbosity os) phDir exitWith postHookExitCode
hunk ./src/Darcs/UI/RunCommand.hs 143
+
+-- Returns the working directory for the posthook. For most commands, the
+-- first parameter is returned. For the 'get' command, the path of the newly
+-- created repository is returned.
+getPosthookDir :: AbsolutePath -> DarcsCommand -> [DarcsFlag] -> [String] -> IO \
AbsolutePath +getPosthookDir here cmd opts extra | commandName cmd == "get" = do
+ case extra of
+ [inrepodir, outname] -> getPosthookDir here cmd (NewRepo outname:opts) \
[inrepodir] + [inrepodir] -> do
+ repodir <- toPath <$> ioAbsoluteOrRemote inrepodir
+ reponame <- makeRepoName opts repodir
+ return $ makeAbsolute here reponame
+ _ -> fail "You must provide 'get' with either one or two arguments."
+
+getPosthookDir here _ _ _ = return here
+
+
-- Checks if the number of extra arguments matches the number of extra
-- arguments supported by the command as specified in `commandExtraArgs`.
-- Extra arguments are arguments that follow the command but aren't
["resolve-issue2311_-posthook-for-_get_-should-run-in-created-repo.dpatch" (application/x-darcs-patch)]
["unnamed" (application/octet-stream)]
_______________________________________________
darcs-devel mailing list
darcs-devel@darcs.net
http://lists.osuosl.org/mailman/listinfo/darcs-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic