-
Notifications
You must be signed in to change notification settings - Fork 704
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for hg version control system (#7133)
* Add sync support for hg * Updated VCS tests to include hg. cabal.project requires tests enabled for cabal-install Co-authored-by: Emily Pillmore <[email protected]>
- Loading branch information
Showing
2 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,12 @@ tests mtimeChange = | |
, testProperty "syncSourceRepos" prop_syncRepos_pijul | ||
] | ||
|
||
, testGroup "mercurial" $ const [] | ||
[ testProperty "check VCS test framework" prop_framework_hg | ||
, testProperty "cloneSourceRepo" prop_cloneRepo_hg | ||
, testProperty "syncSourceRepos" prop_syncRepos_hg | ||
] | ||
|
||
] | ||
|
||
prop_framework_git :: BranchingRepoRecipe -> Property | ||
|
@@ -86,6 +92,12 @@ prop_framework_pijul = | |
. prop_framework vcsPijul vcsTestDriverPijul | ||
. WithBranchingSupport | ||
|
||
prop_framework_hg :: BranchingRepoRecipe -> Property | ||
prop_framework_hg = | ||
ioProperty | ||
. prop_framework vcsHg vcsTestDriverHg | ||
. WithBranchingSupport | ||
|
||
prop_cloneRepo_git :: BranchingRepoRecipe -> Property | ||
prop_cloneRepo_git = | ||
ioProperty | ||
|
@@ -105,6 +117,12 @@ prop_cloneRepo_pijul = | |
. prop_cloneRepo vcsPijul vcsTestDriverPijul | ||
. WithBranchingSupport | ||
|
||
prop_cloneRepo_hg :: BranchingRepoRecipe -> Property | ||
prop_cloneRepo_hg = | ||
ioProperty | ||
. prop_cloneRepo vcsHg vcsTestDriverHg | ||
. WithBranchingSupport | ||
|
||
prop_syncRepos_git :: RepoDirSet -> SyncTargetIterations -> PrngSeed | ||
-> BranchingRepoRecipe -> Property | ||
prop_syncRepos_git destRepoDirs syncTargetSetIterations seed = | ||
|
@@ -130,6 +148,14 @@ prop_syncRepos_pijul destRepoDirs syncTargetSetIterations seed = | |
destRepoDirs syncTargetSetIterations seed | ||
. WithBranchingSupport | ||
|
||
prop_syncRepos_hg :: RepoDirSet -> SyncTargetIterations -> PrngSeed | ||
-> BranchingRepoRecipe -> Property | ||
prop_syncRepos_hg destRepoDirs syncTargetSetIterations seed = | ||
ioProperty | ||
. prop_syncRepos vcsHg vcsTestDriverHg | ||
destRepoDirs syncTargetSetIterations seed | ||
. WithBranchingSupport | ||
|
||
-- ------------------------------------------------------------ | ||
-- * General test setup | ||
-- ------------------------------------------------------------ | ||
|
@@ -755,3 +781,46 @@ vcsTestDriverPijul verbosity vcs repoRoot = | |
} | ||
pijul = runProgramInvocation verbosity . gitInvocation | ||
pijul' = getProgramInvocationOutput verbosity . gitInvocation | ||
|
||
vcsTestDriverHg :: Verbosity -> VCS ConfiguredProgram | ||
-> FilePath -> VCSTestDriver | ||
vcsTestDriverHg verbosity vcs repoRoot = | ||
VCSTestDriver { | ||
vcsVCS = vcs | ||
|
||
, vcsRepoRoot = repoRoot | ||
|
||
, vcsIgnoreFiles = Set.empty | ||
|
||
, vcsInit = | ||
hg $ ["init"] ++ verboseArg | ||
|
||
, vcsAddFile = \_ filename -> | ||
hg ["add", filename] | ||
|
||
, vcsCommitChanges = \_state -> do | ||
hg $ [ "--user='A <[email protected]>'" | ||
, "commit", "--message=a patch" | ||
] ++ verboseArg | ||
commit <- hg' ["log", "--template='{node}\\n' -l1"] | ||
let commit' = takeWhile (not . isSpace) commit | ||
return (Just commit') | ||
|
||
, vcsTagState = \_ tagname -> | ||
hg ["tag", "--force", tagname] | ||
|
||
, vcsSwitchBranch = \RepoState{allBranches} branchname -> do | ||
unless (branchname `Map.member` allBranches) $ | ||
hg ["branch", branchname] | ||
hg $ ["checkout", branchname] ++ verboseArg | ||
|
||
, vcsCheckoutTag = Left $ \tagname -> | ||
hg $ ["checkout", "--rev", tagname] ++ verboseArg | ||
} | ||
where | ||
hgInvocation args = (programInvocation (vcsProgram vcs) args) { | ||
progInvokeCwd = Just repoRoot | ||
} | ||
hg = runProgramInvocation verbosity . hgInvocation | ||
hg' = getProgramInvocationOutput verbosity . hgInvocation | ||
verboseArg = [ "--quiet" | verbosity < Verbosity.normal ] |