Ticket #7035: 7035-release-scripts-use-git-1.patch

File 7035-release-scripts-use-git-1.patch, 11.3 KB (added by multani, 3 years ago)
  • twisted/python/_release.py

    diff --git twisted/python/_release.py twisted/python/_release.py
    index 8d80d45..8d11904 100644
    class NewsBuilder(object): 
    525525        @param header: The top-level header to use when writing the news.
    526526        @type header: L{str}
    527527
    528         @raise NotWorkingDirectory: If the C{path} is not an SVN checkout.
     528        @raise NotWorkingDirectory: If the C{path} is not an Git repository.
    529529        """
    530530        changes = []
    531531        for part in (self._FEATURE, self._BUGFIX, self._DOC, self._REMOVAL):
    class NewsBuilder(object): 
    557557    def _deleteFragments(self, path):
    558558        """
    559559        Delete the change information, to clean up the repository  once the
    560         NEWS files have been built. It requires C{path} to be in a SVN
    561         directory.
     560        NEWS files have been built. It requires C{path} to be in a Git
     561        repository.
    562562
    563563        @param path: A directory (probably a I{topfiles} directory) containing
    564564            change information in the form of <ticket>.<change type> files.
    class NewsBuilder(object): 
    568568        for child in path.children():
    569569            base, ext = os.path.splitext(child.basename())
    570570            if ext in ticketTypes:
    571                 runCommand(["svn", "rm", child.path])
     571                runCommand(["git", "-C", child.dirname(), "rm", child.path])
    572572
    573573
    574574    def _getNewsName(self, project):
    class NewsBuilder(object): 
    626626            beneath which to find Twisted projects for which to generate
    627627            news (see L{findTwistedProjects}).
    628628        """
    629         try:
    630             runCommand(["svn", "info", baseDirectory.path])
    631         except CommandFailed:
     629        if not baseDirectory.child(".git").exists():
    632630            raise NotWorkingDirectory(
    633                 "%s does not appear to be an SVN working directory."
     631                "%s does not appear to be an Git working directory."
    634632                % (baseDirectory.path,))
    635633
    636634        today = self._today()
    class DistributionBuilder(object): 
    988986
    989987class UncleanWorkingDirectory(Exception):
    990988    """
    991     Raised when the working directory of an SVN checkout is unclean.
     989    Raised when the working directory of a Git repository is unclean.
    992990    """
    993991
    994992
    995993
    996994class NotWorkingDirectory(Exception):
    997995    """
    998     Raised when a directory does not appear to be an SVN working directory.
     996    Raised when a directory does not appear to be a Git repository directory.
    999997    """
    1000998
    1001999
    def buildAllTarballs(checkout, destination, templatePath=None): 
    10091007    NEWS files created.
    10101008
    10111009    @type checkout: L{FilePath}
    1012     @param checkout: The SVN working copy from which a pristine source tree
     1010    @param checkout: The Git repository from which a pristine source tree
    10131011        will be exported.
    10141012    @type destination: L{FilePath}
    10151013    @param destination: The directory in which tarballs will be placed.
    def buildAllTarballs(checkout, destination, templatePath=None): 
    10191017
    10201018    @raise UncleanWorkingDirectory: If there are modifications to the
    10211019        working directory of C{checkout}.
    1022     @raise NotWorkingDirectory: If the C{checkout} path is not an SVN checkout.
     1020    @raise NotWorkingDirectory: If the C{checkout} path is not a Git
     1021        repository.
    10231022    """
    1024     if not checkout.child(".svn").exists():
     1023    if not checkout.child(".git").exists():
    10251024        raise NotWorkingDirectory(
    1026             "%s does not appear to be an SVN working directory."
     1025            "%s does not appear to be an Git working directory."
    10271026            % (checkout.path,))
    1028     if runCommand(["svn", "st", checkout.path]).strip():
     1027    if runCommand(["git", "-C", checkout.path, "status", "--short"]).strip():
    10291028        raise UncleanWorkingDirectory(
    1030             "There are local modifications to the SVN checkout in %s."
     1029            "There are local modifications to the Git repository in %s."
    10311030            % (checkout.path,))
    10321031
    10331032    workPath = FilePath(mkdtemp())
    10341033    export = workPath.child("export")
    1035     runCommand(["svn", "export", checkout.path, export.path])
     1034    runCommand(["git", "-C", checkout.path, "checkout-index", "--all",
     1035                "--force", "--prefix", export.path + "/"])
    10361036    twistedPath = export.child("twisted")
    10371037    version = Project(twistedPath).getVersion()
    10381038    versionString = version.base()
  • twisted/python/test/test_release.py

    diff --git twisted/python/test/test_release.py twisted/python/test/test_release.py
    index 9a8dcf3..b548ebf 100644
    else: 
    6262
    6363
    6464
    65 if which("svn") and which("svnadmin"):
    66     svnSkip = skip
     65if which("git"):
     66    gitSkip = skip
    6767else:
    68     svnSkip = "svn or svnadmin is not present."
     68    gitSkip = "git is not present."
    6969
    7070
    7171
    class NewsBuilderTests(TestCase, StructureAssertingMixin): 
    763763    """
    764764    Tests for L{NewsBuilder}.
    765765    """
    766     skip = svnSkip
     766    skip = gitSkip
    767767
    768768    def setUp(self):
    769769        """
    class NewsBuilderTests(TestCase, StructureAssertingMixin): 
    796796                '41.doc': 'writing Foo servers'})
    797797
    798798
    799     def svnCommit(self, project=None):
     799    def gitCommit(self, project=None):
    800800        """
    801         Make the C{project} directory a valid subversion directory with all
     801        Make the C{project} directory a valid Git repository with all
    802802        files committed.
    803803        """
    804804        if project is None:
    805805            project = self.project
    806         repositoryPath = self.mktemp()
    807         repository = FilePath(repositoryPath)
    808 
    809         runCommand(["svnadmin", "create", repository.path])
    810         runCommand(["svn", "checkout", "file://" + repository.path,
    811                     project.path])
    812806
    813         runCommand(["svn", "add"] + glob.glob(project.path + "/*"))
    814         runCommand(["svn", "commit", project.path, "-m", "yay"])
     807        runCommand(["git", "init", project.path])
     808        runCommand(["git", "-C", project.path, "add"] + glob.glob(project.path + "/*"))
     809        runCommand(["git", "-C", project.path, "commit", "-m", "yay"])
    815810
    816811
    817812    def test_today(self):
    class NewsBuilderTests(TestCase, StructureAssertingMixin): 
    11881183        builder._today = lambda: '2009-12-01'
    11891184
    11901185        project = self.createFakeTwistedProject()
    1191         self.svnCommit(project)
     1186        self.gitCommit(project)
    11921187        builder.buildAll(project)
    11931188
    11941189        coreTopfiles = project.child("topfiles")
    class NewsBuilderTests(TestCase, StructureAssertingMixin): 
    12161211        """
    12171212        builder = NewsBuilder()
    12181213        project = self.createFakeTwistedProject()
    1219         self.svnCommit(project)
     1214        self.gitCommit(project)
    12201215        builder.buildAll(project)
    12211216
    12221217        aggregateNews = project.child("NEWS")
    class NewsBuilderTests(TestCase, StructureAssertingMixin): 
    12351230        builder = NewsBuilder()
    12361231        builder._today = lambda: '2009-12-01'
    12371232        project = self.createFakeTwistedProject()
    1238         self.svnCommit(project)
     1233        self.gitCommit(project)
    12391234        builder.buildAll(project)
    12401235        newVersion = Version('TEMPLATE', 7, 7, 14)
    12411236        coreNews = project.child('topfiles').child('NEWS')
    class NewsBuilderTests(TestCase, StructureAssertingMixin): 
    12611256    def test_removeNEWSfragments(self):
    12621257        """
    12631258        L{NewsBuilder.buildALL} removes all the NEWS fragments after the build
    1264         process, using the C{svn} C{rm} command.
     1259        process, using the C{git} C{rm} command.
    12651260        """
    12661261        builder = NewsBuilder()
    12671262        project = self.createFakeTwistedProject()
    1268         self.svnCommit(project)
     1263        self.gitCommit(project)
    12691264        builder.buildAll(project)
    12701265
    12711266        self.assertEqual(5, len(project.children()))
    1272         output = runCommand(["svn", "status", project.path])
     1267        output = runCommand(["git", "-C", project.path, "status", "--short"])
    12731268        removed = [line for line in output.splitlines()
    12741269                   if line.startswith("D ")]
    12751270        self.assertEqual(3, len(removed))
    12761271
    12771272
    1278     def test_checkSVN(self):
     1273    def test_checkGit(self):
    12791274        """
    12801275        L{NewsBuilder.buildAll} raises L{NotWorkingDirectory} when the given
    1281         path is not a SVN checkout.
     1276        path is not a Git repository.
    12821277        """
    12831278        self.assertRaises(
    12841279            NotWorkingDirectory, self.builder.buildAll, self.project)
    class BuildAllTarballsTest(DistributionBuilderTestBase): 
    16771672    """
    16781673    Tests for L{DistributionBuilder.buildAllTarballs}.
    16791674    """
    1680     skip = svnSkip or sphinxSkip
     1675    skip = gitSkip or sphinxSkip
    16811676
    16821677    def test_buildAllTarballs(self):
    16831678        """
    16841679        L{buildAllTarballs} builds tarballs for Twisted and all of its
    1685         subprojects based on an SVN checkout; the resulting tarballs contain
    1686         no SVN metadata.  This involves building documentation, which it will
     1680        subprojects based on an Git repository; the resulting tarballs contain
     1681        no Git metadata.  This involves building documentation, which it will
    16871682        build with the correct API documentation reference base URL.
    16881683        """
    16891684        repositoryPath = self.mktemp()
    class BuildAllTarballsTest(DistributionBuilderTestBase): 
    16921687        checkout = FilePath(checkoutPath)
    16931688        self.outputDir.remove()
    16941689
    1695         runCommand(["svnadmin", "create", repositoryPath])
    1696         runCommand(["svn", "checkout", "file://" + repository.path,
     1690        runCommand(["git", "init", repositoryPath])
     1691        runCommand(["git", "clone", "file://" + repository.path,
    16971692                    checkout.path])
    16981693
    16991694        structure = {
    class BuildAllTarballsTest(DistributionBuilderTestBase): 
    17681763
    17691764        self.createStructure(checkout, structure)
    17701765        childs = [x.path for x in checkout.children()]
    1771         runCommand(["svn", "add"] + childs)
    1772         runCommand(["svn", "commit", checkout.path, "-m", "yay"])
     1766        runCommand(["git", "-C", checkout.path, "add", "-f"] + childs)
     1767        runCommand(["git", "-C", checkout.path, "commit", "-m", "yay"])
    17731768
    17741769        buildAllTarballs(checkout, self.outputDir)
    17751770        self.assertEqual(
    class BuildAllTarballsTest(DistributionBuilderTestBase): 
    17921787    def test_buildAllTarballsEnsuresCleanCheckout(self):
    17931788        """
    17941789        L{UncleanWorkingDirectory} is raised by L{buildAllTarballs} when the
    1795         SVN checkout provided has uncommitted changes.
     1790        Git repository provided has uncommitted changes.
    17961791        """
    17971792        repositoryPath = self.mktemp()
    17981793        repository = FilePath(repositoryPath)
    17991794        checkoutPath = self.mktemp()
    18001795        checkout = FilePath(checkoutPath)
    18011796
    1802         runCommand(["svnadmin", "create", repositoryPath])
    1803         runCommand(["svn", "checkout", "file://" + repository.path,
     1797        runCommand(["git", "init", repositoryPath])
     1798        runCommand(["git", "clone", "file://" + repository.path,
    18041799                    checkout.path])
    18051800
    18061801        checkout.child("foo").setContent("whatever")
    class BuildAllTarballsTest(DistributionBuilderTestBase): 
    18111806    def test_buildAllTarballsEnsuresExistingCheckout(self):
    18121807        """
    18131808        L{NotWorkingDirectory} is raised by L{buildAllTarballs} when the
    1814         checkout passed does not exist or is not an SVN checkout.
     1809        checkout passed does not exist or is not a Git repository.
    18151810        """
    18161811        checkout = FilePath(self.mktemp())
    18171812        self.assertRaises(NotWorkingDirectory,