Ticket #277: buildbot-bug277.patch

File buildbot-bug277.patch, 3.3 kB (added by bsmedberg, 4 months ago)

Updated patch

  • buildbot/slave/commands.py

    old new  
    22042204    def setup(self, args): 
    22052205        SourceBase.setup(self, args) 
    22062206        self.vcexe = getCommand("hg") 
    22072207        self.repourl = args['repourl'] 
    22082208        self.sourcedata = "%s\n" % self.repourl 
    22092209        self.stdout = "" 
    22102210        self.stderr = "" 
    22112211 
    22122212    def sourcedirIsUpdateable(self): 
    22132213        if os.path.exists(os.path.join(self.builder.basedir, 
    22142214                                       self.srcdir, ".buildbot-patched")): 
    22152215            return False 
    2216         # like Darcs, to check out a specific (old) revision, we have to do a 
    2217         # full checkout. TODO: I think 'hg pull' plus 'hg update' might work 
    2218         if self.revision: 
    2219             return False 
    22202216        return os.path.isdir(os.path.join(self.builder.basedir, 
    22212217                                          self.srcdir, ".hg")) 
    22222218 
    22232219    def doVCUpdate(self): 
    22242220        d = os.path.join(self.builder.basedir, self.srcdir) 
    2225         command = [self.vcexe, 'pull', '--update', '--verbose'] 
    2226         if self.args['revision']: 
    2227             command.extend(['--rev', self.args['revision']]) 
     2221        command = [self.vcexe, 'pull', '--verbose'] 
    22282222        c = ShellCommand(self.builder, command, d, 
    22292223                         sendRC=False, timeout=self.timeout, 
    22302224                         keepStdout=True) 
    22312225        self.command = c 
    22322226        d = c.start() 
    22332227        d.addCallback(self._handleEmptyUpdate) 
    22342228        return d 
    22352229 
    22362230    def _handleEmptyUpdate(self, res): 
     2231        if res == 0: 
     2232            return self._doUpdate() 
     2233         
    22372234        if type(res) is int and res == 1: 
    22382235            if self.command.stdout.find("no changes found") != -1: 
    22392236                # 'hg pull', when it doesn't have anything to do, exits with 
    22402237                # rc=1, and there appears to be no way to shut this off. It 
    22412238                # emits a distinctive message to stdout, though. So catch 
    22422239                # this and pretend that it completed successfully. 
    2243                 return 0 
     2240                return self._doUpdate() 
    22442241        return res 
    22452242 
     2243    def _doUpdate(self): 
     2244        dir = os.path.join(self.builder.basedir, self.srcdir) 
     2245        # When cloning a tree without a specified revision, you get the tip 
     2246        # of the default branch. Do the same thing when updating without 
     2247        # a specified revision. 
     2248        if self.args['revision']: 
     2249            rev = self.args['revision'] 
     2250        else: 
     2251            rev = 'default' 
     2252        command = [self.vcexe, 'update', '-C', '--rev', rev] 
     2253        c = ShellCommand(self.builder, command, dir, 
     2254                         sendRC=False, timeout=self.timeout, 
     2255                         keepStdout=True) 
     2256        return c.start() 
     2257 
    22462258    def doVCFull(self): 
    22472259        newdir = os.path.join(self.builder.basedir, self.srcdir) 
    22482260        command = [self.vcexe, 'clone'] 
    22492261        if self.args['revision']: 
    22502262            command.extend(['--rev', self.args['revision']]) 
    22512263        command.extend([self.repourl, newdir]) 
    22522264        c = ShellCommand(self.builder, command, self.builder.basedir, 
    22532265                         sendRC=False, keepStdout=True, keepStderr=True, 
    22542266                         timeout=self.timeout) 
    22552267        self.command = c 
    22562268        d = c.start() 
    22572269        d.addCallback(self._maybeFallback, c)