예제 #1
0
파일: testGrapeGit.py 프로젝트: LLNL/GRAPE
 def testMergeAbort(self):
     try:
         os.chdir(self.repo)
         git.branch("testMergeAbort/tmp1 HEAD")
         #add a file on the master branch.
         f1name = os.path.join(self.repo, "f1")
         writeFile1(f1name)
         git.add("f1")
         commitStr = "testMergeAbort: added f1"
         git.commit(" -m \"%s\"" % commitStr)
         # also add it on the tmp branch
         git.checkout("testMergeAbort/tmp1")
         writeFile2(f1name)
         git.add("f1")
         git.commit(" -m \"testMergeAbort/tmp1 : added f1\"")
         # a merge should generate a conflict
         git.merge("master -m \"merging from master\"")
         self.assertTrue(False, "conflict did not throw exception")
     except:
         status = git.status()
         self.assertTrue("conflict" in status,
                         "'conflict' not in status message %s " % status)
         git.mergeAbort()
         status = git.status()
         self.assertFalse("conflict" in status,
                          "conflict not removed by aborting merge")
예제 #2
0
    def testConflictingMerge_MD(self):
        self.setUpConflictingMerge()
        try:
            self.assertNotEqual(git.shortSHA(), git.shortSHA("master"))
            ret = grapeMenu.menu().applyMenuChoice("md", ["--am"])
            self.assertFalse(
                ret, "grape m did not return false as expected for a conflict")
            # resolve the conflict

            self.assertFalse(
                git.isWorkingDirectoryClean(),
                "working directory clean before attempted continution of "
                "merge\n %s" % self.output.getvalue())
            git.checkout("--ours f2")
            git.add("f2")

            ret = grapeMenu.menu().applyMenuChoice("md", ["--continue"])
            self.assertTrue(
                ret, "grape md --continue did not return True\n%s" %
                self.output.getvalue())
            self.assertTrue(
                git.isWorkingDirectoryClean(),
                "grape m --continue did not finish merge\n%s" %
                self.output.getvalue())
        except SystemExit:
            self.fail("Unexpected SystemExit: %s" % self.output.getvalue())
예제 #3
0
파일: testCO.py 프로젝트: LLNL/GRAPE
    def setUpSubmoduleBranch(self):
        git.clone("%s %s" % (self.repo, self.repos[1]))
        os.chdir(self.repo)
        git.checkout("-b addSubmodule")
        git.submodule("add %s submodule" % self.repos[1])
        git.commit("-m \"added submodule\"")
        git.push("origin HEAD")

        # put the remote for the submodule into a HEAD-less state so it can accept pushes
        os.chdir(self.repos[1])
        git.checkout("--orphan HEAD")

        # go to the submodule and add a file to it.
        os.chdir(os.path.join(self.repo,"submodule"))
        f2 = os.path.join(self.repo,"submodule","f2")
        testGrape.writeFile2(f2)
        git.checkout("-b addSubmodule")
        git.add(f2)
        git.commit("-m \"added f2\"")

        # add another file on the master branch for the submodule
        git.branch("-f master HEAD")
        git.checkout("master")
        f3 = os.path.join(self.repo, "submodule", "f3")
        testGrape.writeFile3(f3)
        git.add(f3)
        git.commit("f3 -m \"f3\"")

        # update the submodule's remote
        git.push("origin --all")

        # git back to the master branch in the original repository
        os.chdir(self.repo)
        git.checkout("master")
예제 #4
0
파일: testGrapeGit.py 프로젝트: LLNL/GRAPE
    def testPush(self):
        try:
            os.chdir(self.repo)
            f2name = os.path.join(self.repo, "f2")
            writeFile2(f2name)
            git.add(f2name)
            git.commit(" -m \"initial commit for testPush\"")
            git.clone("%s %s" %(self.repo,self.repos[1]))
            git.checkout("-b testPush/tmpBranchToAllowPushesToMaster")
            os.chdir(self.repos[1])
            f1name = os.path.join(self.repos[1],"f1")
            writeFile1(f1name)
            git.add("f1")
            commitStr = "testPush: added f1"
            git.commit(" -m \"%s\"" % commitStr)
            os.chdir(self.repo)
            log = git.log("--all")
            self.assertFalse(commitStr in log,"commit message in log before it should be")
            os.chdir(self.repos[1])
            pushOutput = git.push("origin master")
            os.chdir(self.repo)
            git.checkout("master")
            log = git.log()
            self.assertTrue(commitStr in log, "commit message not in log after push")

        except git.GrapeGitError as error:
            self.handleGitError(error)
예제 #5
0
파일: testCO.py 프로젝트: LLNL/GRAPE
    def setUpSubmoduleBranch(self):
        git.clone("%s %s" % (self.repo, self.repos[1]))
        os.chdir(self.repo)
        git.checkout("-b addSubmodule")
        git.submodule("add %s submodule" % self.repos[1])
        git.commit("-m \"added submodule\"")
        git.push("origin HEAD")

        # put the remote for the submodule into a HEAD-less state so it can accept pushes
        os.chdir(self.repos[1])
        git.checkout("--orphan HEAD")

        # go to the submodule and add a file to it.
        os.chdir(os.path.join(self.repo, "submodule"))
        f2 = os.path.join(self.repo, "submodule", "f2")
        testGrape.writeFile2(f2)
        git.checkout("-b addSubmodule")
        git.add(f2)
        git.commit("-m \"added f2\"")

        # add another file on the master branch for the submodule
        git.branch("-f master HEAD")
        git.checkout("master")
        f3 = os.path.join(self.repo, "submodule", "f3")
        testGrape.writeFile3(f3)
        git.add(f3)
        git.commit("f3 -m \"f3\"")

        # update the submodule's remote
        git.push("origin --all")

        # git back to the master branch in the original repository
        os.chdir(self.repo)
        git.checkout("master")
예제 #6
0
파일: testPublish.py 프로젝트: LLNL/GRAPE
 def testTopicConfigOption(self):
     self.setUpBranchToFFMerge()
     git.checkout("-b someOtherBranch")
     testGrape.writeFile1("someOtherfile")
     git.add("someOtherfile")
     git.commit("-a -m \"someOtherfile\"")
     self.assertGrapePublishFailed(["--topic=testPublish"])
예제 #7
0
파일: testGrapeGit.py 프로젝트: LLNL/GRAPE
 def testRebase(self):
     try:
         os.chdir(self.repo)
         f1name = os.path.join(self.repo, "f1")
         writeFile1(f1name)
         git.add(f1name)
         git.commit("-m \"initial commit\"")
         git.branch("testRebase/branchToRebase HEAD")
         # while still on master add another commit.
         writeFile2(f1name)
         git.add(f1name)
         git.commit("-m \"edited f1\"")
         # switch to new branch, add a new file, commit, rebase onto master.
         git.checkout("testRebase/branchToRebase")
         f2name = os.path.join(self.repo, "f2")
         writeFile2(f2name)
         git.add(f2name)
         git.commit("-m \"added f2\" ")
         self.assertFalse(
             git.branchUpToDateWith("testRebase/branchToRebase", "master"),
             "attempting rebase in situation where rebase will not do anything."
         )
         try:
             git.rebase("master")
             self.assertTrue(
                 git.branchUpToDateWith("testRebase/branchToRebase",
                                        "master"),
                 "rebase did not bring current branch up to date with master"
             )
         except git.GrapeGitError as error:
             self.assertTrue(
                 False,
                 "rebase that should not have generated a conflict failed")
     except git.GrapeGitError as error:
         self.handleGitError(error)
예제 #8
0
 def testTopicConfigOption(self):
     self.setUpBranchToFFMerge()
     git.checkout("-b someOtherBranch")
     testGrape.writeFile1("someOtherfile")
     git.add("someOtherfile")
     git.commit("-a -m \"someOtherfile\"")
     self.assertGrapePublishFailed(["--topic=testPublish"])
예제 #9
0
파일: testGrapeGit.py 프로젝트: LLNL/GRAPE
 def testRebase(self):
     try:
         os.chdir(self.repo)
         f1name = os.path.join(self.repo,"f1")
         writeFile1(f1name)
         git.add(f1name)
         git.commit("-m \"initial commit\"")
         git.branch("testRebase/branchToRebase HEAD")
         # while still on master add another commit.
         writeFile2(f1name)
         git.add(f1name)
         git.commit("-m \"edited f1\"")
         # switch to new branch, add a new file, commit, rebase onto master.
         git.checkout("testRebase/branchToRebase")
         f2name = os.path.join(self.repo,"f2")
         writeFile2(f2name)
         git.add(f2name)
         git.commit("-m \"added f2\" ")
         self.assertFalse(git.branchUpToDateWith("testRebase/branchToRebase","master"),"attempting rebase in situation where rebase will not do anything.")
         try:
             git.rebase("master")
             self.assertTrue(git.branchUpToDateWith("testRebase/branchToRebase","master"),"rebase did not bring current branch up to date with master")
         except git.GrapeGitError as error:
             self.assertTrue(False,"rebase that should not have generated a conflict failed")
     except git.GrapeGitError as error:
         self.handleGitError(error)
예제 #10
0
파일: testGrapeGit.py 프로젝트: LLNL/GRAPE
    def testPush(self):
        try:
            os.chdir(self.repo)
            f2name = os.path.join(self.repo, "f2")
            writeFile2(f2name)
            git.add(f2name)
            git.commit(" -m \"initial commit for testPush\"")
            git.clone("%s %s" % (self.repo, self.repos[1]))
            git.checkout("-b testPush/tmpBranchToAllowPushesToMaster")
            os.chdir(self.repos[1])
            f1name = os.path.join(self.repos[1], "f1")
            writeFile1(f1name)
            git.add("f1")
            commitStr = "testPush: added f1"
            git.commit(" -m \"%s\"" % commitStr)
            os.chdir(self.repo)
            log = git.log("--all")
            self.assertFalse(commitStr in log,
                             "commit message in log before it should be")
            os.chdir(self.repos[1])
            pushOutput = git.push("origin master")
            os.chdir(self.repo)
            git.checkout("master")
            log = git.log()
            self.assertTrue(commitStr in log,
                            "commit message not in log after push")

        except git.GrapeGitError as error:
            self.handleGitError(error)
예제 #11
0
파일: testPublish.py 프로젝트: LLNL/GRAPE
 def setUpBranchToFFMerge(self):
     os.chdir(self.repo)
     self.branch = "testPublish"
     git.checkout("-b %s" % self.branch)
     testGrape.writeFile2("f2")
     git.add("f2")
     git.commit("-m \"added f2\"")
     self.setUpConfig()
예제 #12
0
 def setUpBranchToFFMerge(self):
     os.chdir(self.repo)
     self.branch = "testPublish"
     git.checkout("-b %s" % self.branch)
     testGrape.writeFile2("f2")
     git.add("f2")
     git.commit("-m \"added f2\"")
     self.setUpConfig()
예제 #13
0
파일: testGrapeGit.py 프로젝트: LLNL/GRAPE
    def testCheckout(self):
        try:
            os.chdir(self.repo)
            git.checkout("-b testCheckout/tmpBranch")
            self.assertTrue(git.currentBranch() == "testCheckout/tmpBranch", "checkout of new branch failed")
            git.checkout("master")
            self.assertTrue(git.currentBranch() == "master", "switching to master did not work")

        except git.GrapeGitError as error:
            self.handleGitError(error)
예제 #14
0
 def setUpMerge(self):
     os.chdir(self.repo)
     # create a new branch
     git.branch("testMerge")
     # add f2 to master
     testGrape.writeFile2("f2")
     git.add("f2")
     git.commit("-m \"f2\"")
     git.checkout("testMerge")
     self.setUpConfig()
예제 #15
0
 def setUpMerge(self):
     os.chdir(self.repo)
     # create a new branch
     git.branch("testMerge")
     # add f2 to master
     testGrape.writeFile2("f2")
     git.add("f2")
     git.commit("-m \"f2\"")
     git.checkout("testMerge")
     self.setUpConfig()
예제 #16
0
    def testConflictingSubmoduleMerge(self):
        try:
            self.setUpConflictingSubmoduleMerge()
            subPath = os.path.join(self.repo, "submodule1")
            ret = grapeMenu.menu().applyMenuChoice("m", ["master", "--am"])
            self.assertFalse(
                ret, "grape m did not return False for conflicting merge.")
            # should only have modifications in submodule1, not conflicts
            status = git.status("--porcelain")
            self.assertTrue("UU" not in status and "AA" in status,
                            "unexpected status %s at toplevel" % status)
            os.chdir(subPath)
            status = git.status("--porcelain")
            self.assertTrue("AA" in status,
                            "unexpected status %s in submodule1" % status)

            # resolve the conflict and continue from the submodule's directory
            git.checkout("--ours f1")
            git.add("f1")
            git.commit("-m \"resolved conflict with our f1\"")
            self.setUpConfig()
            ret = grapeMenu.menu().applyMenuChoice("m", ["--continue"])

            # test that we returned successfully
            self.assertTrue(
                ret,
                "grape m --continue did not complete successfully after resolving submodule conflict"
                "\n %s" % self.output.getvalue())

            # test that the submodule master was merged in
            self.assertTrue(
                git.branchUpToDateWith("testSubmoduleMerge2", "master"),
                "grape m --continue did not merge in submodule1`s master branch"
            )

            # test that the outer level master was merged in
            os.chdir(self.repo)
            self.assertTrue(
                git.branchUpToDateWith("testSubmoduleMerge2", "master"),
                "grape m --continue did not merge in the outer level master branch"
            )

            # ensure the gitlink is at the right commit
            git.submodule("update")
            os.chdir(subPath)
            diff = git.diff("testSubmoduleMerge2")
            self.assertFalse(
                diff,
                "checked in gitlink is not at tip of testSubmoduleMerge2")

        except git.GrapeGitError as e:
            self.fail("Uncaught git error executing %s: \n%s" %
                      (e.gitCommand, e.gitOutput))
        except SystemExit:
            self.fail("Uncaught exit\n%s" % self.output.getvalue())
예제 #17
0
파일: testGrapeGit.py 프로젝트: LLNL/GRAPE
    def testCheckout(self):
        try:
            os.chdir(self.repo)
            git.checkout("-b testCheckout/tmpBranch")
            self.assertTrue(git.currentBranch() == "testCheckout/tmpBranch",
                            "checkout of new branch failed")
            git.checkout("master")
            self.assertTrue(git.currentBranch() == "master",
                            "switching to master did not work")

        except git.GrapeGitError as error:
            self.handleGitError(error)
예제 #18
0
 def setUpConflictingNestedSubprojectMerge(self):
     os.chdir(self.defaultWorkingDirectory)
     testNestedSubproject.TestNestedSubproject.assertCanAddNewSubproject(self)
     os.chdir(self.subproject)
     
     # set up f1 with conflicting content on master  and testNestedMerge branches. 
     git.checkout("master")
     git.branch("testNestedMerge")
     testGrape.writeFile2("f1")
     git.add("f1")
     git.commit("-m \"added f2 as f1\"")
     git.checkout("testNestedMerge")
     testGrape.writeFile3("f1")
     git.add("f1")
     git.commit("-m \"added f1 as f1\"")
     
     os.chdir(self.repo)
예제 #19
0
    def testConflictingNestedSubprojectMerge_MD(self):
        self.setUpConflictingNestedSubprojectMerge()
        os.chdir(self.repo)
        git.checkout(" -b testNestedMerge")

        #make sure we're not up to date with master
        os.chdir(self.subproject)
        self.assertFalse(git.branchUpToDateWith("testNestedMerge", "master"),
                         msg=None)
        os.chdir(self.repo)
        # run grape md --am
        try:
            ret = grapeMenu.menu().applyMenuChoice("md",
                                                   ["--am", "--public=master"],
                                                   globalArgs=["-v"])
        except SystemExit as e:
            self.assertTrue(False, "grape md raised exception %s" % e)
        self.assertFalse(
            ret, "grape md did not return False for conflicting merge.")
        # git status in outer repo should be clean
        status = git.status("--porcelain")
        self.assertFalse(
            status,
            "status is not empty in outer repo after conflict in subproject")
        # git status in subproject should not be clean
        os.chdir(self.subproject)
        status = git.status("--porcelain")
        self.assertIn("AA", status, "no conflicts in subproject status")

        # resolve the conflict
        git.checkout("--ours f1")
        git.add("f1")
        status = git.status("--porcelain")
        self.assertNotIn("AA", status,
                         "conflict not resolved after staging f1")

        # continue the merge
        ret = grapeMenu.menu().applyMenuChoice("md", ["--continue"])
        self.assertTrue(
            ret, "md didn't return successfully after conflict resolution")
        os.chdir(self.subproject)

        self.assertTrue(git.branchUpToDateWith("testNestedMerge", "master"))
        os.chdir(self.repo)
        self.assertTrue(git.branchUpToDateWith("testNestedMerge", "master"))
예제 #20
0
파일: testGrapeGit.py 프로젝트: LLNL/GRAPE
    def testMerge(self):
        # First, test to see if a merge that should work does.
        try:
            os.chdir(self.repo)
            #add a file on the master branch.
            f1name = os.path.join(self.repo, "f1")
            writeFile1(f1name)
            git.add("f1")
            commitStr = "testMerge: added f1"
            git.commit(" -m \"%s\"" % commitStr)
            # edit it on branch testMerge/tmp1
            git.checkout("-b testMerge/tmp1")
            writeFile2(f1name)
            git.commit("-a -m \"edited f1\"")
            # perform same editon master
            git.checkout("master")
            writeFile2(f1name)
            git.commit("-a -m \"edited f1 on master\"")
            # switch back to tmp, merge changes from master down
            git.checkout("testMerge/tmp1")
            output = git.merge(
                "master -m \"merged identical change from master\"")
            log = git.log()
            self.assertTrue("identical change from master" in log)
        except git.GrapeGitError as error:
            self.handleGitError(error)

        # Second, test that a merge that should result in a conflict throws an appropriate GrapeGitError exception.
        try:
            git.checkout("master")
            f2name = os.path.join(self.repo, "f2")
            writeFile3(f2name)
            git.add(f2name)
            git.commit("-m \"added f2\"")
            git.checkout("testMerge/tmp1")
            writeFile2(f2name)
            git.add(f2name)
            git.commit("-m \"added f2 in tmp branch\"")
            git.merge("master -m \"merged master branch into testmerge/tmp1\"")
            self.assertTrue(False,
                            "Merge did not throw grapeGitError for conflict")
        except git.GrapeGitError as error:
            status = git.status()
            self.assertTrue("conflict" in status,
                            "'conflict' not in status message %s" % status)
예제 #21
0
    def setUpConflictingNestedSubprojectMerge(self):
        os.chdir(self.defaultWorkingDirectory)
        testNestedSubproject.TestNestedSubproject.assertCanAddNewSubproject(
            self)
        os.chdir(self.subproject)

        # set up f1 with conflicting content on master  and testNestedMerge branches.
        git.checkout("master")
        git.branch("testNestedMerge")
        testGrape.writeFile2("f1")
        git.add("f1")
        git.commit("-m \"added f2 as f1\"")
        git.checkout("testNestedMerge")
        testGrape.writeFile3("f1")
        git.add("f1")
        git.commit("-m \"added f1 as f1\"")

        os.chdir(self.repo)
예제 #22
0
    def testConflictingMerge_MD(self):
        self.setUpConflictingMerge()
        try:
            self.assertNotEqual(git.shortSHA(), git.shortSHA("master"))
            ret = grapeMenu.menu().applyMenuChoice("md", ["--am"])
            self.assertFalse(ret, "grape m did not return false as expected for a conflict")
            # resolve the conflict

            self.assertFalse(git.isWorkingDirectoryClean(), "working directory clean before attempted continution of "
                                                            "merge\n %s" % self.output.getvalue())
            git.checkout("--ours f2")
            git.add("f2")            

            ret = grapeMenu.menu().applyMenuChoice("md", ["--continue"])
            self.assertTrue(ret, "grape md --continue did not return True\n%s" % self.output.getvalue())
            self.assertTrue(git.isWorkingDirectoryClean(), "grape m --continue did not finish merge\n%s" %
                                                           self.output.getvalue())
        except SystemExit:
            self.fail("Unexpected SystemExit: %s" % self.output.getvalue())
예제 #23
0
    def testConflictingSubmoduleMerge(self):
        try:
            self.setUpConflictingSubmoduleMerge()
            subPath = os.path.join(self.repo, "submodule1")
            ret = grapeMenu.menu().applyMenuChoice("m", ["master", "--am"])
            self.assertFalse(ret, "grape m did not return False for conflicting merge.")
            # should only have modifications in submodule1, not conflicts
            status = git.status("--porcelain")
            self.assertTrue("UU" not in status and "AA" in status, "unexpected status %s at toplevel" % status)
            os.chdir(subPath)
            status = git.status("--porcelain")
            self.assertTrue("AA" in status, "unexpected status %s in submodule1" % status)

            # resolve the conflict and continue from the submodule's directory
            git.checkout("--ours f1")
            git.add("f1")
            git.commit("-m \"resolved conflict with our f1\"")
            self.setUpConfig()
            ret = grapeMenu.menu().applyMenuChoice("m", ["--continue"])

            # test that we returned successfully
            self.assertTrue(ret, "grape m --continue did not complete successfully after resolving submodule conflict"
                                 "\n %s" % self.output.getvalue())

            # test that the submodule master was merged in
            self.assertTrue(git.branchUpToDateWith("testSubmoduleMerge2", "master"),
                            "grape m --continue did not merge in submodule1`s master branch")

            # test that the outer level master was merged in
            os.chdir(self.repo)
            self.assertTrue(git.branchUpToDateWith("testSubmoduleMerge2", "master"),
                            "grape m --continue did not merge in the outer level master branch")

            # ensure the gitlink is at the right commit
            git.submodule("update")
            os.chdir(subPath)
            diff = git.diff("testSubmoduleMerge2")
            self.assertFalse(diff, "checked in gitlink is not at tip of testSubmoduleMerge2")

        except git.GrapeGitError as e:
            self.fail("Uncaught git error executing %s: \n%s" % (e.gitCommand, e.gitOutput))
        except SystemExit:
            self.fail("Uncaught exit\n%s" % self.output.getvalue())
예제 #24
0
파일: testGrapeGit.py 프로젝트: LLNL/GRAPE
    def testMerge(self):
        # First, test to see if a merge that should work does.
        try:
            os.chdir(self.repo)
            #add a file on the master branch.
            f1name = os.path.join(self.repo, "f1")
            writeFile1(f1name)
            git.add("f1")
            commitStr = "testMerge: added f1"
            git.commit(" -m \"%s\"" % commitStr)
            # edit it on branch testMerge/tmp1
            git.checkout("-b testMerge/tmp1")
            writeFile2(f1name)
            git.commit("-a -m \"edited f1\"")
            # perform same editon master
            git.checkout("master")
            writeFile2(f1name)
            git.commit("-a -m \"edited f1 on master\"")
            # switch back to tmp, merge changes from master down
            git.checkout("testMerge/tmp1")
            output = git.merge("master -m \"merged identical change from master\"")
            log = git.log()
            self.assertTrue("identical change from master" in log)
        except git.GrapeGitError as error:
            self.handleGitError(error)

        # Second, test that a merge that should result in a conflict throws an appropriate GrapeGitError exception. 
        try:
            git.checkout("master")
            f2name = os.path.join(self.repo,"f2")
            writeFile3(f2name)
            git.add(f2name)
            git.commit("-m \"added f2\"")
            git.checkout("testMerge/tmp1")
            writeFile2(f2name)
            git.add(f2name)
            git.commit("-m \"added f2 in tmp branch\"")
            git.merge("master -m \"merged master branch into testmerge/tmp1\"")
            self.assertTrue(False,"Merge did not throw grapeGitError for conflict")
        except git.GrapeGitError as error:
            status = git.status()
            self.assertTrue("conflict" in status, "'conflict' not in status message %s" % status)
예제 #25
0
    def setUpNonConflictingSubmoduleMerge(self):
        os.chdir(self.defaultWorkingDirectory)
        self.createTestSubmodule()
        git.branch("testSubmoduleMerge")
        # create a new commit in submodule1
        os.chdir(os.path.join(self.repo, "submodule1"))
        git.checkout("master")
        testGrape.writeFile2("f1")
        git.add("f1")
        git.commit("-m \"added f2 as f1\"")
        # update outer level with new commit
        os.chdir(self.repo)
        git.commit("submodule1 -m \"updated submodule gitlink on master branch\"")

        # setup what should be a notionally-conflict free merge
        # (grape needs to deal with the gitlink conflicts automatically)
        git.checkout("testSubmoduleMerge")
        git.submodule("update")
        os.chdir(os.path.join(self.repo, "submodule1"))
        git.checkout("-b testSubmoduleMerge")
        testGrape.writeFile3("f2")
        git.add("f2")
        git.commit("-m \"added f3 as f2\"")
        os.chdir(self.repo)
        git.commit("-a -m \"updated gitlink on branch testSubmoduleMerge\"")
        self.setUpConfig()
예제 #26
0
 def setUpConflictingSubmoduleMerge(self):
     os.chdir(self.defaultWorkingDirectory)
     self.createTestSubmodule()
     git.branch("testSubmoduleMerge2")
     subPath = os.path.join(self.repo, "submodule1")
     os.chdir(subPath)
     git.branch("testSubmoduleMerge2")
     git.checkout("master")
     testGrape.writeFile2("f1")
     git.add("f1")
     git.commit("-m \"added f2 as f1\"")
     os.chdir(self.repo)
     git.commit(
         "submodule1 -m \"updated submodule gitlink on master branch\"")
     git.checkout("testSubmoduleMerge2")
     git.submodule("update")
     os.chdir(subPath)
     git.checkout("testSubmoduleMerge2")
     testGrape.writeFile3("f1")
     git.add("f1")
     git.commit("-m \"added f3 as f1\"")
     os.chdir(self.repo)
     git.commit(
         "submodule1 -m \"updated submodule gitlink on testSubmoduleMerge branch\""
     )
     self.setUpConfig()
예제 #27
0
    def setUpNonConflictingSubmoduleMerge(self):
        os.chdir(self.defaultWorkingDirectory)
        self.createTestSubmodule()
        git.branch("testSubmoduleMerge")
        # create a new commit in submodule1
        os.chdir(os.path.join(self.repo, "submodule1"))
        git.checkout("master")
        testGrape.writeFile2("f1")
        git.add("f1")
        git.commit("-m \"added f2 as f1\"")
        # update outer level with new commit
        os.chdir(self.repo)
        git.commit(
            "submodule1 -m \"updated submodule gitlink on master branch\"")

        # setup what should be a notionally-conflict free merge
        # (grape needs to deal with the gitlink conflicts automatically)
        git.checkout("testSubmoduleMerge")
        git.submodule("update")
        os.chdir(os.path.join(self.repo, "submodule1"))
        git.checkout("-b testSubmoduleMerge")
        testGrape.writeFile3("f2")
        git.add("f2")
        git.commit("-m \"added f3 as f2\"")
        os.chdir(self.repo)
        git.commit("-a -m \"updated gitlink on branch testSubmoduleMerge\"")
        self.setUpConfig()
예제 #28
0
    def testConflictingNestedSubprojectMerge_MD(self):
        self.setUpConflictingNestedSubprojectMerge()
        os.chdir(self.repo)
        git.checkout(" -b testNestedMerge")
        
        #make sure we're not up to date with master
        os.chdir(self.subproject)
        self.assertFalse(git.branchUpToDateWith("testNestedMerge", "master"), msg=None)
        os.chdir(self.repo)
        # run grape md --am
        try:
            ret = grapeMenu.menu().applyMenuChoice("md", ["--am", "--public=master"], globalArgs=["-v"])
        except SystemExit as e: 
            self.assertTrue(False, "grape md raised exception %s" % e)
        self.assertFalse(ret, "grape md did not return False for conflicting merge.")
        # git status in outer repo should be clean
        status = git.status("--porcelain")
        self.assertFalse(status, "status is not empty in outer repo after conflict in subproject")
        # git status in subproject should not be clean
        os.chdir(self.subproject)
        status = git.status("--porcelain")
        self.assertIn("AA", status, "no conflicts in subproject status")
        
        # resolve the conflict
        git.checkout("--ours f1")
        git.add("f1")
        status = git.status("--porcelain")
        self.assertNotIn("AA", status, "conflict not resolved after staging f1")
        
        # continue the merge
        ret = grapeMenu.menu().applyMenuChoice("md", ["--continue"])
        self.assertTrue(ret, "md didn't return successfully after conflict resolution")
        os.chdir(self.subproject)

        self.assertTrue(git.branchUpToDateWith("testNestedMerge", "master"))
        os.chdir(self.repo)
        self.assertTrue(git.branchUpToDateWith("testNestedMerge", "master"))
예제 #29
0
파일: testGrapeGit.py 프로젝트: LLNL/GRAPE
 def testMergeAbort(self):
     try:
         os.chdir(self.repo)
         git.branch("testMergeAbort/tmp1 HEAD")
         #add a file on the master branch.
         f1name = os.path.join(self.repo, "f1")
         writeFile1(f1name)
         git.add("f1")
         commitStr = "testMergeAbort: added f1"
         git.commit(" -m \"%s\"" % commitStr)
         # also add it on the tmp branch
         git.checkout("testMergeAbort/tmp1")
         writeFile2(f1name)
         git.add("f1")
         git.commit(" -m \"testMergeAbort/tmp1 : added f1\"")
         # a merge should generate a conflict
         git.merge("master -m \"merging from master\"")
         self.assertTrue(False,"conflict did not throw exception")
     except:
         status = git.status()
         self.assertTrue("conflict" in status, "'conflict' not in status message %s " % status)
         git.mergeAbort()
         status = git.status()
         self.assertFalse("conflict" in status, "conflict not removed by aborting merge")
예제 #30
0
 def setUpConflictingSubmoduleMerge(self):
     os.chdir(self.defaultWorkingDirectory)
     self.createTestSubmodule()
     git.branch("testSubmoduleMerge2")
     subPath = os.path.join(self.repo, "submodule1")
     os.chdir(subPath)
     git.branch("testSubmoduleMerge2")
     git.checkout("master")
     testGrape.writeFile2("f1")
     git.add("f1")
     git.commit("-m \"added f2 as f1\"")
     os.chdir(self.repo)
     git.commit("submodule1 -m \"updated submodule gitlink on master branch\"")
     git.checkout("testSubmoduleMerge2")
     git.submodule("update")
     os.chdir(subPath)
     git.checkout("testSubmoduleMerge2")
     testGrape.writeFile3("f1")
     git.add("f1")
     git.commit("-m \"added f3 as f1\"")
     os.chdir(self.repo)
     git.commit("submodule1 -m \"updated submodule gitlink on testSubmoduleMerge branch\"")
     self.setUpConfig()