Commits

David Schneider committed 9f8ceeb

use the builtin mercurial support

Comments (0)

Files changed (1)

bot2/pypybuildbot/builds.py

+from buildbot.steps.source.mercurial import Mercurial
 from buildbot.process import factory
 from buildbot.steps import shell, transfer
 from buildbot.steps.trigger import Trigger
         if not os.path.exists(masterdest):
             os.makedirs(masterdest)
         #
-        assert '%(final_file_name)s' in self.basename
-        symname = self.basename.replace('%(final_file_name)s', 'latest')
+        assert '%(got_revision)s' in self.basename
+        symname = self.basename.replace('%(got_revision)s', 'latest')
         assert '%' not in symname
         self.symlinkname = os.path.join(masterdest, symname)
         #
 
 # _______________________________________________________________
 
-class UpdateCheckout(ShellCmd):
-    description = 'hg update'
-    command = 'UNKNOWN'
-
-    def __init__(self, workdir=None, haltOnFailure=True, force_branch=None,
-                 **kwargs):
-        ShellCmd.__init__(self, workdir=workdir, haltOnFailure=haltOnFailure,
-                          **kwargs)
-        self.force_branch = force_branch
-        self.addFactoryArguments(force_branch=force_branch)
-
-    def start(self):
-        if self.force_branch is not None:
-            branch = self.force_branch
-            # Note: We could add a warning to the output if we
-            # ignore the branch set by the user.
-        else:
-            properties = self.build.getProperties()
-            branch = properties['branch'] or 'default'
-        command = ["hg", "update", "--clean", "-r", branch]
-        self.setCommand(command)
-        ShellCmd.start(self)
-
-
-class CheckGotRevision(ShellCmd):
-    description = 'got_revision'
-    command = ['hg', 'parents', '--template', 'got_revision:{rev}:{node}']
-
-    def commandComplete(self, cmd):
-        if cmd.rc == 0:
-            got_revision = cmd.logs['stdio'].getText()
-            got_revision = got_revision.split('got_revision:')[-1]
-            # manually get the effect of {node|short} without using a
-            # '|' in the command-line, because it doesn't work on Windows
-            num = got_revision.find(':')
-            if num > 0:
-                got_revision = got_revision[:num + 13]
-            #
-            final_file_name = got_revision.replace(':', '-')
-            # ':' should not be part of filenames --- too many issues
-            self.build.setProperty('got_revision', got_revision,
-                                   'got_revision')
-            self.build.setProperty('final_file_name', final_file_name,
-                                   'got_revision')
-
-
 def update_hg(platform, factory, repourl, workdir, use_branch,
               force_branch=None):
-    if platform == 'win32':
-        command = "if not exist .hg rmdir /q /s ."
-    else:
-        command = "if [ ! -d .hg ]; then rm -fr * .[a-z]*; fi"
-    factory.addStep(ShellCmd(description="rmdir?",
-                             command=command,
-                             workdir=workdir,
-                             haltOnFailure=False))
-    #
-    if platform == "win32":
-        command = "if not exist .hg %s"
-    else:
-        command = "if [ ! -d .hg ]; then %s; fi"
-    command = command % ("hg clone -U " + repourl + " .")
-    factory.addStep(ShellCmd(description="hg clone",
-                             command=command,
-                             workdir=workdir,
-                             timeout=3600,
-                             haltOnFailure=True))
-    #
     factory.addStep(
-        ShellCmd(description="hg purge",
-                 command="hg --config extensions.purge= purge --all",
-                 workdir=workdir,
-                 haltOnFailure=True))
-    #
-    factory.addStep(ShellCmd(description="hg pull",
-                             command="hg pull",
-                             workdir=workdir))
-    #
-    if use_branch or force_branch:
-        factory.addStep(UpdateCheckout(workdir=workdir,
-                                       haltOnFailure=True,
-                                       force_branch=force_branch))
-    else:
-        factory.addStep(ShellCmd(description="hg update",
-                command=WithProperties("hg update --clean %(revision)s"),
-                workdir=workdir))
+            Mercurial(
+                repourl=repourl,
+                mode='incremental',
+                method='fresh',
+                defaultBranch=force_branch,
+                branchType='inrepo',
+                clobberOnBranchChange=False,
+                workdir=workdir,
+                logEnviron=False))
 
 
 def setup_steps(platform, factory, workdir=None,
     update_hg(platform, factory, repourl, workdir, use_branch=True,
               force_branch=force_branch)
     #
-    factory.addStep(CheckGotRevision(workdir=workdir))
+
 
 def build_name(platform, jit=False, flags=[], placeholder=None):
     if placeholder is None:
-        placeholder = '%(final_file_name)s'
+        placeholder = '%(got_revision)s'
     if jit or '-Ojit' in flags:
         kind = 'jit'
     else: