From fde6099c59d5e6355ab8fd51eb92dc279593dad1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 23 Jun 2020 17:41:50 -0400 Subject: [PATCH] dix original branch determation when testing adjusted branches --- Test.hs | 31 +++++++++++++------------------ Test/Framework.hs | 11 ++++++++++- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Test.hs b/Test.hs index 109dbe9846..c3ccbf95f8 100644 --- a/Test.hs +++ b/Test.hs @@ -37,7 +37,6 @@ import qualified Git.Types import qualified Git.Ref import qualified Git.LsTree import qualified Git.FilePath -import qualified Git.Branch import qualified Annex.Locations #ifndef mingw32_HOST_OS import qualified Types.GitConfig @@ -1503,8 +1502,7 @@ test_adjusted_branch_subtree_regression = withtmpclonerepo $ \r -> whenM (adjustedbranchsupported r) $ do indir r $ do disconnectOrigin - origbranch <- maybe "foo" (Git.Types.fromRef . Git.Ref.base) - <$> annexeval (Annex.inRepo Git.Branch.current) + origbranch <- annexeval origBranch git_annex "upgrade" [] @? "upgrade failed" git_annex "adjust" ["--unlock", "--force"] @? "adjust failed" createDirectoryIfMissing True "a/b/c" @@ -1774,21 +1772,20 @@ test_export_import = intmpclonerepo $ do -- is in sync with the adjusted branch, which it may not be -- depending on how the repository was set up. commitchanges - currbranch <- maybe "foo" (Git.Types.fromRef . Git.Ref.base) - <$> annexeval (Annex.inRepo Git.Branch.current) - git_annex "export" [currbranch, "--to", "foo"] @? "export to dir failed" + origbranch <- annexeval origBranch + git_annex "export" [origbranch, "--to", "foo"] @? "export to dir failed" dircontains annexedfile (content annexedfile) writedir "import" (content "import") - git_annex "import" [currbranch, "--from", "foo"] @? "import from dir failed" - git_annex "merge" ["foo/" ++ currbranch] @? "git annex merge failed" + git_annex "import" [origbranch, "--from", "foo"] @? "import from dir failed" + git_annex "merge" ["foo/" ++ origbranch] @? "git annex merge failed" annexed_present_imported "import" nukeFile "import" writecontent "import" (content "newimport1") git_annex "add" ["import"] @? "add of import failed" commitchanges - git_annex "export" [currbranch, "--to", "foo"] @? "export modified file to dir failed" + git_annex "export" [origbranch, "--to", "foo"] @? "export modified file to dir failed" dircontains "import" (content "newimport1") -- verify that export refuses to overwrite modified file @@ -1797,17 +1794,17 @@ test_export_import = intmpclonerepo $ do writecontent "import" (content "newimport3") git_annex "add" ["import"] @? "add of import failed" commitchanges - git_annex_shouldfail "export" [currbranch, "--to", "foo"] @? "export failed to fail in conflict" + git_annex_shouldfail "export" [origbranch, "--to", "foo"] @? "export failed to fail in conflict" dircontains "import" (content "newimport2") -- resolving import conflict - git_annex "import" [currbranch, "--from", "foo"] @? "import from dir failed" + git_annex "import" [origbranch, "--from", "foo"] @? "import from dir failed" not <$> boolSystem "git" [Param "merge", Param "foo/master", Param "-mmerge"] @? "git merge of conflict failed to exit nonzero" nukeFile "import" writecontent "import" (content "newimport3") git_annex "add" ["import"] @? "add of import failed" commitchanges - git_annex "export" [currbranch, "--to", "foo"] @? "export failed after import conflict" + git_annex "export" [origbranch, "--to", "foo"] @? "export failed after import conflict" dircontains "import" (content "newimport3") where dircontains f v = @@ -1855,15 +1852,13 @@ test_export_import_subdir = intmpclonerepo $ do subannexedfile = "subdir" annexedfile testexport = do - currbranch <- maybe "foo" (Git.Types.fromRef . Git.Ref.base) - <$> annexeval (Annex.inRepo Git.Branch.current) - git_annex "export" [currbranch++":"++subdir, "--to", "foo"] @? "export of subdir failed" + origbranch <- annexeval origBranch + git_annex "export" [origbranch++":"++subdir, "--to", "foo"] @? "export of subdir failed" dircontains annexedfile (content annexedfile) testimport = do - currbranch <- maybe "foo" (Git.Types.fromRef . Git.Ref.base) - <$> annexeval (Annex.inRepo Git.Branch.current) - git_annex "import" [currbranch++":"++subdir, "--from", "foo"] @? "import of subdir failed" + origbranch <- annexeval origBranch + git_annex "import" [origbranch++":"++subdir, "--from", "foo"] @? "import of subdir failed" git_annex "merge" ["foo/master"] @? "git annex merge foo/master failed" -- Make sure that import did not import the file to the top diff --git a/Test/Framework.hs b/Test/Framework.hs index bf3a16d287..5e95d750d8 100644 --- a/Test/Framework.hs +++ b/Test/Framework.hs @@ -1,6 +1,6 @@ {- git-annex test suite framework - - - Copyright 2010-2019 Joey Hess + - Copyright 2010-2020 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. -} @@ -24,6 +24,8 @@ import qualified Backend import qualified Git.CurrentRepo import qualified Git.Construct import qualified Git.Types +import qualified Git.Branch +import qualified Git.Ref import qualified Types.KeySource import qualified Types.Backend import qualified Types @@ -591,3 +593,10 @@ getKey b f = case Types.Backend.getKey b of , Types.KeySource.contentLocation = toRawFilePath f , Types.KeySource.inodeCache = Nothing } + +{- Get the name of the original branch, eg the current branch, or + - if in an adjusted branch, the parent branch. -} +origBranch :: Types.Annex String +origBranch = maybe "foo" + (Git.Types.fromRef . Git.Ref.base . Annex.AdjustedBranch.fromAdjustedBranch) + <$> Annex.inRepo Git.Branch.current